Placeholders now properly reload with '/papi reload'

This commit is contained in:
Esophose 2019-03-23 00:40:19 -06:00
parent 130a3437a6
commit 868ec061c9
3 changed files with 19 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package me.goodandevil.skyblock.placeholder;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration; 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.NumberUtil;
import me.goodandevil.skyblock.utils.player.OfflinePlayer; import me.goodandevil.skyblock.utils.player.OfflinePlayer;
import me.goodandevil.skyblock.visit.Visit; 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; private final SkyBlock skyblock;
public EZPlaceholder(SkyBlock skyblock) { public EZPlaceholder(SkyBlock skyblock) {
this.skyblock = skyblock; this.skyblock = skyblock;
Bukkit.getPluginManager().registerEvents(this, skyblock);
} }
public String getIdentifier() { public String getIdentifier() {
@ -113,4 +117,14 @@ public class EZPlaceholder extends PlaceholderExpansion {
return placeholderManager.getPlaceholder(player, "fabledskyblock_" + identifier); 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);
}
}
} }

View File

@ -72,10 +72,10 @@ public class PlaceholderManager {
if (placeholder.equalsIgnoreCase("fabledskyblock_island_exists")) { if (placeholder.equalsIgnoreCase("fabledskyblock_island_exists")) {
if (island == null) { if (island == null) {
return ChatColor.translateAlternateColorCodes('&', return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_island_exists.False.Message")); configLoad.getString("Placeholder.fabledskyblock_island_exists.Not-exists.Message"));
} else { } else {
return ChatColor.translateAlternateColorCodes('&', 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")) { } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_size")) {
if (island == null) { if (island == null) {

View File

@ -1091,9 +1091,9 @@ Placeholder:
Non-empty: Non-empty:
Message: "&f[%position] %player [%votes]" Message: "&f[%position] %player [%votes]"
fabledskyblock_island_exists: fabledskyblock_island_exists:
True: Exists:
Message: "&atrue" Message: "&atrue"
False: Not-exists:
Message: "&cfalse" Message: "&cfalse"
fabledskyblock_island_size: fabledskyblock_island_size:
Empty: Empty: