1
mirror of https://github.com/Shiewk/SModeration.git synced 2026-04-29 06:34:17 +02:00

Remove the chat prefix

This commit is contained in:
Shy
2026-04-03 15:53:07 +02:00
parent 5c4feea042
commit fcd2a513aa
6 changed files with 29 additions and 33 deletions
@@ -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())
@@ -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<Component> 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() {
@@ -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)));
}
}
}
@@ -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,
@@ -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));
}
}
}