Admin can watch tournament games.
This commit is contained in:
@@ -23,8 +23,8 @@ public class ChatRoomMediator {
|
||||
_channelInactivityTimeoutPeriod = 1000 * secondsTimeoutPeriod;
|
||||
}
|
||||
|
||||
public synchronized List<ChatMessage> joinUser(String playerId) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
public synchronized List<ChatMessage> joinUser(String playerId, boolean admin) {
|
||||
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
GatheringChatRoomListener value = new GatheringChatRoomListener();
|
||||
@@ -33,8 +33,8 @@ public class ChatRoomMediator {
|
||||
return value.consumeMessages();
|
||||
}
|
||||
|
||||
public synchronized List<ChatMessage> getPendingMessages(String playerId) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
public synchronized List<ChatMessage> getPendingMessages(String playerId, boolean admin) {
|
||||
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||
@@ -48,8 +48,8 @@ public class ChatRoomMediator {
|
||||
_listeners.remove(playerId);
|
||||
}
|
||||
|
||||
public synchronized void sendMessage(String playerId, String message) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
public synchronized void sendMessage(String playerId, String message, boolean admin) {
|
||||
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_chatRoom.postMessage(playerId, message);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.gempukku.lotro.chat;
|
||||
|
||||
import com.gempukku.lotro.AbstractServer;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -12,16 +11,14 @@ public class ChatServer extends AbstractServer {
|
||||
|
||||
public ChatRoomMediator createChatRoom(String name, int 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);
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
public ChatRoomMediator createPrivateChatRoom(String name, Set<String> allowedUsers, int secondsTimeoutPeriod) {
|
||||
Set<String> allowed = new HashSet<String>(allowedUsers);
|
||||
allowed.add("System");
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod, allowed);
|
||||
chatRoom.sendMessage("System", "Welcome to private room: " + name);
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(secondsTimeoutPeriod, allowedUsers);
|
||||
chatRoom.sendMessage("System", "Welcome to private room: " + name, true);
|
||||
_chatRooms.put(name, chatRoom);
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class LotroGameMediator {
|
||||
|
||||
public void processCommunicationChannel(Player player, int channelNumber, ParticipantCommunicationVisitor visitor) {
|
||||
String playerName = player.getName();
|
||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
||||
if (!player.getType().contains("a") && _noSpectators && !_playersPlaying.contains(playerName))
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_readLock.lock();
|
||||
@@ -360,7 +360,7 @@ public class LotroGameMediator {
|
||||
|
||||
public void singupUserForGame(Player player, ParticipantCommunicationVisitor visitor) {
|
||||
String playerName = player.getName();
|
||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
||||
if (!player.getType().contains("a") && _noSpectators && !_playersPlaying.contains(playerName))
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_readLock.lock();
|
||||
|
||||
@@ -100,7 +100,7 @@ public class LotroServer extends AbstractServer {
|
||||
String gameId = finishedGame.getKey();
|
||||
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeathWarning
|
||||
&& !_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);
|
||||
}
|
||||
if (currentTime > finishedGame.getValue().getTime() + _timeToGameDeath) {
|
||||
|
||||
@@ -265,7 +265,7 @@ public class HallServer extends AbstractServer {
|
||||
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId());
|
||||
if (lotroGameMediator != null) {
|
||||
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
|
||||
finishedTables.put(runningGame.getKey(), runningTable);
|
||||
}
|
||||
@@ -543,7 +543,7 @@ public class HallServer extends AbstractServer {
|
||||
|
||||
@Override
|
||||
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)
|
||||
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();
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
@@ -69,11 +69,11 @@ public class ChatResource extends AbstractResource {
|
||||
if (messages != null) {
|
||||
for (String message : messages) {
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user