mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Show player joins message in chat window only, if player isn't already connected. Suppres posting of empty strings in the chat window.
This commit is contained in:
parent
0cedc155ae
commit
e52c35fec9
1 changed files with 14 additions and 12 deletions
|
@ -56,7 +56,7 @@ public class ChatSession {
|
|||
|
||||
public void join(UUID userId) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
if (user != null && !clients.containsKey(userId)) {
|
||||
String userName = user.getName();
|
||||
clients.put(userId, userName);
|
||||
broadcast(userName, " has joined", MessageColor.BLACK);
|
||||
|
@ -74,17 +74,19 @@ public class ChatSession {
|
|||
}
|
||||
|
||||
public void broadcast(String userName, String message, MessageColor color) {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
final String msg = message;
|
||||
final String time = timeFormatter.format(cal.getTime());
|
||||
final String username = userName;
|
||||
logger.debug("Broadcasting '" + msg + "' for " + chatId);
|
||||
for (UUID userId: clients.keySet()) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null)
|
||||
user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
else
|
||||
kill(userId);
|
||||
if (!message.isEmpty()) {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
final String msg = message;
|
||||
final String time = timeFormatter.format(cal.getTime());
|
||||
final String username = userName;
|
||||
logger.debug("Broadcasting '" + msg + "' for " + chatId);
|
||||
for (UUID userId: clients.keySet()) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null)
|
||||
user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
else
|
||||
kill(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue