From 868ec061c931b80a0af1fe3e7c32b7fba0b63e9f Mon Sep 17 00:00:00 2001 From: Esophose Date: Sat, 23 Mar 2019 00:40:19 -0600 Subject: [PATCH] Placeholders now properly reload with '/papi reload' --- .../skyblock/placeholder/EZPlaceholder.java | 16 +++++++++++++++- .../skyblock/placeholder/PlaceholderManager.java | 4 ++-- src/main/resources/language.yml | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/goodandevil/skyblock/placeholder/EZPlaceholder.java b/src/main/java/me/goodandevil/skyblock/placeholder/EZPlaceholder.java index e4625067..e044cf17 100644 --- a/src/main/java/me/goodandevil/skyblock/placeholder/EZPlaceholder.java +++ b/src/main/java/me/goodandevil/skyblock/placeholder/EZPlaceholder.java @@ -3,6 +3,7 @@ package me.goodandevil.skyblock.placeholder; import java.io.File; import java.util.List; +import me.clip.placeholderapi.events.ExpansionUnregisterEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; @@ -18,13 +19,16 @@ import me.goodandevil.skyblock.leaderboard.LeaderboardManager; import me.goodandevil.skyblock.utils.NumberUtil; import me.goodandevil.skyblock.utils.player.OfflinePlayer; import me.goodandevil.skyblock.visit.Visit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; -public class EZPlaceholder extends PlaceholderExpansion { +public class EZPlaceholder extends PlaceholderExpansion implements Listener { private final SkyBlock skyblock; public EZPlaceholder(SkyBlock skyblock) { this.skyblock = skyblock; + Bukkit.getPluginManager().registerEvents(this, skyblock); } public String getIdentifier() { @@ -113,4 +117,14 @@ public class EZPlaceholder extends PlaceholderExpansion { return placeholderManager.getPlaceholder(player, "fabledskyblock_" + identifier); } + + /** + * If a player uses '/papi reload' then we need to reload this expansion + */ + @EventHandler + public void onExpansionUnregister(ExpansionUnregisterEvent event) { + if (event.getExpansion() instanceof EZPlaceholder) { + Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, this::register, 20L); + } + } } diff --git a/src/main/java/me/goodandevil/skyblock/placeholder/PlaceholderManager.java b/src/main/java/me/goodandevil/skyblock/placeholder/PlaceholderManager.java index 09c4ab9a..9978fbee 100644 --- a/src/main/java/me/goodandevil/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/me/goodandevil/skyblock/placeholder/PlaceholderManager.java @@ -72,10 +72,10 @@ public class PlaceholderManager { if (placeholder.equalsIgnoreCase("fabledskyblock_island_exists")) { if (island == null) { return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_exists.False.Message")); + configLoad.getString("Placeholder.fabledskyblock_island_exists.Not-exists.Message")); } else { return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_exists.True.Message")); + configLoad.getString("Placeholder.fabledskyblock_island_exists.Exists.Message")); } } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_size")) { if (island == null) { diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 506788a8..1d346f2d 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1091,9 +1091,9 @@ Placeholder: Non-empty: Message: "&f[%position] %player [%votes]" fabledskyblock_island_exists: - True: + Exists: Message: "&atrue" - False: + Not-exists: Message: "&cfalse" fabledskyblock_island_size: Empty: