From 338b8792a9522e123f1ebd50c24c0276e7b20c5c Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 16 Aug 2020 01:47:14 -0400 Subject: [PATCH] Remove useless URL detection and event addition from 1.13->1.12.2 ChatRewriter --- .../protocol1_13to1_12_2/ChatRewriter.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java index 206d24785..e858d5cf0 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java @@ -16,7 +16,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class ChatRewriter { - private static final Pattern URL = Pattern.compile("^(?:(https?)://)?([-\\w_.]{2,}\\.[a-z]{2,4})(/\\S*)?$"); private static final BaseComponent[] EMPTY_COMPONENTS = new BaseComponent[0]; private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter1_13(); @@ -25,7 +24,6 @@ public class ChatRewriter { List components = new ArrayList<>(); StringBuilder builder = new StringBuilder(); TextComponent component = new TextComponent(); - Matcher matcher = URL.matcher(message); for (int i = 0; i < message.length(); i++) { char c = message.charAt(i); @@ -83,31 +81,6 @@ public class ChatRewriter { } continue; } - int pos = message.indexOf(' ', i); - if (pos == -1) { - pos = message.length(); - } - if (matcher.region(i, pos).find()) { //Web link handling - - if (builder.length() > 0) { - TextComponent old = component; - component = new TextComponent(old); - old.setText(builder.toString()); - builder = new StringBuilder(); - components.add(old); - } - - TextComponent old = component; - component = new TextComponent(old); - String urlString = message.substring(i, pos); - component.setText(urlString); - component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, - urlString.startsWith("http") ? urlString : "http://" + urlString)); - components.add(component); - i += pos - i - 1; - component = old; - continue; - } builder.append(c); }