From 1a07815f4b535cc80c32579b010294eb4b49ecfc Mon Sep 17 00:00:00 2001 From: snowleo Date: Fri, 3 Aug 2012 22:57:29 +0200 Subject: Make chat handling more thread safe (and also faster) --- .../essentials/chat/EssentialsChatPlayerListenerLowest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'EssentialsChat/src') diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java index 599c39dda..79ff4994a 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.chat; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.text.MessageFormat; import java.util.Locale; import java.util.Map; import org.bukkit.Server; @@ -40,9 +41,13 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer event.setMessage(Util.formatMessage(user, "essentials.chat", event.getMessage())); String group = user.getGroup(); String world = user.getWorld().getName(); - event.setFormat(ess.getSettings().getChatFormat(group).format(new Object[] - { - group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH) - })); + MessageFormat format = ess.getSettings().getChatFormat(group); + synchronized (format) + { + event.setFormat(format.format(new Object[] + { + group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH) + })); + } } } -- cgit v1.2.3