Only get expansions when checking for cleanable implementations

This commit is contained in:
extendedclip 2018-03-24 12:56:25 -04:00
parent 8a5d82d3a8
commit 11401f0bfd

View File

@ -36,6 +36,7 @@ import org.bukkit.event.server.PluginEnableEvent;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
public class PlaceholderListener implements Listener { public class PlaceholderListener implements Listener {
@ -126,7 +127,7 @@ public class PlaceholderListener implements Listener {
} }
if (ex.getPlugin().equalsIgnoreCase(n)) { if (ex.getPlugin().equalsIgnoreCase(n)) {
if (PlaceholderAPI.unregisterPlaceholderHook(hook.getKey())) { if (PlaceholderAPI.unregisterExpansion(ex)) {
plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier()); plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier());
} }
} }
@ -137,15 +138,15 @@ public class PlaceholderListener implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
Map<String, PlaceholderHook> placeholders = PlaceholderAPI.getPlaceholders(); Set<PlaceholderExpansion> expansions = PlaceholderAPI.getExpansions();
if (placeholders.isEmpty()) { if (expansions.isEmpty()) {
return; return;
} }
for (PlaceholderHook hooks : placeholders.values()) { for (PlaceholderExpansion ex : expansions) {
if (hooks instanceof Cleanable) { if (ex instanceof Cleanable) {
((Cleanable) hooks).cleanup(e.getPlayer()); ((Cleanable) ex).cleanup(e.getPlayer());
} }
} }
} }