Fixed local server time in client's chat messages

This commit is contained in:
rsypen 2018-01-15 09:17:35 +01:00 committed by GitHub
parent bc3274b144
commit ccd121277a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 17 deletions

View file

@ -37,6 +37,8 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.text.DateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -55,6 +57,11 @@ import org.mage.card.arcane.ManaSymbols;
*/
public class ChatPanelBasic extends javax.swing.JPanel {
/**
* Time formatter
*/
protected final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
protected UUID chatId;
/**
* Chat message color for opponents.
@ -238,10 +245,10 @@ public class ChatPanelBasic extends javax.swing.JPanel {
*/
Pattern cardNamePattern = Pattern.compile(".*<font bgcolor=orange.*?</font>.*");
public void receiveMessage(String username, String message, String time, MessageType messageType, MessageColor color) {
public void receiveMessage(String username, String message, Date time, MessageType messageType, MessageColor color) {
StringBuilder text = new StringBuilder();
if (time != null) {
text.append(getColoredText(TIMESTAMP_COLOR, time + ": "));
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": "));
//this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
}
String userColor;

View file

@ -28,6 +28,7 @@
package mage.client.chat;
import java.awt.Font;
import java.util.Date;
import mage.client.SessionHandler;
import mage.client.components.ColorPane;
@ -54,7 +55,7 @@ public class ChatPanelSeparated extends ChatPanelBasic {
* @param color Preferred color. Not used.
*/
@Override
public void receiveMessage(String username, String message, String time, ChatMessage.MessageType messageType, ChatMessage.MessageColor color) {
public void receiveMessage(String username, String message, Date time, ChatMessage.MessageType messageType, ChatMessage.MessageColor color) {
switch (messageType) {
case TALK:
case WHISPER_TO:
@ -65,7 +66,7 @@ public class ChatPanelSeparated extends ChatPanelBasic {
}
StringBuilder text = new StringBuilder();
if (time != null) {
text.append(getColoredText(TIMESTAMP_COLOR, time + ": "));
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": "));
}
String userColor;
String textColor;

View file

@ -7,7 +7,6 @@ import mage.interfaces.callback.ClientCallback;
import mage.interfaces.callback.ClientCallbackMethod;
import mage.view.ChatMessage;
import java.text.DateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.StringTokenizer;
@ -15,8 +14,6 @@ import java.util.UUID;
public final class LocalCommands {
private static final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
/**
* Handler for commands that do not require server interaction, i.e settings etc
* @param chatId
@ -60,7 +57,7 @@ public final class LocalCommands {
private static void displayLocalCommandResponse(UUID chatId, String response) {
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
new ChatMessage("", text, new Date(), ChatMessage.MessageColor.BLUE));
MageFrame.getInstance().processCallback(chatMessage);
}
}