Fix NoClassDef errors if the optional PlaceholderAPI is not available (Fixes #108)

This commit is contained in:
games647
2017-01-07 18:42:10 +01:00
parent f08daa9b72
commit 22aa9287e9
2 changed files with 10 additions and 5 deletions

View File

@ -27,8 +27,6 @@ import java.util.concurrent.ThreadFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.clip.placeholderapi.PlaceholderAPI;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
@ -114,7 +112,8 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
getCommand("import-auth").setExecutor(new ImportCommand(core));
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
PlaceholderAPI.registerPlaceholderHook(this, new PremiumPlaceholder(this));
//prevents NoClassDef errors if it's not available
PremiumPlaceholder.register(this);
}
}

View File

@ -7,14 +7,16 @@ import org.bukkit.metadata.MetadataValue;
import java.util.List;
import me.clip.placeholderapi.PlaceholderAPI;
public class PremiumPlaceholder extends PlaceholderHook {
private final FastLoginBukkit plugin;
public PremiumPlaceholder(FastLoginBukkit plugin) {
this.plugin = plugin;
}
}
@Override
public String onPlaceholderRequest(Player player, String variable) {
if (player != null && "fastlogin_status".contains(variable)) {
@ -32,4 +34,8 @@ public class PremiumPlaceholder extends PlaceholderHook {
return null;
}
public static boolean register(FastLoginBukkit plugin) {
return PlaceholderAPI.registerPlaceholderHook(plugin, new PremiumPlaceholder(plugin));
}
}