summaryrefslogtreecommitdiffstats
path: root/EssentialsChat/src
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-08-07 16:03:12 +0200
committersnowleo <schneeleo@gmail.com>2012-08-07 16:03:39 +0200
commit54133cd75e53d67e431a36669f164eabd3b80c81 (patch)
tree18d3f9203b65c9fdf1dac80345bad0c8d7377133 /EssentialsChat/src
parent322fe386f67db869a49a4d2009b5fa2c890f97a3 (diff)
downloadEssentials-54133cd75e53d67e431a36669f164eabd3b80c81.tar
Essentials-54133cd75e53d67e431a36669f164eabd3b80c81.tar.gz
Essentials-54133cd75e53d67e431a36669f164eabd3b80c81.tar.lz
Essentials-54133cd75e53d67e431a36669f164eabd3b80c81.tar.xz
Essentials-54133cd75e53d67e431a36669f164eabd3b80c81.zip
Prevent errors in listeners affecting EssentialsChat
Diffstat (limited to 'EssentialsChat/src')
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
index 9dce1169c..1ebb6389c 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -46,11 +47,25 @@ public abstract class EssentialsChatPlayer implements Listener
}
synchronized (listeners)
{
- for (IEssentialsChatListener listener : listeners.values())
+ for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
{
- if (listener.shouldHandleThisChat(event))
+ try
{
- return true;
+ if (listener.getValue().shouldHandleThisChat(event))
+ {
+ return true;
+ }
+ }
+ catch (Throwable t)
+ {
+ if (ess.getSettings().isDebug())
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
+ }
+ else
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
+ }
}
}
}
@@ -160,9 +175,23 @@ public abstract class EssentialsChatPlayer implements Listener
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
synchronized (listeners)
{
- for (IEssentialsChatListener listener : listeners.values())
+ for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
{
- message = listener.modifyMessage(event, onlinePlayer, message);
+ try
+ {
+ message = listener.getValue().modifyMessage(event, onlinePlayer, message);
+ }
+ catch (Throwable t)
+ {
+ if (ess.getSettings().isDebug())
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
+ }
+ else
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
+ }
+ }
}
}
onlineUser.sendMessage(message);