diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index 7ef083002a..755571becf 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -1,14 +1,5 @@ - package mage.server; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -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; @@ -20,6 +11,15 @@ import mage.view.ChatMessage.MessageType; import mage.view.ChatMessage.SoundToPlay; import org.apache.log4j.Logger; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * @author BetaSteward_at_googlemail.com */ @@ -107,7 +107,8 @@ public enum ChatManager { if (u.isPresent()) { User user = u.get(); - if (message.equals(userMessages.get(userName))) { + String messageId = chatId.toString() + message; + if (messageId.equals(userMessages.get(userName))) { // prevent identical messages String informUser = "Your message appears to be identical to your last message"; chatSessions.get(chatId).broadcastInfoToUser(user, informUser); @@ -144,7 +145,7 @@ public enum ChatManager { } } - userMessages.put(userName, message); + userMessages.put(userName, messageId); if (messageType == MessageType.TALK) { if (user.getChatLockedUntil() != null) { @@ -203,7 +204,7 @@ public enum ChatManager { if (session != null && session.getInfo() != null) { String gameId = session.getInfo(); if (gameId.startsWith("Game ")) { - UUID id = java.util.UUID.fromString(gameId.substring(5, gameId.length())); + UUID id = java.util.UUID.fromString(gameId.substring(5)); for (Entry entry : GameManager.instance.getGameController().entrySet()) { if (entry.getKey().equals(id)) { GameController controller = entry.getValue(); @@ -224,7 +225,7 @@ public enum ChatManager { if (session != null && session.getInfo() != null) { String gameId = session.getInfo(); if (gameId.startsWith("Game ")) { - UUID id = java.util.UUID.fromString(gameId.substring(5, gameId.length())); + UUID id = java.util.UUID.fromString(gameId.substring(5)); for (Entry entry : GameManager.instance.getGameController().entrySet()) { if (entry.getKey().equals(id)) { GameController controller = entry.getValue(); @@ -238,7 +239,7 @@ public enum ChatManager { } } return true; - } + } if (command.startsWith("CARD ")) { Matcher matchPattern = getCardTextPattern.matcher(message.toLowerCase(Locale.ENGLISH)); if (matchPattern.find()) {