Admin can watch tournament games.
This commit is contained in:
@@ -23,8 +23,8 @@ public class ChatRoomMediator {
|
|||||||
_channelInactivityTimeoutPeriod = 1000 * secondsTimeoutPeriod;
|
_channelInactivityTimeoutPeriod = 1000 * secondsTimeoutPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<ChatMessage> joinUser(String playerId) {
|
public synchronized List<ChatMessage> joinUser(String playerId, boolean admin) {
|
||||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||||
|
|
||||||
GatheringChatRoomListener value = new GatheringChatRoomListener();
|
GatheringChatRoomListener value = new GatheringChatRoomListener();
|
||||||
@@ -33,8 +33,8 @@ public class ChatRoomMediator {
|
|||||||
return value.consumeMessages();
|
return value.consumeMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<ChatMessage> getPendingMessages(String playerId) {
|
public synchronized List<ChatMessage> getPendingMessages(String playerId, boolean admin) {
|
||||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||||
|
|
||||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||||
@@ -48,8 +48,8 @@ public class ChatRoomMediator {
|
|||||||
_listeners.remove(playerId);
|
_listeners.remove(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void sendMessage(String playerId, String message) {
|
public synchronized void sendMessage(String playerId, String message, boolean admin) {
|
||||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||||
|
|
||||||
_chatRoom.postMessage(playerId, message);
|
_chatRoom.postMessage(playerId, message);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gempukku.lotro.chat;
|
|||||||
|
|
||||||
import com.gempukku.lotro.AbstractServer;
|
import com.gempukku.lotro.AbstractServer;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -12,16 +11,14 @@ public class ChatServer extends AbstractServer {
|
|||||||
|
|
||||||
public ChatRoomMediator createChatRoom(String name, int secondsTimeoutPeriod) {
|
public ChatRoomMediator createChatRoom(String name, int secondsTimeoutPeriod) {
|
||||||
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod);
|
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod);
|
||||||
chatRoom.sendMessage("System", "Welcome to room: " + name);
|
chatRoom.sendMessage("System", "Welcome to room: " + name, true);
|
||||||
_chatRooms.put(name, chatRoom);
|
_chatRooms.put(name, chatRoom);
|
||||||
return chatRoom;
|
return chatRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatRoomMediator createPrivateChatRoom(String name, Set<String> allowedUsers, int secondsTimeoutPeriod) {
|
public ChatRoomMediator createPrivateChatRoom(String name, Set<String> allowedUsers, int secondsTimeoutPeriod) {
|
||||||
Set<String> allowed = new HashSet<String>(allowedUsers);
|
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod, allowedUsers);
|
||||||
allowed.add("System");
|
chatRoom.sendMessage("System", "Welcome to private room: " + name, true);
|
||||||
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod, allowed);
|
|
||||||
chatRoom.sendMessage("System", "Welcome to private room: " + name);
|
|
||||||
_chatRooms.put(name, chatRoom);
|
_chatRooms.put(name, chatRoom);
|
||||||
return chatRoom;
|
return chatRoom;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ public class LotroGameMediator {
|
|||||||
|
|
||||||
public void processCommunicationChannel(Player player, int channelNumber, ParticipantCommunicationVisitor visitor) {
|
public void processCommunicationChannel(Player player, int channelNumber, ParticipantCommunicationVisitor visitor) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
if (!player.getType().contains("a") && _noSpectators && !_playersPlaying.contains(playerName))
|
||||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||||
|
|
||||||
_readLock.lock();
|
_readLock.lock();
|
||||||
@@ -360,7 +360,7 @@ public class LotroGameMediator {
|
|||||||
|
|
||||||
public void singupUserForGame(Player player, ParticipantCommunicationVisitor visitor) {
|
public void singupUserForGame(Player player, ParticipantCommunicationVisitor visitor) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
if (!player.getType().contains("a") && _noSpectators && !_playersPlaying.contains(playerName))
|
||||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||||
|
|
||||||
_readLock.lock();
|
_readLock.lock();
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class LotroServer extends AbstractServer {
|
|||||||
String gameId = finishedGame.getKey();
|
String gameId = finishedGame.getKey();
|
||||||
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeathWarning
|
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeathWarning
|
||||||
&& !_gameDeathWarningsSent.contains(gameId)) {
|
&& !_gameDeathWarningsSent.contains(gameId)) {
|
||||||
_chatServer.getChatRoom(getChatRoomName(gameId)).sendMessage("System", "This game is already finished and will be shortly removed, please move to the Game Hall");
|
_chatServer.getChatRoom(getChatRoomName(gameId)).sendMessage("System", "This game is already finished and will be shortly removed, please move to the Game Hall", true);
|
||||||
_gameDeathWarningsSent.add(gameId);
|
_gameDeathWarningsSent.add(gameId);
|
||||||
}
|
}
|
||||||
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeath) {
|
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeath) {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ public class HallServer extends AbstractServer {
|
|||||||
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId());
|
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId());
|
||||||
if (lotroGameMediator != null) {
|
if (lotroGameMediator != null) {
|
||||||
if (!lotroGameMediator.isFinished())
|
if (!lotroGameMediator.isFinished())
|
||||||
visitor.visitTable(runningGame.getKey(), runningTable.getGameId(), !lotroGameMediator.isNoSpectators(), lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner());
|
visitor.visitTable(runningGame.getKey(), runningTable.getGameId(), player.getType().contains("a") || !lotroGameMediator.isNoSpectators(), lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner());
|
||||||
else
|
else
|
||||||
finishedTables.put(runningGame.getKey(), runningTable);
|
finishedTables.put(runningGame.getKey(), runningTable);
|
||||||
}
|
}
|
||||||
@@ -543,7 +543,7 @@ public class HallServer extends AbstractServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcastMessage(String message) {
|
public void broadcastMessage(String message) {
|
||||||
_hallChat.sendMessage("TournamentSystem", message);
|
_hallChat.sendMessage("TournamentSystem", message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class ChatResource extends AbstractResource {
|
|||||||
if (chatRoom == null)
|
if (chatRoom == null)
|
||||||
sendError(Response.Status.NOT_FOUND);
|
sendError(Response.Status.NOT_FOUND);
|
||||||
|
|
||||||
List<ChatMessage> chatMessages = chatRoom.joinUser(resourceOwner.getName());
|
List<ChatMessage> chatMessages = chatRoom.joinUser(resourceOwner.getName(), resourceOwner.getType().contains("a"));
|
||||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||||
|
|
||||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
@@ -69,11 +69,11 @@ public class ChatResource extends AbstractResource {
|
|||||||
if (messages != null) {
|
if (messages != null) {
|
||||||
for (String message : messages) {
|
for (String message : messages) {
|
||||||
if (message != null && message.trim().length() > 0)
|
if (message != null && message.trim().length() > 0)
|
||||||
chatRoom.sendMessage(resourceOwner.getName(), StringEscapeUtils.escapeHtml(message));
|
chatRoom.sendMessage(resourceOwner.getName(), StringEscapeUtils.escapeHtml(message), resourceOwner.getType().contains("a"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ChatMessage> chatMessages = chatRoom.getPendingMessages(resourceOwner.getName());
|
List<ChatMessage> chatMessages = chatRoom.getPendingMessages(resourceOwner.getName(), resourceOwner.getType().contains("a"));
|
||||||
|
|
||||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user