Clean up sending of formatted chat

This now fully uses MC's ChatComponentStyle for the general chat
styling, and cleans up some duplication
Dieser Commit ist enthalten in:
zml 2015-07-22 00:04:31 -07:00 committet von Kenzie Togami
Ursprung aa3a2d4764
Commit 3f171a95b7

Datei anzeigen

@ -37,6 +37,7 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S3FPacketCustomPayload; import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.util.EnumChatFormatting;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -130,23 +131,26 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { sendColorized(msg, EnumChatFormatting.GRAY);
this.player.addChatMessage(new ChatComponentText("\u00a77" + part));
}
} }
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { sendColorized(msg, EnumChatFormatting.LIGHT_PURPLE);
this.player.addChatMessage(new ChatComponentText("\u00a7d" + part));
}
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { sendColorized(msg, EnumChatFormatting.RED);
this.player.addChatMessage(new ChatComponentText("\u00a7c" + part));
} }
private void sendColorized(String msg, EnumChatFormatting formatting) {
for (String part : msg.split("\n")) {
ChatComponentText component = new ChatComponentText(part);
component.getChatStyle().setColor(formatting);
this.player.addChatMessage(component);
}
} }
@Override @Override