mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Fixed that antispam blocks system messages in diff chat rooms;
This commit is contained in:
parent
b6f075c505
commit
2a750457d5
1 changed files with 15 additions and 14 deletions
|
@ -1,14 +1,5 @@
|
||||||
|
|
||||||
package mage.server;
|
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.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import mage.server.exceptions.UserNotFoundException;
|
import mage.server.exceptions.UserNotFoundException;
|
||||||
|
@ -20,6 +11,15 @@ import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.ChatMessage.SoundToPlay;
|
import mage.view.ChatMessage.SoundToPlay;
|
||||||
import org.apache.log4j.Logger;
|
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
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -107,7 +107,8 @@ public enum ChatManager {
|
||||||
if (u.isPresent()) {
|
if (u.isPresent()) {
|
||||||
|
|
||||||
User user = u.get();
|
User user = u.get();
|
||||||
if (message.equals(userMessages.get(userName))) {
|
String messageId = chatId.toString() + message;
|
||||||
|
if (messageId.equals(userMessages.get(userName))) {
|
||||||
// prevent identical messages
|
// prevent identical messages
|
||||||
String informUser = "Your message appears to be identical to your last message";
|
String informUser = "Your message appears to be identical to your last message";
|
||||||
chatSessions.get(chatId).broadcastInfoToUser(user, informUser);
|
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 (messageType == MessageType.TALK) {
|
||||||
if (user.getChatLockedUntil() != null) {
|
if (user.getChatLockedUntil() != null) {
|
||||||
|
@ -203,7 +204,7 @@ public enum ChatManager {
|
||||||
if (session != null && session.getInfo() != null) {
|
if (session != null && session.getInfo() != null) {
|
||||||
String gameId = session.getInfo();
|
String gameId = session.getInfo();
|
||||||
if (gameId.startsWith("Game ")) {
|
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<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
for (Entry<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
||||||
if (entry.getKey().equals(id)) {
|
if (entry.getKey().equals(id)) {
|
||||||
GameController controller = entry.getValue();
|
GameController controller = entry.getValue();
|
||||||
|
@ -224,7 +225,7 @@ public enum ChatManager {
|
||||||
if (session != null && session.getInfo() != null) {
|
if (session != null && session.getInfo() != null) {
|
||||||
String gameId = session.getInfo();
|
String gameId = session.getInfo();
|
||||||
if (gameId.startsWith("Game ")) {
|
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<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
for (Entry<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
||||||
if (entry.getKey().equals(id)) {
|
if (entry.getKey().equals(id)) {
|
||||||
GameController controller = entry.getValue();
|
GameController controller = entry.getValue();
|
||||||
|
|
Loading…
Reference in a new issue