From fcd2a513aa6e035c37f4381c523c538d5879eed5 Mon Sep 17 00:00:00 2001 From: Shiewk Date: Fri, 3 Apr 2026 15:53:07 +0200 Subject: [PATCH] Remove the chat prefix --- .../smoderation/paper/SModerationPaper.java | 12 +++----- .../smoderation/paper/input/ChatInput.java | 4 +-- .../paper/listener/PunishmentListener.java | 10 +++---- .../paper/listener/VanishListener.java | 2 +- .../paper/punishments/Punishment.java | 6 ++-- .../smoderation/translations/en_us.json | 28 +++++++++---------- 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/main/java/de/shiewk/smoderation/paper/SModerationPaper.java b/src/main/java/de/shiewk/smoderation/paper/SModerationPaper.java index bf9d470..581d5d5 100644 --- a/src/main/java/de/shiewk/smoderation/paper/SModerationPaper.java +++ b/src/main/java/de/shiewk/smoderation/paper/SModerationPaper.java @@ -11,7 +11,6 @@ import de.shiewk.smoderation.paper.util.SchedulerUtil; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import net.kyori.adventure.key.Key; -import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.logger.slf4j.ComponentLogger; @@ -35,11 +34,14 @@ import java.util.Objects; import static de.shiewk.smoderation.paper.command.VanishCommand.isVanished; import static de.shiewk.smoderation.paper.command.VanishCommand.toggleVanish; -import static net.kyori.adventure.text.Component.text; import static org.bukkit.Bukkit.getPluginManager; public final class SModerationPaper extends JavaPlugin { + public static final TextColor PRIMARY_COLOR = TextColor.color(212, 0, 255); + public static final TextColor SECONDARY_COLOR = TextColor.color(52, 143, 255); + public static final TextColor INACTIVE_COLOR = NamedTextColor.GRAY; + public static final Gson gson = new Gson(); public static final PunishmentContainer container = new PunishmentContainer(); public static ComponentLogger LOGGER = null; @@ -47,11 +49,6 @@ public final class SModerationPaper extends JavaPlugin { public static File SAVE_FILE = null; private static SkinTextureProvider textureProvider = null; - public static final TextColor PRIMARY_COLOR = TextColor.color(212, 0, 255); - public static final TextColor SECONDARY_COLOR = TextColor.color(52, 143, 255); - public static final TextColor INACTIVE_COLOR = NamedTextColor.GRAY; - public static final TextComponent CHAT_PREFIX = text("SM \u00BB ").color(PRIMARY_COLOR); - private final TranslatorManager translatorManager = new TranslatorManager( Key.key("smoderation", "translations"), createMiniMessage(), @@ -161,7 +158,6 @@ public final class SModerationPaper extends JavaPlugin { private MiniMessage createMiniMessage() { return MiniMessage.builder() .tags(TagResolver.builder() - .resolver(TagResolver.resolver("prefix", Tag.inserting(CHAT_PREFIX))) .resolver(TagResolver.resolver("primary", Tag.styling(style -> style.color(PRIMARY_COLOR)))) .resolver(TagResolver.resolver("secondary", Tag.styling(style -> style.color(SECONDARY_COLOR)))) .resolver(TagResolver.standard()) diff --git a/src/main/java/de/shiewk/smoderation/paper/input/ChatInput.java b/src/main/java/de/shiewk/smoderation/paper/input/ChatInput.java index e9b8ef9..e172cdb 100644 --- a/src/main/java/de/shiewk/smoderation/paper/input/ChatInput.java +++ b/src/main/java/de/shiewk/smoderation/paper/input/ChatInput.java @@ -10,7 +10,7 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; -import static de.shiewk.smoderation.paper.SModerationPaper.CHAT_PREFIX; +import static de.shiewk.smoderation.paper.SModerationPaper.PRIMARY_COLOR; import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; @@ -53,7 +53,7 @@ public class ChatInput { public static void prompt(Player player, Consumer consumer, Component prompt, int timeSeconds){ runningInputs.put(player, new ChatInput(player, prompt, consumer, timeSeconds)); - player.sendMessage(CHAT_PREFIX.append(prompt)); + player.sendMessage(prompt.colorIfAbsent(PRIMARY_COLOR)); } public Component getPrompt() { diff --git a/src/main/java/de/shiewk/smoderation/paper/listener/PunishmentListener.java b/src/main/java/de/shiewk/smoderation/paper/listener/PunishmentListener.java index 9842b30..7768f5d 100644 --- a/src/main/java/de/shiewk/smoderation/paper/listener/PunishmentListener.java +++ b/src/main/java/de/shiewk/smoderation/paper/listener/PunishmentListener.java @@ -18,7 +18,7 @@ import org.bukkit.event.world.WorldSaveEvent; import java.util.List; -import static de.shiewk.smoderation.paper.SModerationPaper.CHAT_PREFIX; +import static de.shiewk.smoderation.paper.SModerationPaper.PRIMARY_COLOR; import static net.kyori.adventure.text.Component.translatable; public class PunishmentListener implements Listener { @@ -33,7 +33,7 @@ public class PunishmentListener implements Listener { && p.to.equals(event.getUniqueId()) && p.isActive()); if (punishment != null){ - event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, CHAT_PREFIX.append(punishment.playerMessage())); + event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, punishment.playerMessage().colorIfAbsent(PRIMARY_COLOR)); } } @@ -46,7 +46,7 @@ public class PunishmentListener implements Listener { && p.isActive()); if (punishment != null) { event.setCancelled(true); - player.sendMessage(CHAT_PREFIX.append(punishment.playerMessage())); + player.sendMessage(punishment.playerMessage().colorIfAbsent(PRIMARY_COLOR)); } } @@ -66,7 +66,7 @@ public class PunishmentListener implements Listener { || message.toLowerCase().startsWith(str.toLowerCase()+" ") )){ Bukkit.getConsoleSender().sendMessage(player.getName() + " tried to run forbidden command while muted"); - player.sendMessage(CHAT_PREFIX.append(translatable("smod.punishment.playerMessage.mute.chat"))); + player.sendMessage(translatable("smod.punishment.playerMessage.mute.chat", PRIMARY_COLOR)); event.setCancelled(true); } } @@ -86,7 +86,7 @@ public class PunishmentListener implements Listener { case KICK, BAN -> { final Player player = Bukkit.getPlayer(punishment.to); if (player != null) { - player.kick(CustomInventory.renderComponent(player, CHAT_PREFIX.append(punishment.playerMessage()))); + player.kick(CustomInventory.renderComponent(player, punishment.playerMessage().colorIfAbsent(PRIMARY_COLOR))); } } } diff --git a/src/main/java/de/shiewk/smoderation/paper/listener/VanishListener.java b/src/main/java/de/shiewk/smoderation/paper/listener/VanishListener.java index 30145ad..b624dc4 100644 --- a/src/main/java/de/shiewk/smoderation/paper/listener/VanishListener.java +++ b/src/main/java/de/shiewk/smoderation/paper/listener/VanishListener.java @@ -57,7 +57,7 @@ public class VanishListener implements Listener { broadcast(message.color(null)); } SchedulerUtil.scheduleForEntity(SModerationPaper.PLUGIN, player, () -> { - player.sendMessage(translatable("smod.vanish.stillEnabled")); + player.sendMessage(translatable("smod.command.vanish.stillEnabled")); player.playSound(Sound.sound( Key.key("minecraft", "block.beacon.power_select"), Sound.Source.MASTER, diff --git a/src/main/java/de/shiewk/smoderation/paper/punishments/Punishment.java b/src/main/java/de/shiewk/smoderation/paper/punishments/Punishment.java index a68e8a5..941b087 100644 --- a/src/main/java/de/shiewk/smoderation/paper/punishments/Punishment.java +++ b/src/main/java/de/shiewk/smoderation/paper/punishments/Punishment.java @@ -120,7 +120,7 @@ public class Punishment { public void broadcastUndo(PunishmentContainer container){ for (CommandSender sender : container.collectBroadcastTargets()) { - sender.sendMessage(CHAT_PREFIX.append(undoMessage())); + sender.sendMessage(undoMessage().colorIfAbsent(PRIMARY_COLOR)); } } @@ -158,7 +158,7 @@ public class Punishment { private void broadcastIssue(PunishmentContainer container){ for (CommandSender sender : container.collectBroadcastTargets()) { - sender.sendMessage(CHAT_PREFIX.append(broadcastMessage())); + sender.sendMessage(broadcastMessage().colorIfAbsent(PRIMARY_COLOR)); } } @@ -167,7 +167,7 @@ public class Punishment { case MUTE, BAN -> { final CommandSender sender = PlayerUtil.senderByUUID(to); if (sender != null) { - sender.sendMessage(CHAT_PREFIX.append(playerMessage())); + sender.sendMessage(playerMessage().colorIfAbsent(PRIMARY_COLOR)); } } } diff --git a/src/main/resources/smoderation/translations/en_us.json b/src/main/resources/smoderation/translations/en_us.json index 75bbf42..a3bd3c4 100644 --- a/src/main/resources/smoderation/translations/en_us.json +++ b/src/main/resources/smoderation/translations/en_us.json @@ -8,17 +8,17 @@ "smod.command.ban.fail.protect": "This player can't be banned.", "smod.command.ban.fail.self": "You can't ban yourself.", "smod.command.ban.fail.tooShort": "You can't ban an offline player for less than 1ms.", - "smod.command.ecsee.opening": "Opening ender chest of .", + "smod.command.ecsee.opening": "Opening ender chest of .", "smod.command.fail.invalidPlayer": "Please provide a valid player.", "smod.command.fail.players": "Only players can execute this command.", "smod.command.fail.playersConsole": "Only players and the console can execute this command.", "smod.command.invsee.fail.self": "You can't open your own inventory.", - "smod.command.invsee.opening": "Opening inventory of .", + "smod.command.invsee.opening": "Opening inventory of .", "smod.command.kick.fail.forceReason": "Please provide a reason.", "smod.command.kick.fail.protect": "This player can't be kicked.", "smod.command.kick.fail.self": "You can't kick yourself.", "smod.command.modlogs.ban": "- is banned until (in ). Reason: ", - "smod.command.modlogs.heading": "Player ()", + "smod.command.modlogs.heading": "Player ()", "smod.command.modlogs.mute": "- is muted until (in ). Reason: ", "smod.command.modlogs.none": "- is not currently muted or banned.", "smod.command.mute.fail.forceReason": "Please provide a reason.", @@ -26,18 +26,19 @@ "smod.command.mute.fail.self": "You can't mute yourself.", "smod.command.mute.fail.tooShort": "You can't mute a player for less than 1ms.", "smod.command.offlinetp.fail.unknown": "This player's location is unknown.", - "smod.command.offlinetp.teleporting": "Teleporting you to .", - "smod.command.socialspy.disabled": "SocialSpy disabled.", - "smod.command.socialspy.enabled": "SocialSpy enabled.", + "smod.command.offlinetp.teleporting": "Teleporting you to .", + "smod.command.socialspy.disabled": "SocialSpy disabled.", + "smod.command.socialspy.enabled": "SocialSpy enabled.", "smod.command.unban.fail.notBanned": "That player is not banned.", "smod.command.unmute.fail.notMuted": "That player is not muted.", - "smod.command.vanish.broadcast.off": " re-appeared.", - "smod.command.vanish.broadcast.on": " vanished.", + "smod.command.vanish.broadcast.off": " re-appeared.", + "smod.command.vanish.broadcast.on": " vanished.", "smod.command.vanish.fail.noPlayersFound": "No player was found.", - "smod.command.vanish.list": "The following players are currently vanished: ", - "smod.command.vanish.list.none": "No players are currently vanished.", - "smod.command.vanish.toggle.off": "You are no longer vanished.", - "smod.command.vanish.toggle.on": "You are now vanished.", + "smod.command.vanish.list": "The following players are currently vanished: ", + "smod.command.vanish.list.none": "No players are currently vanished.", + "smod.command.vanish.stillEnabled": "You are still vanished!", + "smod.command.vanish.toggle.off": "You are no longer vanished.", + "smod.command.vanish.toggle.on": "You are now vanished.", "smod.confirm.no": "No", "smod.confirm.yes": "Yes", "smod.menu": "SMod Menu", @@ -104,6 +105,5 @@ "smod.time.seconds": " seconds", "smod.time.timestamp": " :: ", "smod.time.weeks": " weeks", - "smod.time.years": " years", - "smod.vanish.stillEnabled": "You are still vanished!" + "smod.time.years": " years" } \ No newline at end of file