From 4c35650b2b27c5f7a39db8c67d9b5a49be57877f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 2 Apr 2017 10:51:00 +0200 Subject: [PATCH] * Fixed a problem that chat messages were no longer broadcast (fixes #3050). --- .../main/java/mage/server/ChatManager.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index e77b9b12dd..f8b5fd89de 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -27,6 +27,10 @@ */ package mage.server; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.server.exceptions.UserNotFoundException; @@ -36,11 +40,6 @@ import mage.view.ChatMessage.MessageType; import mage.view.ChatMessage.SoundToPlay; import org.apache.log4j.Logger; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * @author BetaSteward_at_googlemail.com */ @@ -50,7 +49,6 @@ public enum ChatManager { private static final Logger logger = Logger.getLogger(ChatManager.class); private static final HashMap userMessages = new HashMap<>(); - private final ConcurrentHashMap chatSessions = new ConcurrentHashMap<>(); public UUID createChatSession(String info) { @@ -159,7 +157,6 @@ public enum ChatManager { userMessages.put(userName, message); - if (messageType == MessageType.TALK) { if (user.getChatLockedUntil() != null) { if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) { @@ -173,8 +170,8 @@ public enum ChatManager { } } - chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay); } + chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay); } } @@ -255,11 +252,11 @@ public enum ChatManager { } public void sendReconnectMessage(UUID userId) { - UserManager.instance.getUser(userId).ifPresent(user -> - chatSessions.values() - .stream() - .filter(chat -> chat.hasUser(userId)) - .forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null))); + UserManager.instance.getUser(userId).ifPresent(user + -> chatSessions.values() + .stream() + .filter(chat -> chat.hasUser(userId)) + .forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null))); } @@ -275,6 +272,4 @@ public enum ChatManager { return new ArrayList<>(chatSessions.values()); } - } -