From 51fa2b3e64f021c3c0535f9f931d3fae27ca7adc Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 27 Apr 2019 18:34:58 +0100 Subject: Use text components instead of legacy formatting codes throughout the project --- .../java/me/lucko/spark/forge/ForgeSparkPlugin.java | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'spark-forge/src/main/java') diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkPlugin.java index 609894d..7298793 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkPlugin.java @@ -24,6 +24,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.SparkPlugin; import me.lucko.spark.common.sampler.ThreadDumper; +import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.serializer.ComponentSerializers; import net.minecraft.command.ICommand; @@ -70,23 +71,10 @@ public abstract class ForgeSparkPlugin implements SparkPlugin, I return this.mod.getConfigDirectory(); } - @SuppressWarnings("deprecation") @Override - public void sendMessage(ICommandSender sender, String message) { - TextComponent component = ComponentSerializers.LEGACY.deserialize(message, '&'); - ITextComponent mcComponent = ITextComponent.Serializer.jsonToComponent(ComponentSerializers.JSON.serialize(component)); - sender.sendMessage(mcComponent); - } - - @Override - public void sendLink(ICommandSender sender, String url) { - TextComponentString msg = new TextComponentString(url); - Style style = msg.getStyle(); - style.setColor(TextFormatting.GRAY); - style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)); - msg.setStyle(style); - - sender.sendMessage(msg); + public void sendMessage(ICommandSender sender, Component message) { + ITextComponent component = ITextComponent.Serializer.jsonToComponent(ComponentSerializers.JSON.serialize(message)); + sender.sendMessage(component); } @Override -- cgit