From a45b48786813fc17f2305fb9d6d99e0f89108fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Fri, 21 Oct 2022 23:58:52 +0200 Subject: [PATCH] Implement basic PlaceholderAPI support --- pom.xml | 13 +++- .../wtf/beatrice/nounspicker/NounsPicker.java | 18 ++++++ .../nounspicker/objects/PAPIManager.java | 62 +++++++++++++++++++ src/main/resources/plugin.yml | 2 + 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/main/java/wtf/beatrice/nounspicker/objects/PAPIManager.java diff --git a/pom.xml b/pom.xml index 9128009..7945b59 100644 --- a/pom.xml +++ b/pom.xml @@ -19,8 +19,12 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + @@ -30,6 +34,13 @@ 1.19.2-R0.1-SNAPSHOT provided + + me.clip + placeholderapi + 2.10.9 + provided + + diff --git a/src/main/java/wtf/beatrice/nounspicker/NounsPicker.java b/src/main/java/wtf/beatrice/nounspicker/NounsPicker.java index 2fd127e..71e7edf 100644 --- a/src/main/java/wtf/beatrice/nounspicker/NounsPicker.java +++ b/src/main/java/wtf/beatrice/nounspicker/NounsPicker.java @@ -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; + } } \ No newline at end of file diff --git a/src/main/java/wtf/beatrice/nounspicker/objects/PAPIManager.java b/src/main/java/wtf/beatrice/nounspicker/objects/PAPIManager.java new file mode 100644 index 0000000..ef412ce --- /dev/null +++ b/src/main/java/wtf/beatrice/nounspicker/objects/PAPIManager.java @@ -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; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a3dfce8..bad2647 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,6 +3,8 @@ version: 1.0 author: astro_bea main: wtf.beatrice.nounspicker.NounsPicker api-version: 1.19 +depend: + - PlaceholderAPI commands: nouns: