2014-11-30 23:16:48 +01:00
|
|
|
From fc8066aa363f20a5c37f8789294943d7f56e16a1 Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02:00
|
|
|
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
|
|
|
Date: Sat, 18 Jan 2014 19:32:42 +0000
|
|
|
|
Subject: [PATCH] Support non-prefixed URLs
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
2014-11-29 01:06:26 +01:00
|
|
|
index 844bf6a..0481688 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
|
|
|
@@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableMap.Builder;
|
|
|
|
public final class CraftChatMessage {
|
|
|
|
private static class StringMessage {
|
|
|
|
private static final Map<Character, EnumChatFormat> formatMap;
|
|
|
|
- private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|(?:(https?://[^ ][^ ]*?)(?=[\\.\\?!,;:]?(?:[ \\n]|$)))", Pattern.CASE_INSENSITIVE);
|
|
|
|
+ private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|((?:(?:https?)://)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))", Pattern.CASE_INSENSITIVE);
|
|
|
|
|
|
|
|
static {
|
|
|
|
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -89,6 +89,9 @@ public final class CraftChatMessage {
|
|
|
|
}
|
2014-07-21 22:46:54 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
+ if ( !( match.startsWith( "http://" ) || match.startsWith( "https://" ) ) ) {
|
|
|
|
+ match = "http://" + match;
|
|
|
|
+ }
|
|
|
|
modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
|
|
|
|
appendNewComponent(matcher.end(groupId));
|
|
|
|
modifier.setChatClickable((ChatClickable) null);
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -100,7 +103,7 @@ public final class CraftChatMessage {
|
2014-07-21 22:46:54 +02:00
|
|
|
appendNewComponent(message.length());
|
|
|
|
}
|
|
|
|
|
|
|
|
- output = list.toArray(new IChatBaseComponent[0]);
|
|
|
|
+ output = list.toArray(new IChatBaseComponent[list.size()]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void appendNewComponent(int index) {
|
|
|
|
--
|
2014-11-28 02:17:45 +01:00
|
|
|
2.1.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|