Implement basic PlaceholderAPI support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,18 +1,36 @@
|
||||
package wtf.beatrice.nounspicker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import wtf.beatrice.nounspicker.objects.PAPIManager;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NounsPicker extends JavaPlugin
|
||||
{
|
||||
private static NounsPicker instance;
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
pluginManager = getServer().getPluginManager();
|
||||
instance = this;
|
||||
|
||||
|
||||
// register PlaceholderAPI
|
||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PAPIManager(this).register();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static NounsPicker getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package wtf.beatrice.nounspicker.objects;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.nounspicker.NounsPicker;
|
||||
|
||||
public class PAPIManager extends PlaceholderExpansion
|
||||
{
|
||||
|
||||
private final NounsPicker plugin;
|
||||
public PAPIManager(NounsPicker plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "nouns";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return plugin.getDescription().getAuthors().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, @NotNull String identifier) {
|
||||
|
||||
if (player == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
switch (identifier.toLowerCase()) {
|
||||
case "main_pronoun":
|
||||
|
||||
break;
|
||||
case "secondary_pronoun":
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user