SPIGOT-199: Default to white instead of black for chat messages

This commit is contained in:
Thinkofdeath 2014-12-13 09:36:35 +00:00
parent e8efbb8a87
commit 5f2a9eadde
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde/net/minecraft/server/PlayerList.java 2014-12-12 21:45:59.845822542 +0000 --- ../work/decompile-8eb82bde/net/minecraft/server/PlayerList.java 2014-12-13 09:37:43.506950406 +0000
+++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-12 21:44:44.381823361 +0000 +++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-13 09:35:13.993746030 +0000
@@ -18,6 +18,26 @@ @@ -18,6 +18,26 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -820,7 +820,7 @@
- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, (byte) i)); - this.sendAll(new PacketPlayOutChat(ichatbasecomponent, (byte) i));
+ // CraftBukkit start - we run this through our processor first so we can get web links etc + // CraftBukkit start - we run this through our processor first so we can get web links etc
+ // PAIL: Rename + // PAIL: Rename
+ for (IChatBaseComponent component : CraftChatMessage.fromString(CraftChatMessage.fromComponent(ichatbasecomponent))) { + for (IChatBaseComponent component : CraftChatMessage.fromString(CraftChatMessage.fromComponent(ichatbasecomponent, EnumChatFormat.WHITE))) {
+ this.sendAll(new PacketPlayOutChat(component, (byte) i)); + this.sendAll(new PacketPlayOutChat(component, (byte) i));
+ } + }
+ // CraftBukkit end + // CraftBukkit end

View File

@ -131,12 +131,16 @@ public final class CraftChatMessage {
} }
public static String fromComponent(IChatBaseComponent component) { public static String fromComponent(IChatBaseComponent component) {
return fromComponent(component, EnumChatFormat.BLACK);
}
public static String fromComponent(IChatBaseComponent component, EnumChatFormat defaultColor) {
if (component == null) return ""; if (component == null) return "";
StringBuilder out = new StringBuilder(); StringBuilder out = new StringBuilder();
for (IChatBaseComponent c : (Iterable<IChatBaseComponent>) component) { for (IChatBaseComponent c : (Iterable<IChatBaseComponent>) component) {
ChatModifier modi = c.getChatModifier(); ChatModifier modi = c.getChatModifier();
out.append(modi.getColor() == null ? EnumChatFormat.BLACK : modi.getColor()); out.append(modi.getColor() == null ? defaultColor : modi.getColor());
if (modi.isBold()) { if (modi.isBold()) {
out.append(EnumChatFormat.BOLD); out.append(EnumChatFormat.BOLD);
} }
@ -154,7 +158,7 @@ public final class CraftChatMessage {
} }
out.append(c.getText()); out.append(c.getText());
} }
return out.toString().replaceFirst("^(§0)*", ""); return out.toString().replaceFirst("^(" + defaultColor + ")*", "");
} }
private CraftChatMessage() { private CraftChatMessage() {