From 1801dcb33b12c1ff1e3c86b53307afaf43c82df1 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Fri, 24 May 2024 13:14:10 -0400 Subject: [PATCH] Add validity check for MVdW Listener --- .../placeholder/MVdWPlaceholderAPIListener.java | 6 +++++- .../skript/elements/StructPlaceholder.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/apickledwalrus/skriptplaceholders/placeholder/MVdWPlaceholderAPIListener.java b/src/main/java/io/github/apickledwalrus/skriptplaceholders/placeholder/MVdWPlaceholderAPIListener.java index 9f49ad1..d9baf59 100644 --- a/src/main/java/io/github/apickledwalrus/skriptplaceholders/placeholder/MVdWPlaceholderAPIListener.java +++ b/src/main/java/io/github/apickledwalrus/skriptplaceholders/placeholder/MVdWPlaceholderAPIListener.java @@ -16,6 +16,7 @@ public class MVdWPlaceholderAPIListener implements PlaceholderListener { private final String placeholder; private final Set evaluators = new HashSet<>(); + private boolean isInvalid; public MVdWPlaceholderAPIListener(Plugin plugin, String placeholder) { this.plugin = plugin; @@ -25,6 +26,9 @@ public MVdWPlaceholderAPIListener(Plugin plugin, String placeholder) { @Override public void registerListener() { PlaceholderAPI.registerPlaceholder(plugin, placeholder, event -> { + if (isInvalid) { // true when the listener has been unregistered + return null; + } OfflinePlayer player = event.getPlayer(); if (player == null) { // this is for an actual offline player player = event.getOfflinePlayer(); @@ -41,7 +45,7 @@ public void registerListener() { @Override public void unregisterListener() { - // TODO determine if this is possible + isInvalid = true; } @Override diff --git a/src/main/java/io/github/apickledwalrus/skriptplaceholders/skript/elements/StructPlaceholder.java b/src/main/java/io/github/apickledwalrus/skriptplaceholders/skript/elements/StructPlaceholder.java index 41f2037..acfd840 100644 --- a/src/main/java/io/github/apickledwalrus/skriptplaceholders/skript/elements/StructPlaceholder.java +++ b/src/main/java/io/github/apickledwalrus/skriptplaceholders/skript/elements/StructPlaceholder.java @@ -46,7 +46,7 @@ "\t# Placeholder is \"{skriptplaceholders_author}\"", "\tset the result to \"APickledWalrus\"" }) -@Since("1.0.0, 1.3.0 (MVdWPlaceholderAPI support)") +@Since("1.0.0, 1.3.0 (MVdWPlaceholderAPI support), 1.7.0 (relational placeholder support)") public class StructPlaceholder extends Structure implements PlaceholderEvaluator { static {