From 85a1defb6ad501024c9fc4cdae9a435f566c07b2 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 24 Sep 2016 19:00:37 +0200 Subject: [PATCH] #46 is harder than I thought --- .../java/buttondevteam/chat/ChatProcessing.java | 6 ------ .../chat/formatting/ChatFormatter.java | 13 ++----------- .../chat/formatting/FormattedSection.java | 3 +-- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/main/java/buttondevteam/chat/ChatProcessing.java b/src/main/java/buttondevteam/chat/ChatProcessing.java index 385fa60..646367a 100644 --- a/src/main/java/buttondevteam/chat/ChatProcessing.java +++ b/src/main/java/buttondevteam/chat/ChatProcessing.java @@ -110,12 +110,6 @@ public class ChatProcessing { // URLs + Rainbow text formatters.add(new ChatFormatterBuilder().setRegex(URL_PATTERN).setFormat(ChatFormatter.Format.Underlined) .setOpenlink("$1").build()); - /* - * formattedmessage = formattedmessage .replace( item, String.format( - * "\",\"color\":\"%s\"},{\"text\":\"%s\",\"color\":\"%s\",\"underlined\":\"true\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open URL\",\"color\":\"blue\"}]}}},{\"text\":\"" - * , colormode, url, colormode, url)); - */ - if (PluginMain.GetPlayers().size() > 0) { StringBuilder namesb = new StringBuilder(); namesb.append("(?i)("); diff --git a/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java b/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java index 2dc40f1..1cbb7b6 100644 --- a/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java +++ b/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java @@ -35,7 +35,6 @@ public final class ChatFormatter { * This method assumes that there is always a global formatter */ ArrayList sections = new ArrayList(); - List removecharpositions = new ArrayList(); for (ChatFormatter formatter : formatters) { Matcher matcher = formatter.regex.matcher(str); while (matcher.find()) { @@ -48,12 +47,6 @@ public final class ChatFormatter { DebugCommand.SendDebugMessage("First group: " + groups.get(0)); FormattedSection section = new FormattedSection(formatter, matcher.start(), matcher.end() - 1, groups); sections.add(section); - if (formatter.removecharcount != 0) { - removecharpositions.add(section.Start + formatter.removecharcount - 1); - removecharpositions.add(section.End - formatter.removecharcount - 1); - } - if (formatter.removecharpos != -1) - removecharpositions.add(section.Start + (int) formatter.removecharpos); } } sections.sort((s1, s2) -> { @@ -62,7 +55,6 @@ public final class ChatFormatter { else return Integer.compare(s1.Start, s2.Start); }); - removecharpositions.sort(null); boolean cont = true; boolean found = false; for (int i = 1; cont;) { @@ -83,7 +75,7 @@ public final class ChatFormatter { } FormattedSection section = new FormattedSection(sections.get(i - 1).Formatters, sections.get(i).Start, origend, sections.get(i - 1).Matches); - section.Formatters.addAll(sections.get(i).Formatters); + section.Formatters.addAll(sections.get(i).Formatters); // TODO: Process remove positions here section.Matches.addAll(sections.get(i).Matches); sections.add(i, section); nextindex++; @@ -133,7 +125,6 @@ public final class ChatFormatter { } } int nextremcharpospos = 0; - DebugCommand.SendDebugMessage("RemoveCharPositions size: " + removecharpositions.size()); for (int i = 0; i < sections.size(); i++) { FormattedSection section = sections.get(i); DebugCommand.SendDebugMessage("Applying section: " + section); @@ -147,7 +138,7 @@ public final class ChatFormatter { start++; nextremcharpospos++; if (removecharpositions.size() > nextremcharpospos) - nextremcharpos = removecharpositions.get(nextremcharpospos); //TODO: Section.RemoveCharCountStart/End + nextremcharpos = removecharpositions.get(nextremcharpospos); // TODO: Section.RemoveCharCountStart/End } if (nextremcharpos == section.End) { end--; diff --git a/src/main/java/buttondevteam/chat/formatting/FormattedSection.java b/src/main/java/buttondevteam/chat/formatting/FormattedSection.java index a7c4531..0ab55ba 100644 --- a/src/main/java/buttondevteam/chat/formatting/FormattedSection.java +++ b/src/main/java/buttondevteam/chat/formatting/FormattedSection.java @@ -26,7 +26,6 @@ class FormattedSection { @Override public String toString() { return new StringBuilder("Section(").append(Start).append(", ").append(End).append(", formatters: ") - .append(Formatters.toString()).append(", matches: ").append(Matches.toString()).append(")") - .toString(); + .append(Formatters.toString()).append(", matches: ").append(Matches.toString()).append(")").toString(); } } \ No newline at end of file