From 205e2d212e7538c691a4c00903e10ac814284d8f Mon Sep 17 00:00:00 2001 From: Wyatt Childers Date: Mon, 4 Apr 2016 23:34:20 -0400 Subject: [PATCH] Cleaned up the Sponge Command Sender chat implementation --- .../worldedit/sponge/SpongeCommandSender.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java index f9986101f..a2a3fa138 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java @@ -26,7 +26,9 @@ import com.sk89q.worldedit.util.auth.AuthorizationException; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; +import org.spongepowered.api.text.format.TextColor; import org.spongepowered.api.text.format.TextColors; +import org.spongepowered.api.text.serializer.TextSerializers; import javax.annotation.Nullable; import java.io.File; @@ -67,28 +69,28 @@ public class SpongeCommandSender implements Actor { @Override public void printRaw(String msg) { for (String part : msg.split("\n")) { - sender.sendMessage(Text.of(part)); + sender.sendMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part)); } } @Override public void print(String msg) { - for (String part : msg.split("\n")) { - sender.sendMessage(Text.of(TextColors.LIGHT_PURPLE, part)); - } + sendColorized(msg, TextColors.LIGHT_PURPLE); } @Override public void printDebug(String msg) { - for (String part : msg.split("\n")) { - sender.sendMessage(Text.of(TextColors.GRAY, part)); - } + sendColorized(msg, TextColors.GRAY); } @Override public void printError(String msg) { + sendColorized(msg, TextColors.RED); + } + + private void sendColorized(String msg, TextColor formatting) { for (String part : msg.split("\n")) { - sender.sendMessage(Text.of(TextColors.RED, part)); + sender.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part))); } }