mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-31 03:07:34 +02:00
Migrate to PlaceholderExpansion from PlaceholderAPI
This commit is contained in:
@ -1,14 +1,15 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderHook;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
|
||||||
|
|
||||||
public class PremiumPlaceholder extends PlaceholderHook {
|
public class PremiumPlaceholder extends PlaceholderExpansion {
|
||||||
|
|
||||||
|
private static final String PLACEHOLDER_VARIABLE = "fastlogin_status";
|
||||||
|
|
||||||
private final FastLoginBukkit plugin;
|
private final FastLoginBukkit plugin;
|
||||||
|
|
||||||
@ -16,25 +17,37 @@ public class PremiumPlaceholder extends PlaceholderHook {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void register(FastLoginBukkit plugin) {
|
||||||
|
PremiumPlaceholder placeholderHook = new PremiumPlaceholder(plugin);
|
||||||
|
PlaceholderAPI.registerPlaceholderHook(PLACEHOLDER_VARIABLE, placeholderHook);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onPlaceholderRequest(Player player, String variable) {
|
public String onPlaceholderRequest(Player player, String variable) {
|
||||||
if (player != null && "fastlogin_status".contains(variable)) {
|
if (player != null && PLACEHOLDER_VARIABLE.equals(variable)) {
|
||||||
List<MetadataValue> metadata = player.getMetadata(plugin.getName());
|
return plugin.getStatus(player.getUniqueId()).name();
|
||||||
if (metadata == null) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metadata.isEmpty()) {
|
|
||||||
return "cracked";
|
|
||||||
} else {
|
|
||||||
return "premium";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(FastLoginBukkit plugin) {
|
@Override
|
||||||
PlaceholderAPI.registerPlaceholderHook(plugin, new PremiumPlaceholder(plugin));
|
public String getIdentifier() {
|
||||||
|
return PLACEHOLDER_VARIABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlugin() {
|
||||||
|
return plugin.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return plugin.getDescription().getAuthors().stream().collect(Collectors.joining(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return plugin.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user