From c8b626f655ca33592a8cc9e892aa28c79d826403 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 29 Aug 2021 00:56:57 +0200 Subject: [PATCH] Improved Chat API --- .../java/fr/pandacube/lib/core/chat/Chat.java | 38 +++++++++---------- .../fr/pandacube/lib/core/chat/ChatUtil.java | 34 +++++++++++++---- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java b/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java index f881d51..548b3ed 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java +++ b/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java @@ -218,26 +218,26 @@ public abstract class Chat extends ChatStatic implements HoverEventSource maxWidth) return text; @@ -215,9 +227,13 @@ public class ChatUtil { public static Chat leftText(Chat text, char repeatedChar, TextColor decorationColor, int nbLeft, boolean console) { + return leftText(text, repeatedChar, decorationColor, nbLeft, console, console ? CONSOLE_NB_CHAR_DEFAULT : DEFAULT_CHAT_WIDTH); + } + + public static Chat leftText(Chat text, char repeatedChar, TextColor decorationColor, int nbLeft, + boolean console, int maxWidth) { int textWidth = componentWidth(text.getAdv(), console); - int maxWidth = (console) ? CONSOLE_NB_CHAR_DEFAULT : DEFAULT_CHAT_WIDTH; int repeatedCharWidth = charW(repeatedChar, console, false); int leftWidth = nbLeft * repeatedCharWidth; @@ -238,9 +254,13 @@ public class ChatUtil { public static Chat rightText(Chat text, char repeatedChar, TextColor decorationColor, int nbRight, boolean console) { + return rightText(text, repeatedChar, decorationColor, nbRight, console, console ? CONSOLE_NB_CHAR_DEFAULT : DEFAULT_CHAT_WIDTH); + } + + public static Chat rightText(Chat text, char repeatedChar, TextColor decorationColor, int nbRight, + boolean console, int maxWidth) { int textWidth = componentWidth(text.getAdv(), console); - int maxWidth = (console) ? CONSOLE_NB_CHAR_DEFAULT : DEFAULT_CHAT_WIDTH; int repeatedCharWidth = charW(repeatedChar, console, false); int rightWidth = nbRight * repeatedCharWidth;