From 9837ae969edfae29d71e4df2a9399c993b5fa2ee Mon Sep 17 00:00:00 2001 From: filoghost Date: Fri, 17 Feb 2017 11:36:58 +0100 Subject: [PATCH] Better placeholder error handling. Fixes #22 --- .../placeholder/PlaceholdersManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java index 3d01ff7d..bb7bdc94 100644 --- a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java +++ b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java @@ -4,12 +4,14 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import com.gmail.filoghost.holographicdisplays.HolographicDisplays; import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer; import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable; @@ -48,7 +50,11 @@ public class PlaceholdersManager { for (Placeholder placeholder : PlaceholdersRegister.getPlaceholders()) { if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) { - placeholder.update(); + try { + placeholder.update(); + } catch (Throwable t) { + HolographicDisplays.getInstance().getLogger().log(Level.WARNING, "The placeholder " + placeholder.getTextPlaceholder() + " registered by the plugin " + placeholder.getOwner().getName() + " generated an exception while updating. Please contact the author of " + placeholder.getOwner().getName(), t); + } } }