Sorting players in room ignore case.
This commit is contained in:
@@ -5,7 +5,13 @@ import java.util.*;
|
||||
public class ChatRoom {
|
||||
private int _maxMessageHistoryCount = 150;
|
||||
private LinkedList<ChatMessage> _lastMessages = new LinkedList<ChatMessage>();
|
||||
private Map<String, ChatRoomListener> _chatRoomListeners = new HashMap<String, ChatRoomListener>();
|
||||
private Map<String, ChatRoomListener> _chatRoomListeners = new TreeMap<String, ChatRoomListener>(
|
||||
new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareToIgnoreCase(o2);
|
||||
}
|
||||
});
|
||||
|
||||
public ChatRoom() {
|
||||
}
|
||||
@@ -40,8 +46,8 @@ public class ChatRoom {
|
||||
postMessage("System", playerId + " left the room", false);
|
||||
}
|
||||
|
||||
public Set<String> getUsersInRoom() {
|
||||
return new TreeSet<String>(_chatRoomListeners.keySet());
|
||||
public Collection<String> getUsersInRoom() {
|
||||
return new ArrayList<String>(_chatRoomListeners.keySet());
|
||||
}
|
||||
|
||||
private void shrinkLastMessages() {
|
||||
|
||||
@@ -2,10 +2,7 @@ package com.gempukku.lotro.chat;
|
||||
|
||||
import com.gempukku.lotro.game.GatheringChatRoomListener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class ChatRoomMediator {
|
||||
private ChatRoom _chatRoom = new ChatRoom();
|
||||
@@ -70,7 +67,7 @@ public class ChatRoomMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Set<String> getUsersInRoom() {
|
||||
public synchronized Collection<String> getUsersInRoom() {
|
||||
return _chatRoom.getUsersInRoom();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import javax.ws.rs.core.Response;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
@Path("/chat")
|
||||
@@ -42,7 +42,7 @@ public class ChatResource extends AbstractResource {
|
||||
List<ChatMessage> chatMessages = chatRoom.joinUser(resourceOwner.getName());
|
||||
if (chatMessages == null)
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
Set<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
@@ -80,7 +80,7 @@ public class ChatResource extends AbstractResource {
|
||||
if (chatMessages == null)
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
|
||||
Set<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
@@ -92,7 +92,7 @@ public class ChatResource extends AbstractResource {
|
||||
return doc;
|
||||
}
|
||||
|
||||
private void serializeChatRoomData(String room, List<ChatMessage> chatMessages, Set<String> usersInRoom, Document doc) {
|
||||
private void serializeChatRoomData(String room, List<ChatMessage> chatMessages, Collection<String> usersInRoom, Document doc) {
|
||||
Element chatElem = doc.createElement("chat");
|
||||
chatElem.setAttribute("roomName", room);
|
||||
doc.appendChild(chatElem);
|
||||
|
||||
Reference in New Issue
Block a user