Placeholder Integration
How It Works
%phantomdungeons_{identifier}%
│
▼
PlaceholderManager.onPlaceholderRequest()
│
├─ CurrencyPlaceholders.handle() → null (not mine)
├─ ZonePlaceholders.handle() → null (not mine)
├─ ...
└─ YourCategory.handle() → "42" bingoQuick Start
1
Step 1 - Implement PlaceholderCategory
PlaceholderCategoryimport me.fergs.phantomdungeons.placeholders.PlaceholderCategory;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class MyPlaceholders implements PlaceholderCategory {
@Override
public @NotNull String getPrefix() {
return "myplugin"; // informational only — used for error logging
}
@Override
public @Nullable String handle(@NotNull Player player, @NotNull String identifier) {
// Only handle identifiers that belong to this category.
// Return null to let the next category try.
if (!identifier.startsWith("myplugin_")) {
return null;
}
String suffix = identifier.substring("myplugin_".length());
return switch (suffix) {
case "score" -> String.valueOf(getScore(player));
case "rank" -> getRank(player);
case "status" -> isActive(player) ? "&aActive" : "&cInactive";
default -> null; // unknown sub-key
};
}
}2
Step 2 - Register during onEnable()
onEnable()import me.fergs.phantomdungeons.PhantomDungeons;
import me.fergs.phantomdungeons.placeholders.PlaceholderManager;
public final class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
PhantomDungeons pd = (PhantomDungeons) getServer().getPluginManager().getPlugin("PhantomDungeons");
if (pd == null) return;
PlaceholderManager manager = pd.getPlaceholderManager();
if (manager == null) return; // PlaceholderAPI not present
manager.addCategory(new MyPlaceholders());
getLogger().info("Registered placeholders under %phantomdungeons_myplugin_*%");
}
}PlaceholderCategory Reference
PlaceholderCategory ReferenceMethod
Required
Description
Identifier Conventions
Built-in pattern
Example
Little Example - Some kind of kill counter
Accessing PhantomDungeons APIs from Your Category
Register before PlaceholderAPI resolves the first request
Last updated