mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +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.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) {
|
||||||
|
sendColorized(msg, EnumChatFormatting.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendColorized(String msg, EnumChatFormatting formatting) {
|
||||||
for (String part : msg.split("\n")) {
|
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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user