From fbfc85726b870c51aed0f20ede461c8aeb0afbb4 Mon Sep 17 00:00:00 2001 From: xGinko Date: Thu, 19 Oct 2023 13:12:57 +0200 Subject: [PATCH] fix and improve say command --- .../me/moomoo/anarchyexploitfixes/commands/SayCommand.java | 3 ++- .../me/moomoo/anarchyexploitfixes/commands/SayCommand.java | 5 ++++- .../java/me/moomoo/anarchyexploitfixes/config/Config.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java index dc534a35a..c115578c3 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java @@ -6,6 +6,7 @@ import cloud.commandframework.annotations.CommandPermission; import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; import net.kyori.adventure.text.TextReplacementConfig; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.command.CommandSender; public class SayCommand implements AnarchyExploitFixesCommand { @@ -22,7 +23,7 @@ public void onSay( final @Argument(value = "message", description = "message you want to broadcast") String message ) { AnarchyExploitFixes.getInstance().getServer().broadcast(AnarchyExploitFixes.getConfiguration().cmd_say_format - .replaceText(TextReplacementConfig.builder().matchLiteral("%message%").replacement(message).build()) + .replaceText(TextReplacementConfig.builder().matchLiteral("%message%").replacement(MiniMessage.miniMessage().deserialize(message)).build()) ); } } \ No newline at end of file diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java index c8925b1a1..a61b1f3e4 100644 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/commands/SayCommand.java @@ -5,6 +5,7 @@ import cloud.commandframework.annotations.CommandMethod; import cloud.commandframework.annotations.CommandPermission; import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; public class SayCommand implements AnarchyExploitFixesCommand { @@ -21,6 +22,8 @@ public void onSay( final @Argument(value = "message", description = "message you want to broadcast") String message ) { AnarchyExploitFixes.getInstance().getServer() - .broadcastMessage(AnarchyExploitFixes.getConfiguration().cmd_say_format.replace("%message%", message)); + .broadcastMessage(AnarchyExploitFixes.getConfiguration().cmd_say_format + .replace("%message%", ChatColor.translateAlternateColorCodes('&', message)) + ); } } \ No newline at end of file diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/config/Config.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/config/Config.java index 556740d76..36e2bf907 100644 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/config/Config.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/config/Config.java @@ -3,6 +3,7 @@ import io.github.thatsmusic99.configurationmaster.api.ConfigFile; import io.github.thatsmusic99.configurationmaster.api.ConfigSection; import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; +import org.bukkit.ChatColor; import java.io.File; import java.util.*; @@ -31,7 +32,7 @@ public Config() throws Exception { this.overworld_floor_min_y = getInt("general.overworld-floor-y", AnarchyExploitFixes.getMCVersion() > 17 ? -64 : 0, "The Y-level at which the overworld floor generates the last layer of bedrock on your server."); this.cmd_kickphrase_enabled = getBoolean("misc.enable-kickphrase-command", false, "Enable the /aef kickphrase command."); this.cmd_say_enabled = getBoolean("general.commands.say.enable", false); - this.cmd_say_format = getString("general.commands.say.format", "&7Server: &6%message%"); + this.cmd_say_format = ChatColor.translateAlternateColorCodes('&', getString("general.commands.say.format", "&7Server: &6%message%")); this.cmd_help_enabled = getBoolean("general.commands.help.enable", false, "Help command that shows a small command overview for players."); this.cmd_toggleConMsgs_enabled = getBoolean("general.commands.toggleconnectionmsgs.enable", true, "If you don't use join leave/messages, you can set this to false."); config.addComment("general.commands", "A server restart is required when changing a command's enable status!");