From bb654279daa13077393fc11ef6ebd85c3bba51f3 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 12 May 2019 22:04:47 +0200 Subject: [PATCH] Updates for PlaceHolderAPI and some changes to the SignManager --- .idea/.name | 1 - .idea/uiDesigner.xml | 124 ------------------ pom.xml | 2 +- .../themepark/ThemeParkPlugin.java | 2 +- .../attraction/sign/SignManager.java | 7 +- .../placeholder/ThemeParkPlaceholder.java | 55 ++++++-- 6 files changed, 47 insertions(+), 144 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/uiDesigner.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 09564ec..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Theme \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 15f5163..2765fa8 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ me.clip placeholderapi - 2.0.6 + 2.10.2 provided diff --git a/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java b/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java index 325183d..49c4101 100644 --- a/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java +++ b/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java @@ -47,7 +47,7 @@ public class ThemeParkPlugin extends JavaPlugin { StatusManager.load(); AttractionMenu.load(); if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { - new ThemeParkPlaceholder(this).hook(); + new ThemeParkPlaceholder(this).register(); } } diff --git a/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java b/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java index b2fd940..1632f28 100644 --- a/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java +++ b/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java @@ -50,12 +50,13 @@ public class SignManager { for(Map.Entry> entry : signs.entrySet()) { List array = new ArrayList<>(); for(StatusSign sign : entry.getValue()) - array.add(LocationUtils.toString(sign.getLocation())); + if(LocationUtils.toString(sign.getLocation()) != null) + array.add(LocationUtils.toString(sign.getLocation())); - config.getConfig().set("signs." + entry.getKey().getId(), new ArrayList<>()); config.getConfig().set("signs." + entry.getKey().getId(), array); - config.save(); } + + config.save(); } public static void addSign(StatusSign sign) { diff --git a/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java b/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java index 24cfe02..96bf767 100644 --- a/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java +++ b/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java @@ -1,32 +1,59 @@ package me.paradoxpixel.themepark.placeholder; -import me.paradoxpixel.themepark.ThemeParkPlugin; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.paradoxpixel.themepark.api.API; import me.paradoxpixel.themepark.api.attraction.component.Status; import me.paradoxpixel.themepark.attraction.status.StatusManager; import me.paradoxpixel.themepark.utils.Utils; -import org.bukkit.entity.Player; -import me.clip.placeholderapi.external.EZPlaceholderHook; +import org.bukkit.OfflinePlayer; +import org.bukkit.plugin.Plugin; -public class ThemeParkPlaceholder extends EZPlaceholderHook { +public class ThemeParkPlaceholder extends PlaceholderExpansion { - public ThemeParkPlaceholder(ThemeParkPlugin plugin) { - super(plugin, "tp"); + private Plugin plugin; + + public ThemeParkPlaceholder(Plugin plugin){ + this.plugin = plugin; } @Override - public String onPlaceholderRequest(Player player, String identifier) { - if(identifier == null) - return null; + public boolean persist(){ + return true; + } + + @Override + public boolean canRegister() { + return true; + } + + @Override + public String getAuthor() { + return "ParadoxPixel"; + } + + @Override + public String getIdentifier() { + return "tp"; + } + + @Override + public String getVersion() { + return plugin.getDescription().getVersion(); + } + + @Override + public String onRequest(OfflinePlayer player, String identifier){ + if(identifier == null || player == null) + return ""; if(identifier.startsWith("status")) { String[] args = identifier.split(":"); if(args.length < 2) - return null; + return ""; String id = args[1]; if(!API.isAttraction(id)) - return null; + return ""; Status status = API.getAttraction(id).getStatus(); return Utils.color(StatusManager.getName(status)); @@ -35,17 +62,17 @@ public class ThemeParkPlaceholder extends EZPlaceholderHook { if(identifier.startsWith("name")) { String[] args = identifier.split(":"); if(args.length < 2) - return null; + return ""; String id = args[1]; if(!API.isAttraction(id)) - return null; + return ""; String name = API.getAttraction(id).getName(); return Utils.color(name); } - return null; + return ""; } } \ No newline at end of file