Update chat link fix to use Bukkit's current system instead of the old one

This commit is contained in:
Thinkofdeath 2014-01-18 19:36:47 +00:00
parent c746557f95
commit 027e514ebf
22 changed files with 74 additions and 275 deletions

View file

@ -1,4 +1,4 @@
From 02ea30c4573133af4814749e42c3af57d7a35530 Mon Sep 17 00:00:00 2001 From e474b6f9b33af77e3a7f64b0b46d8837568c6c6e Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Fri, 20 Dec 2013 21:36:06 +0000 Date: Fri, 20 Dec 2013 21:36:06 +0000
Subject: [PATCH] Particle API Subject: [PATCH] Particle API
@ -117,5 +117,5 @@ index 468a4e1..c90dd54 100644
public Spigot spigot() public Spigot spigot()
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,138 +0,0 @@
From 710564f77ec4de65b7064579b76cfdcc3d49ec53 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Wed, 18 Dec 2013 20:39:24 +1100
Subject: [PATCH] Remove Bukkit URL Clicking
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index 66368f4..cc8e715 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -3,28 +3,23 @@ package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import net.minecraft.server.ChatClickable;
import net.minecraft.server.ChatComponentText;
import net.minecraft.server.ChatModifier;
import net.minecraft.server.EnumChatFormat;
-import net.minecraft.server.EnumClickAction;
import net.minecraft.server.IChatBaseComponent;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
public final class CraftChatMessage {
- private static class StringMessage {
+ private static class FromString {
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);
static {
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
for (EnumChatFormat format : EnumChatFormat.values()) {
- builder.put(Character.toLowerCase(format.getChar()), format);
+ builder.put(format.getChar(), format);
}
formatMap = builder.build();
}
@@ -32,29 +27,25 @@ public final class CraftChatMessage {
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
private IChatBaseComponent currentChatComponent = new ChatComponentText("");
private ChatModifier modifier = new ChatModifier();
+ private StringBuilder builder = new StringBuilder();
private final IChatBaseComponent[] output;
- private int currentIndex;
- private final String message;
- private StringMessage(String message) {
- this.message = message;
+ private FromString(String message) {
if (message == null) {
output = new IChatBaseComponent[] { currentChatComponent };
return;
}
list.add(currentChatComponent);
- Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
- String match = null;
- while (matcher.find()) {
- int groupId = 0;
- while ((match = matcher.group(++groupId)) == null) {
- // NOOP
- }
- appendNewComponent(matcher.start(groupId));
- switch (groupId) {
- case 1:
- EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
+ EnumChatFormat format = null;
+
+ for (int i = 0; i < message.length(); i++) {
+ char currentChar = message.charAt(i);
+ if (currentChar == '\u00A7' && (i < (message.length() - 1)) && (format = formatMap.get(message.charAt(i + 1))) != null) {
+ if (builder.length() > 0) {
+ appendNewComponent();
+ }
+
if (format == EnumChatFormat.RESET) {
modifier = new ChatModifier();
} else if (format.isFormat()) {
@@ -80,31 +71,27 @@ public final class CraftChatMessage {
} else { // Color resets formatting
modifier = new ChatModifier().setColor(format);
}
- break;
- case 2:
+ i++;
+ } else if (currentChar == '\n') {
+ if (builder.length() > 0) {
+ appendNewComponent();
+ }
currentChatComponent = null;
- break;
- case 3:
- modifier.a(new ChatClickable(EnumClickAction.OPEN_URL, match)); // Should be setChatClickable
- appendNewComponent(matcher.end(groupId));
- modifier.a((ChatClickable) null);
+ } else {
+ builder.append(currentChar);
}
- currentIndex = matcher.end(groupId);
}
- if (currentIndex < message.length()) {
- appendNewComponent(message.length());
+ if (builder.length() > 0) {
+ appendNewComponent();
}
output = list.toArray(new IChatBaseComponent[0]);
}
- private void appendNewComponent(int index) {
- if (index <= currentIndex) {
- return;
- }
- IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setChatModifier(modifier);
- currentIndex = index;
+ private void appendNewComponent() {
+ IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
+ builder = new StringBuilder();
modifier = modifier.clone();
if (currentChatComponent == null) {
currentChatComponent = new ChatComponentText("");
@@ -119,7 +106,7 @@ public final class CraftChatMessage {
}
public static IChatBaseComponent[] fromString(String message) {
- return new StringMessage(message).getOutput();
+ return new FromString(message).getOutput();
}
private CraftChatMessage() {
--
1.8.3.2

View file

@ -1,4 +1,4 @@
From eed402ce73fec9890879e3ed03ec3ba4e4a2c9e6 Mon Sep 17 00:00:00 2001 From dfeec72862e67c4fb08e1f11962717cc99e81e5a Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Sun, 5 Jan 2014 09:35:01 +1100 Date: Sun, 5 Jan 2014 09:35:01 +1100
Subject: [PATCH] Fix Biome Decoration Crashes Subject: [PATCH] Fix Biome Decoration Crashes
@ -107,5 +107,5 @@ index b048d6c..962d719 100644
+ // Spigot End + // Spigot End
} }
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,104 +0,0 @@
From 5ad9b20df6175c93ea54bd2961d30ab256b25235 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <purggames@gmail.com>
Date: Sun, 1 Dec 2013 10:33:55 +0000
Subject: [PATCH] Fix links in chat
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index cc8e715..5607df1 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -3,11 +3,15 @@ package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import net.minecraft.server.ChatComponentText;
import net.minecraft.server.ChatModifier;
import net.minecraft.server.EnumChatFormat;
import net.minecraft.server.IChatBaseComponent;
+import net.minecraft.server.ChatClickable;
+import net.minecraft.server.EnumClickAction;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
@@ -29,6 +33,8 @@ public final class CraftChatMessage {
private ChatModifier modifier = new ChatModifier();
private StringBuilder builder = new StringBuilder();
private final IChatBaseComponent[] output;
+ private static final Pattern url = Pattern.compile("^(\u00A7.)*?((?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,4})(/\\S*?)?)(\u00A7.)*?$");
+ private int lastWord = 0;
private FromString(String message) {
if (message == null) {
@@ -38,10 +44,14 @@ public final class CraftChatMessage {
list.add(currentChatComponent);
EnumChatFormat format = null;
+ Matcher matcher = url.matcher(message);
+ lastWord = 0;
for (int i = 0; i < message.length(); i++) {
char currentChar = message.charAt(i);
if (currentChar == '\u00A7' && (i < (message.length() - 1)) && (format = formatMap.get(message.charAt(i + 1))) != null) {
+ checkUrl(matcher, message, i);
+ lastWord++;
if (builder.length() > 0) {
appendNewComponent();
}
@@ -73,11 +83,18 @@ public final class CraftChatMessage {
}
i++;
} else if (currentChar == '\n') {
+ checkUrl(matcher, message, i);
+ lastWord = i + 1;
if (builder.length() > 0) {
appendNewComponent();
}
currentChatComponent = null;
} else {
+ if (currentChar == ' ' || i == message.length() - 1) {
+ if (checkUrl(matcher, message, i)) {
+ break;
+ }
+ }
builder.append(currentChar);
}
}
@@ -89,6 +106,31 @@ public final class CraftChatMessage {
output = list.toArray(new IChatBaseComponent[0]);
}
+ private boolean checkUrl(Matcher matcher, String message, int i) {
+ Matcher urlMatcher = matcher.region(lastWord, i == message.length() - 1 ? message.length() : i);
+ lastWord = i + 1;
+ if (urlMatcher.find()) {
+ String fullUrl = urlMatcher.group(2);
+ String protocol = urlMatcher.group(3);
+ String url = urlMatcher.group(4);
+ String path = urlMatcher.group(5);
+ builder.delete(builder.length() - fullUrl.length() + (i == message.length() - 1 ? 1 : 0), builder.length());
+ if (builder.length() > 0) {
+ appendNewComponent();
+ }
+ builder.append(fullUrl);
+ ChatClickable link = new ChatClickable(EnumClickAction.OPEN_URL,
+ (protocol!=null?protocol:"http") + "://" + url + (path!=null?path:""));
+ modifier.a(link);
+ appendNewComponent();
+ modifier.a((ChatClickable) null);
+ if (i == message.length() - 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void appendNewComponent() {
IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
builder = new StringBuilder();
--
1.8.3.2

View file

@ -1,4 +1,4 @@
From d14e8feb5dac1d571188f31735eb6c15d06d93d0 Mon Sep 17 00:00:00 2001 From 59270de3d66b10b895713ea1a4c8abcf59584716 Mon Sep 17 00:00:00 2001
From: DerFlash <bte@freenet.de> From: DerFlash <bte@freenet.de>
Date: Tue, 9 Jul 2013 00:11:12 +0200 Date: Tue, 9 Jul 2013 00:11:12 +0200
Subject: [PATCH] Save ticks lived to nbttag Subject: [PATCH] Save ticks lived to nbttag
@ -26,5 +26,5 @@ index 9ef9f88..84bac83 100644
if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
EntityInsentient entityinsentient = (EntityInsentient) entity; EntityInsentient entityinsentient = (EntityInsentient) entity;
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From fbf76761d5c951b22f128a1555dcd7d0eece12a7 Mon Sep 17 00:00:00 2001 From 0fb2802696244681df560cb73a9ff464a47914a6 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 12:17:37 +1000 Date: Tue, 11 Jun 2013 12:17:37 +1000
Subject: [PATCH] More Efficient GetCubes Subject: [PATCH] More Efficient GetCubes
@ -64,5 +64,5 @@ index 1aca7f6..04f5ed1 100644
double d0 = 0.25D; double d0 = 0.25D;
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0)); List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From 913fd442d20a4b592f6d25ce3efc7991d1559ee6 Mon Sep 17 00:00:00 2001 From b74e50dac0676245ae0584e91329e07331b7b1e8 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Sun, 22 Dec 2013 20:58:02 +1100 Date: Sun, 22 Dec 2013 20:58:02 +1100
Subject: [PATCH] Add Option to Nerf Mobs from Spawner's Subject: [PATCH] Add Option to Nerf Mobs from Spawner's
@ -67,5 +67,5 @@ index e7cb99d..50d3069 100644
+ } + }
} }
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From c1ec14127cc9b7047ec70ff080c817a0a408d7f3 Mon Sep 17 00:00:00 2001 From 9c7daa9543db10418630043186271c9a49535127 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Mon, 23 Dec 2013 14:07:41 +1100 Date: Mon, 23 Dec 2013 14:07:41 +1100
Subject: [PATCH] Warn if PermGen may be insufficient Subject: [PATCH] Warn if PermGen may be insufficient

View file

@ -1,11 +1,11 @@
From 05a7acf595798c58789556ac73a9f663993aef21 Mon Sep 17 00:00:00 2001 From 3a9abdf9814017446d83a3267a6f70ae4163e7c7 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Mon, 23 Dec 2013 15:57:57 +1100 Date: Mon, 23 Dec 2013 15:57:57 +1100
Subject: [PATCH] Disable Connected Check on setScoreboard Subject: [PATCH] Disable Connected Check on setScoreboard
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index c9454b5..1f29821 100644 index 3c8b9b9..331ff29 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1068,7 +1068,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1068,7 +1068,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -18,5 +18,5 @@ index c9454b5..1f29821 100644
this.server.getScoreboardManager().setPlayerBoard(this, scoreboard); this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From aaf097a40971ba23a677172d27fcba85531387b3 Mon Sep 17 00:00:00 2001 From 4f0db695940594818b0c7be8f3f91422fe28a332 Mon Sep 17 00:00:00 2001
From: slide23 <me@slide.ws> From: slide23 <me@slide.ws>
Date: Fri, 20 Dec 2013 20:15:33 -0600 Date: Fri, 20 Dec 2013 20:15:33 -0600
Subject: [PATCH] Add Late Bind Option Subject: [PATCH] Add Late Bind Option
@ -56,7 +56,7 @@ index c9bb3a6..8ec6474
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
old mode 100644 old mode 100644
new mode 100755 new mode 100755
index 1befcb9..b25395f index b3f2647..4811778
--- a/src/main/java/org/spigotmc/SpigotConfig.java --- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -219,4 +219,9 @@ public class SpigotConfig @@ -219,4 +219,9 @@ public class SpigotConfig

View file

@ -1,4 +1,4 @@
From b8eba900197cdc6e9c71feff78e051292b3de6e5 Mon Sep 17 00:00:00 2001 From 9eadce08d9f2cf5315756d94f0a1d9fdfbeeb9d3 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Fri, 3 Jan 2014 17:30:52 +0000 Date: Fri, 3 Jan 2014 17:30:52 +0000
Subject: [PATCH] Disconnect for spam in the main thread Subject: [PATCH] Disconnect for spam in the main thread

View file

@ -1,4 +1,4 @@
From 9b82bd9730c7b87940423c5a48724b05c841900c Mon Sep 17 00:00:00 2001 From ec7cba889f9934f5b1cc49c241dfd86a4ee0c797 Mon Sep 17 00:00:00 2001
From: bloodshot <jdroque@gmail.com> From: bloodshot <jdroque@gmail.com>
Date: Mon, 6 Jan 2014 16:29:51 -0500 Date: Mon, 6 Jan 2014 16:29:51 -0500
Subject: [PATCH] Update Chest Animation when Cancelling Event Subject: [PATCH] Update Chest Animation when Cancelling Event
@ -113,5 +113,5 @@ index ab39926..550ef44 100644
if (this.activeContainer != this.defaultContainer) { if (this.activeContainer != this.defaultContainer) {
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From f9172bc5ec67e5f0a52b1e635ca2f646980e55b3 Mon Sep 17 00:00:00 2001 From b67eeecbc4d4eca02e6350e558e3bb10caf0e3c0 Mon Sep 17 00:00:00 2001
From: bloodshot <jdroque@gmail.com> From: bloodshot <jdroque@gmail.com>
Date: Mon, 6 Jan 2014 18:02:01 -0500 Date: Mon, 6 Jan 2014 18:02:01 -0500
Subject: [PATCH] Update Client's Hand when BlockPlaceEvent Cancelled Subject: [PATCH] Update Client's Hand when BlockPlaceEvent Cancelled
@ -31,5 +31,5 @@ index f7fdca3..91de23b 100644
flag = true; flag = true;
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From 952dec3d35c4cba71cf919e45f5204397b551b15 Mon Sep 17 00:00:00 2001 From 4c5d07c4c8f28bbd42b3bf4445d8e7d4c6bd769b Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Tue, 7 Jan 2014 15:56:26 +0000 Date: Tue, 7 Jan 2014 15:56:26 +0000
Subject: [PATCH] Allow statistics to be disabled/forced Subject: [PATCH] Allow statistics to be disabled/forced
@ -40,7 +40,7 @@ index 2f980cb..3f78728 100644
super.a(entityhuman, statistic, i); super.a(entityhuman, statistic, i);
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index b25395f..7f59b8f 100755 index 4811778..8e53b55 100755
--- a/src/main/java/org/spigotmc/SpigotConfig.java --- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -11,11 +11,14 @@ import java.util.HashMap; @@ -11,11 +11,14 @@ import java.util.HashMap;

View file

@ -1,4 +1,4 @@
From 817267c19278a9c34c33b852009eb1d70058bb5c Mon Sep 17 00:00:00 2001 From b995049e7e282c0e217cc4db1043a947a87d89ce Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Thu, 9 Jan 2014 14:19:12 +0000 Date: Thu, 9 Jan 2014 14:19:12 +0000
Subject: [PATCH] Fix anvil collisions Subject: [PATCH] Fix anvil collisions

View file

@ -1,4 +1,4 @@
From 0c83bc061d6d630018bf7da6c061d903d0187cec Mon Sep 17 00:00:00 2001 From 049ab256099deffea5f89022629ababe8dcfcfa5 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Fri, 10 Jan 2014 15:15:50 +1100 Date: Fri, 10 Jan 2014 15:15:50 +1100
Subject: [PATCH] Fix ItemStack Unbreakable Code Subject: [PATCH] Fix ItemStack Unbreakable Code
@ -24,5 +24,5 @@ index f32322e..37ceade 100644
public boolean usesData() { public boolean usesData() {
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From 7a826c1e1d2348619e6cfd466c40c199ee4886a0 Mon Sep 17 00:00:00 2001 From 0373bc1b64bf816402795a7b14f73805a2084c99 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Sun, 12 Jan 2014 20:56:41 +1100 Date: Sun, 12 Jan 2014 20:56:41 +1100
Subject: [PATCH] Try and Debug Crash Reports Crashing Subject: [PATCH] Try and Debug Crash Reports Crashing
@ -37,5 +37,5 @@ index 868061b..c58c73e 100644
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From c358cbf157659bd9e47dd01e3540e22bbd3127ae Mon Sep 17 00:00:00 2001 From e4ad495ac44e88b0cabbe3d51098af3f5e125ba7 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Sun, 12 Jan 2014 21:07:18 +1100 Date: Sun, 12 Jan 2014 21:07:18 +1100
Subject: [PATCH] Replace AutoSave Mechanism Subject: [PATCH] Replace AutoSave Mechanism
@ -28,5 +28,5 @@ index c58c73e..c158e8a 100644
} }
-- --
1.8.3.2 1.8.4.msysgit.0

View file

@ -1,4 +1,4 @@
From c40d8531dbe4217d3457e3c3c598da3b052fabd1 Mon Sep 17 00:00:00 2001 From 056226c0ebd85eceb6bc83d35f12220d118bc4dc Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Tue, 14 Jan 2014 20:11:25 +0000 Date: Tue, 14 Jan 2014 20:11:25 +0000
Subject: [PATCH] Fix ConcurrentModificationException while being idle kicked Subject: [PATCH] Fix ConcurrentModificationException while being idle kicked

View file

@ -1,4 +1,4 @@
From e6ed2f4e16c26134c5b177a3f37df5fa0c7c711b Mon Sep 17 00:00:00 2001 From 438be204a29764ce1bdda2c94bed5298ad71ec3d Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Wed, 15 Jan 2014 21:52:47 +0000 Date: Wed, 15 Jan 2014 21:52:47 +0000
Subject: [PATCH] Block data values that crash the client Subject: [PATCH] Block data values that crash the client

View file

@ -1,4 +1,4 @@
From b8644fa6ff4062eace6b9ccf9c779464e0f5b1e3 Mon Sep 17 00:00:00 2001 From 583b55f00d1755910fe5fa0c0b21bbcd0bf5e521 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com> From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Sat, 18 Jan 2014 14:27:03 +0000 Date: Sat, 18 Jan 2014 14:27:03 +0000
Subject: [PATCH] Support vanilla's direction tag on fireballs Subject: [PATCH] Support vanilla's direction tag on fireballs

View file

@ -0,0 +1,41 @@
From bf22233f1d884d0899b6e971661ebe541bcc94b4 Mon Sep 17 00:00:00 2001
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
index 66368f4..f4de71c 100644
--- 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}.*?(?=[\\.\\?!,;:]?(?:[ \\n]|$))))", Pattern.CASE_INSENSITIVE);
static {
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
@@ -85,6 +85,9 @@ public final class CraftChatMessage {
currentChatComponent = null;
break;
case 3:
+ if ( !( match.startsWith( "http://" ) || match.startsWith( "https://" ) ) ) {
+ match = "http://" + match;
+ }
modifier.a(new ChatClickable(EnumClickAction.OPEN_URL, match)); // Should be setChatClickable
appendNewComponent(matcher.end(groupId));
modifier.a((ChatClickable) null);
@@ -96,7 +99,7 @@ public final class CraftChatMessage {
appendNewComponent(message.length());
}
- output = list.toArray(new IChatBaseComponent[0]);
+ output = list.toArray(new IChatBaseComponent[list.size()]);
}
private void appendNewComponent(int index) {
--
1.8.4.msysgit.0