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.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);
}
}
}

View File

@ -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) {

View File

@ -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: