diff --git a/ChatApp/app/src/main/java/client/ClientGuiController.java b/ChatApp/app/src/main/java/client/ClientGuiController.java index cefaabf..0a0f472 100644 --- a/ChatApp/app/src/main/java/client/ClientGuiController.java +++ b/ChatApp/app/src/main/java/client/ClientGuiController.java @@ -71,9 +71,7 @@ public class ClientGuiController implements ClientListener { * Request the list of rooms from the server every second. */ private void requestRoomsRegularly() { - Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), event -> { - client.RequestRoomList(); - })); + Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), event -> client.RequestRoomList())); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play(); } @@ -130,7 +128,7 @@ public class ClientGuiController implements ClientListener { String timeString = formatter.format(time); Text chatterText = new Text(chatter + ": "); chatterText.setStyle("-fx-fill: black; -fx-font-weight: bold;"); - TextFlow messageText = formatMessage(chatter, untagged); + TextFlow messageText = formatMessage(untagged); TextFlow wholeMessage = new TextFlow(chatterText, messageText); Text timeText = new Text(" " + timeString); timeText.setStyle("-fx-fill: gray; -fx-font-size: 10px;"); @@ -151,7 +149,7 @@ public class ClientGuiController implements ClientListener { Pattern pattern = Pattern.compile("\u001B\\[44;30m(.*?)\u001B\\[49;39m"); Matcher matcher = pattern.matcher(message); - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); while (matcher.find()) { String taggedName = matcher.group(1); matcher.appendReplacement(result, taggedName); @@ -220,11 +218,10 @@ public class ClientGuiController implements ClientListener { /** * Colorize the message according to the color codes. - * @param chatter the name of the person who sent the message * @param content the content of the message * @return the formatted message */ - private TextFlow formatMessage(String chatter, String content) { + private TextFlow formatMessage(String content) { TextFlow textFlow = new TextFlow(); // Evil regex : match every sequence starting with a color code ending with the next color code Pattern pattern = Pattern.compile("&([rbgyn])([^&]*)");