mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-28 05:54:16 +02:00
Remove the chat prefix
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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": "<prefix>Opening ender chest of <secondary><arg:0></secondary>.",
|
||||
"smod.command.ecsee.opening": "<primary>Opening ender chest of <secondary><arg:0></secondary>.",
|
||||
"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": "<prefix>Opening inventory of <secondary><arg:0></secondary>.",
|
||||
"smod.command.invsee.opening": "<primary>Opening inventory of <secondary><arg:0></secondary>.",
|
||||
"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": "<primary>- is banned until <secondary><arg:0></secondary> <gray>(in <arg:1>)</gray>. Reason: <secondary><arg:2>",
|
||||
"smod.command.modlogs.heading": "<prefix>Player <secondary><arg:0> <gray>(<arg:1>)",
|
||||
"smod.command.modlogs.heading": "<primary>Player <secondary><arg:0> <gray>(<arg:1>)",
|
||||
"smod.command.modlogs.mute": "<primary>- is muted until <secondary><arg:0></secondary> <gray>(in <arg:1>)</gray>. Reason: <secondary><arg:2>",
|
||||
"smod.command.modlogs.none": "<primary>- 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": "<prefix>Teleporting you to <secondary><arg:0></secondary>.",
|
||||
"smod.command.socialspy.disabled": "<prefix>SocialSpy <red>disabled</red>.",
|
||||
"smod.command.socialspy.enabled": "<prefix>SocialSpy <green>enabled</green>.",
|
||||
"smod.command.offlinetp.teleporting": "<primary>Teleporting you to <secondary><arg:0></secondary>.",
|
||||
"smod.command.socialspy.disabled": "<primary>SocialSpy <red>disabled</red>.",
|
||||
"smod.command.socialspy.enabled": "<primary>SocialSpy <green>enabled</green>.",
|
||||
"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": "<prefix><secondary><arg:0></secondary> re-appeared.",
|
||||
"smod.command.vanish.broadcast.on": "<prefix><secondary><arg:0></secondary> vanished.",
|
||||
"smod.command.vanish.broadcast.off": "<primary><secondary><arg:0></secondary> re-appeared.",
|
||||
"smod.command.vanish.broadcast.on": "<primary><secondary><arg:0></secondary> vanished.",
|
||||
"smod.command.vanish.fail.noPlayersFound": "No player was found.",
|
||||
"smod.command.vanish.list": "<prefix>The following players are currently vanished: <arg:0>",
|
||||
"smod.command.vanish.list.none": "<prefix>No players are currently vanished.",
|
||||
"smod.command.vanish.toggle.off": "<prefix>You are no longer vanished.",
|
||||
"smod.command.vanish.toggle.on": "<prefix>You are now vanished.",
|
||||
"smod.command.vanish.list": "<primary>The following players are currently vanished: <arg:0>",
|
||||
"smod.command.vanish.list.none": "<primary>No players are currently vanished.",
|
||||
"smod.command.vanish.stillEnabled": "<bold><primary>You are still vanished!",
|
||||
"smod.command.vanish.toggle.off": "<primary>You are no longer vanished.",
|
||||
"smod.command.vanish.toggle.on": "<primary>You are now vanished.",
|
||||
"smod.confirm.no": "<red>No",
|
||||
"smod.confirm.yes": "<green>Yes",
|
||||
"smod.menu": "SMod Menu",
|
||||
@@ -104,6 +105,5 @@
|
||||
"smod.time.seconds": "<arg:0> seconds",
|
||||
"smod.time.timestamp": "<arg:2> <arg:1> <arg:0> <arg:3>:<arg:4>:<arg:5> <arg:6>",
|
||||
"smod.time.weeks": "<arg:0> weeks",
|
||||
"smod.time.years": "<arg:0> years",
|
||||
"smod.vanish.stillEnabled": "<bold><prefix>You are still vanished!"
|
||||
"smod.time.years": "<arg:0> years"
|
||||
}
|
||||
Reference in New Issue
Block a user