summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormbax <matt@phozop.net>2013-12-01 11:09:47 -0500
committermbax <matt@phozop.net>2013-12-01 15:24:15 -0500
commit46c11eb83fec168d21111a3030f100764cd862e3 (patch)
tree9b5c860cb9c4036cef8f24f53f6c46c025ac7164 /src/main/java/org
parent72b36b8b07c3eb7532ba0fefa499c714997f9265 (diff)
downloadcraftbukkit-46c11eb83fec168d21111a3030f100764cd862e3.tar
craftbukkit-46c11eb83fec168d21111a3030f100764cd862e3.tar.gz
craftbukkit-46c11eb83fec168d21111a3030f100764cd862e3.tar.lz
craftbukkit-46c11eb83fec168d21111a3030f100764cd862e3.tar.xz
craftbukkit-46c11eb83fec168d21111a3030f100764cd862e3.zip
Handle ChatColor-ending messages FIXES BUKKIT-4924
Now adds the component upon creation, eliminating issues where the created component was discarded.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index 2e163f2f..cc8e7150 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -32,9 +32,10 @@ public final class CraftChatMessage {
private FromString(String message) {
if (message == null) {
- output = new IChatBaseComponent[] { new ChatComponentText("") };
+ output = new IChatBaseComponent[] { currentChatComponent };
return;
}
+ list.add(currentChatComponent);
EnumChatFormat format = null;
@@ -73,19 +74,16 @@ public final class CraftChatMessage {
i++;
} else if (currentChar == '\n') {
if (builder.length() > 0) {
- finishComponent();
+ appendNewComponent();
}
+ currentChatComponent = null;
} else {
builder.append(currentChar);
}
}
if (builder.length() > 0) {
- finishComponent();
- }
-
- if (list.isEmpty()) {
- list.add(new ChatComponentText(""));
+ appendNewComponent();
}
output = list.toArray(new IChatBaseComponent[0]);
@@ -95,13 +93,11 @@ public final class CraftChatMessage {
IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
builder = new StringBuilder();
modifier = modifier.clone();
- currentChatComponent = currentChatComponent.a(addition);
- }
-
- private void finishComponent() {
- appendNewComponent();
- list.add(currentChatComponent);
- currentChatComponent = new ChatComponentText("");
+ if (currentChatComponent == null) {
+ currentChatComponent = new ChatComponentText("");
+ list.add(currentChatComponent);
+ }
+ currentChatComponent.a(addition);
}
private IChatBaseComponent[] getOutput() {