✏️
PlayerListDeluxe
  • Introduction
  • Troubleshoot
  • Configuration
    • Understanding the Config Element
    • Tablist Handlers
    • Sorting Feature
    • Migrating from PlayerListPlus
  • FAKE PLAYER
    • Managing Fake Player
    • Fake Player Placeholder
  • HOW TO
    • Where to put Handler?
    • How to add/remove column
    • Create Staff/VIP Handler
    • Prevent Same Player Showing in 2 Handler
    • Sort Player By Name and Etc
    • List of Player that in Same or in A World
    • Condition Tutorial
  • PLACEHOLDER
    • Using Placeholder From PlaceholderAPI
    • Custom Placeholders
  • API
    • Creating Complex Placeholder
    • Creating Parameterized Placeholder
    • Creating Simple Placeholder
    • Managing your own Tablist
    • Events
    • Skin Toolkit
Powered by GitBook
On this page
  • Introduction
  • Implementing the class

Was this helpful?

  1. API

Creating Parameterized Placeholder

Introduction

This class allows you to replace parameterized placeholder.

Implementing the class

public class ExamplePlaceholder implements ParameterizedPlaceholder {

    public ExamplePlaceholder() {
        // register the placeholder
        PlaceholderManager.register(this);
    }
    
    @Override
    public boolean accept(String placeholder) {
        return "example".equals(placeholder);
    }
    
    @Override
    public String provide(String placeholder, String param, ExtraData data) {
        if (param != null) {
            Player player = Bukkit.getPlayer(param);
            if (player != null) {
                return String.valueOf(player.getHealth());
            }
        }
        return "NOT_FOUND";
    }

}

/*
    To use your parameterized placeholder:
    {example} will result NOT_FOUND
    {example_Septogeddon} will result 20.0 (assuming that player Septogeddon is online)
    {example_Notch} will result NOT_FOUND (assuming that player Notch is offline)
*/
PreviousCreating Complex PlaceholderNextCreating Simple Placeholder

Last updated 5 years ago

Was this helpful?