diff options
author | snowleo <schneeleo@gmail.com> | 2012-08-04 11:10:57 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-08-04 11:10:57 +0200 |
commit | 5379b3955f46b4551a4054930c8b79ce499b41c2 (patch) | |
tree | 82d408df507b2c7f01120d11a8c98e6209ecb490 /EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java | |
parent | bf93bb2026e1d3474be88759e72b144e218387db (diff) | |
download | Essentials-5379b3955f46b4551a4054930c8b79ce499b41c2.tar Essentials-5379b3955f46b4551a4054930c8b79ce499b41c2.tar.gz Essentials-5379b3955f46b4551a4054930c8b79ce499b41c2.tar.lz Essentials-5379b3955f46b4551a4054930c8b79ce499b41c2.tar.xz Essentials-5379b3955f46b4551a4054930c8b79ce499b41c2.zip |
More thread safety
Diffstat (limited to 'EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java')
-rw-r--r-- | EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java index 8ca16fbbb..9dce1169c 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java @@ -44,11 +44,14 @@ public abstract class EssentialsChatPlayer implements Listener { return true; } - for (IEssentialsChatListener listener : listeners.values()) + synchronized (listeners) { - if (listener.shouldHandleThisChat(event)) + for (IEssentialsChatListener listener : listeners.values()) { - return true; + if (listener.shouldHandleThisChat(event)) + { + return true; + } } } return false; @@ -155,9 +158,12 @@ public abstract class EssentialsChatPlayer implements Listener } String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage()); - for (IEssentialsChatListener listener : listeners.values()) + synchronized (listeners) { - message = listener.modifyMessage(event, onlinePlayer, message); + for (IEssentialsChatListener listener : listeners.values()) + { + message = listener.modifyMessage(event, onlinePlayer, message); + } } onlineUser.sendMessage(message); } |