From 3ab97276f6799098c57e77635a03aa4bc4d15419 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 19 Dec 2016 22:33:11 +0100 Subject: [PATCH] Finished IsRange --- .../java/buttondevteam/chat/ChatProcessing.java | 15 +++++---------- .../chat/formatting/ChatFormatterBuilder.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/buttondevteam/chat/ChatProcessing.java b/src/main/java/buttondevteam/chat/ChatProcessing.java index 3bdbd5b..2c18920 100644 --- a/src/main/java/buttondevteam/chat/ChatProcessing.java +++ b/src/main/java/buttondevteam/chat/ChatProcessing.java @@ -2,7 +2,6 @@ package buttondevteam.chat; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.regex.Pattern; import org.bukkit.Bukkit; @@ -21,11 +20,7 @@ import com.palmergames.bukkit.towny.object.Town; import buttondevteam.chat.commands.UnlolCommand; import buttondevteam.chat.commands.ucmds.admin.DebugCommand; -import buttondevteam.chat.formatting.ChatFormatter; -import buttondevteam.chat.formatting.ChatFormatterBuilder; -import buttondevteam.chat.formatting.TellrawEvent; -import buttondevteam.chat.formatting.TellrawPart; -import buttondevteam.chat.formatting.TellrawSerializer; +import buttondevteam.chat.formatting.*; import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.chat.Channel; @@ -57,15 +52,15 @@ public class ChatProcessing { static { commonFormatters.add(new ChatFormatterBuilder().setRegex(BOLD_PATTERN).setFormat(Format.Bold) - .setRemoveCharCount((short) 2).build()); + .setRemoveCharCount((short) 2).setRange(true).build()); commonFormatters.add(new ChatFormatterBuilder().setRegex(ITALIC_PATTERN).setFormat(Format.Italic) - .setRemoveCharCount((short) 1).build()); + .setRemoveCharCount((short) 1).setRange(true).build()); commonFormatters.add(new ChatFormatterBuilder().setRegex(UNDERLINED_PATTERN).setFormat(Format.Underlined) - .setRemoveCharCount((short) 1).build()); + .setRemoveCharCount((short) 1).setRange(true).build()); commonFormatters.add(ESCAPE_FORMATTER); // URLs + Rainbow text commonFormatters.add(new ChatFormatterBuilder().setRegex(URL_PATTERN).setFormat(Format.Underlined) - .setOpenlink("$1").build()); + .setOpenlink("$1").setRange(true).build()); commonFormatters.add(new ChatFormatterBuilder().setRegex(NULL_MENTION_PATTERN).setColor(Color.DarkRed).build()); // Properly added a bug as a feature commonFormatters.add(new ChatFormatterBuilder().setRegex(CONSOLE_PING_PATTERN).setColor(Color.Aqua) .setOnmatch((String match) -> { diff --git a/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java b/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java index 2277b10..a835d7f 100644 --- a/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java +++ b/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java @@ -14,9 +14,11 @@ public class ChatFormatterBuilder { private Priority priority; private short removecharcount = 0; private short removecharpos = -1; + private boolean range = false; public ChatFormatter build() { - return new ChatFormatter(regex, format, color, onmatch, openlink, priority, removecharcount, removecharpos); + return new ChatFormatter(regex, format, color, onmatch, openlink, priority, removecharcount, removecharpos, + range); } public Pattern getRegex() { @@ -100,4 +102,13 @@ public class ChatFormatterBuilder { this.removecharpos = removecharpos; return this; } + + public boolean isRange() { + return range; + } + + public ChatFormatterBuilder setRange(boolean range) { + this.range = range; + return this; + } }