Added tag feature
This commit is contained in:
@@ -15,4 +15,8 @@ public class ANSIColor {
|
||||
.replace("&y", GREY)
|
||||
.replace("&n", RESET);
|
||||
}
|
||||
|
||||
public static String tag(String message, String chatter){
|
||||
return message.replaceAll("(@" + chatter + ")", "\u001B[44;30m$1\u001B[49;39m" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
|
||||
import network.PacketHandler;
|
||||
import network.SocketReader;
|
||||
import network.protocol.ANSIColor;
|
||||
import network.protocol.Packet;
|
||||
import network.protocol.packets.ChatMessagePacket;
|
||||
import network.protocol.packets.SendChatMessagePacket;
|
||||
@@ -81,7 +82,9 @@ public class Server implements PacketHandler {
|
||||
|
||||
public boolean sendToRoom(String roomName, ChatMessagePacket packet) {
|
||||
if (roomName != null && rooms.containsKey(roomName)) {
|
||||
rooms.get(roomName).forEach(con -> con.sendPacket(packet));
|
||||
rooms.get(roomName).forEach(con -> con.sendPacket(
|
||||
new ChatMessagePacket(packet.getTime(), packet.getChatter(), ANSIColor.tag(packet.getContent(), con.getChatterName()))
|
||||
));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user