Skip to content

Commit

Permalink
fix and improve say command
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Oct 19, 2023
1 parent a080813 commit fbfc857
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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 <phrase> 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!");
Expand Down

0 comments on commit fbfc857

Please sign in to comment.