mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Clean up sending of formatted chat
This now fully uses MC's ChatComponentStyle for the general chat styling, and cleans up some duplication
This commit is contained in:
parent
aa3a2d4764
commit
3f171a95b7
@ -37,6 +37,7 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -130,23 +131,26 @@ public class ForgePlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
this.player.addChatMessage(new ChatComponentText("\u00a77" + part));
|
||||
}
|
||||
sendColorized(msg, EnumChatFormatting.GRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
this.player.addChatMessage(new ChatComponentText("\u00a7d" + part));
|
||||
}
|
||||
sendColorized(msg, EnumChatFormatting.LIGHT_PURPLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
sendColorized(msg, EnumChatFormatting.RED);
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, EnumChatFormatting formatting) {
|
||||
for (String part : msg.split("\n")) {
|
||||
this.player.addChatMessage(new ChatComponentText("\u00a7c" + part));
|
||||
ChatComponentText component = new ChatComponentText(part);
|
||||
component.getChatStyle().setColor(formatting);
|
||||
this.player.addChatMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,4 +220,4 @@ public class ForgePlayer extends AbstractPlayerActor {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user