Correct format for hour

This commit is contained in:
Clément
2025-02-28 15:02:03 +01:00
parent f0a9617649
commit 09637ba775
2 changed files with 6 additions and 2 deletions

View File

@@ -50,12 +50,14 @@ public class ClientConnexion implements PacketVisitor, PacketHandler{
public void visitPacket(ChatMessagePacket packet) {
StringBuilder sb = new StringBuilder();
String time = packet.getTime().toString();
sb.append("&y[");
sb.append(time, 11, 19); // We only take the HH:MM:SS part
sb.append("]&n");
sb.append(" ");
sb.append(packet.getChatter());
sb.append(" : ");
sb.append(ANSIColor.formatString(packet.getContent() + "&n")); // make the color back to normal at the end of every message
System.out.println(sb);
sb.append(packet.getContent()).append("&n"); // make the color back to normal at the end of every message
System.out.println(ANSIColor.formatString(sb.toString()));
}
@Override

View File

@@ -6,11 +6,13 @@ public class ANSIColor {
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
public static final String BLUE = "\u001B[34m";
public static final String GREY = "\u001B[37m";
public static String formatString(String message){
return message.replace("&r", RED)
.replace("&g", GREEN)
.replace("&b", BLUE)
.replace("&y", GREY)
.replace("&n", RESET);
}
}