From 61e7ad7d8cc9c3c8c5d6b4b7b5afaf12ca1cb91a Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Mon, 26 Jan 2026 12:15:50 +0200 Subject: [PATCH 1/3] Registered default permissions --- README.md | 24 +++--- pom.xml | 6 ++ .../cloudnode/smp/cloudnodemsg/Message.java | 9 +- .../smp/cloudnodemsg/Permission.java | 55 ------------ .../smp/cloudnodemsg/Permissions.java | 84 +++++++++++++++++++ .../cloudnodemsg/command/IgnoreCommand.java | 8 +- .../smp/cloudnodemsg/command/MainCommand.java | 6 +- .../cloudnodemsg/command/MessageCommand.java | 8 +- .../cloudnodemsg/command/ReplyCommand.java | 4 +- .../command/TeamMessageCommand.java | 6 +- .../command/ToggleMessageCommand.java | 6 +- .../cloudnodemsg/command/UnIgnoreCommand.java | 6 +- .../listener/AsyncChatListener.java | 5 +- 13 files changed, 131 insertions(+), 96 deletions(-) delete mode 100644 src/main/java/pro/cloudnode/smp/cloudnodemsg/Permission.java create mode 100644 src/main/java/pro/cloudnode/smp/cloudnodemsg/Permissions.java diff --git a/README.md b/README.md index a2e5beb..d9d16b3 100644 --- a/README.md +++ b/README.md @@ -130,22 +130,22 @@ Reload the plugin configuration. Here is a list of the permissions used by this plugin. -| Permission | Description | Recommended Group | -|------------------------------|-------------------------------------------------------------------------|-------------------| -| `cloudnodemsg.use` | Allows using the `/msg` and `/r` commands | default | -| `cloudnodemsg.team` | Allows using the `/teammsg` command | default | -| `cloudnodemsg.send.vanished` | Allows sending messages to vanished players | admin | -| `cloudnodemsg.ignore` | Allows using the `/ignore` and `/unignore` commands | default | -| `cloudnodemsg.ignore.bypass` | Makes your private messages visible, even if the recipient ignored you | admin | -| `cloudnodemsg.toggle` | Allows you to use the `/togglemsg` command | default | -| `cloudnodemsg.toggle.other` | Allows you to toggle msg for another player using `/togglemsg ` | admin | -| `cloudnodemsg.toggle.bypass` | Allows you to send messages to players with disabled DMs | admin | -| `cloudnodemsg.spy` | Players with this permission see ALL private messages and team messages | admin | +| Permission | Description | Default | +|------------------------------|------------------------------------------------------------------------------------------------------------------|----------| +| `cloudnodemsg.use` | Allows access to the private message ([`/msg`](#msg-player-message) and reply ([`/r`](#reply-message) commands | everyone | +| `cloudnodemsg.team` | Allows access to the team message command ([`/teammsg`](#teammsg) | everyone | +| `cloudnodemsg.ignore` | Allows access to the [`/ignore`](#ignore-player) and [`/unignore`](#unignore-player) commands | everyone | +| `cloudnodemsg.ignore.bypass` | Prevents the sender’s messages from being ignored | none | +| `cloudnodemsg.toggle` | Allows toggling receiving private messages on and off with [`/togglemsg`](#togglemsg) | everyone | +| `cloudnodemsg.toggle.other` | Allows toggling receiving private messages on and off for others with [`/togglemsg `](#togglemsg-player) | OP | +| `cloudnodemsg.toggle.bypass` | Allows sending private messages to recipients who have toggled them off | OP | +| `cloudnodemsg.send.vanished` | Allows sending messages to vanished recipients | OP | +| `cloudnodemsg.spy` | Makes you see all private and team messages sent between all players | none | ## Release Cycle CloudnodeMSG follows a weekly **time-based release schedule**, -with new features or changes typically released every **Tuesday**. +with new features or changes typically released on **Tuesday**. When we merge critical bug fixes, we may publish out-of-band releases on any day of the week. diff --git a/pom.xml b/pom.xml index f7c1967..6c7ddf8 100644 --- a/pom.xml +++ b/pom.xml @@ -64,5 +64,11 @@ 2.11.7 provided + + org.jspecify + jspecify + 1.0.0 + compile + diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java index b206444..e192a20 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java @@ -57,7 +57,8 @@ public void send(final @NotNull Context context) throws InvalidPlayerError { final @NotNull Optional<@NotNull Player> senderPlayer = Optional.ofNullable(this.sender.getPlayer()); final @NotNull Optional<@NotNull Player> recipientPlayer = Optional.ofNullable(this.recipient.getPlayer()); - if (!recipient.getUniqueId().equals(console.getUniqueId()) && recipientPlayer.isEmpty() || (recipientPlayer.isPresent() && senderPlayer.isPresent() && CloudnodeMSG.isVanished(recipientPlayer.get()) && !senderPlayer.get().hasPermission(Permission.SEND_VANISHED))) { + if (!recipient.getUniqueId().equals(console.getUniqueId()) && recipientPlayer.isEmpty() || (recipientPlayer.isPresent() && senderPlayer.isPresent() && CloudnodeMSG.isVanished(recipientPlayer.get()) && !senderPlayer.get().hasPermission( + Permissions.SEND_VANISHED))) { if (context == Context.CHANNEL) { final @NotNull Player player = Objects.requireNonNull(sender.getPlayer()); Message.exitChannel(player); @@ -73,7 +74,7 @@ public void send(final @NotNull Context context) throws InvalidPlayerError { } if (recipientPlayer.isPresent() && senderPlayer.isPresent() && !Message.isIncomingEnabled(recipientPlayer.get()) && !senderPlayer - .get().hasPermission(Permission.TOGGLE_BYPASS)) { + .get().hasPermission(Permissions.TOGGLE_BYPASS)) { new PlayerHasIncomingDisabledError(recipientPlayer.get().getName()).send(senderPlayer.get()); return; } @@ -81,7 +82,7 @@ public void send(final @NotNull Context context) throws InvalidPlayerError { sendSpyMessage(sender, recipient, message); sendMessage(sender, CloudnodeMSG.getInstance().config().outgoing(senderUsername, recipientUsername, message)); if ((recipientPlayer.isPresent() && Message.isIgnored(recipientPlayer.get(), sender)) && (senderPlayer.isPresent() && !senderPlayer - .get().hasPermission(Permission.IGNORE_BYPASS))) return; + .get().hasPermission(Permissions.IGNORE_BYPASS))) return; sendMessage(recipient, CloudnodeMSG.getInstance().config() .incoming(senderUsername, recipientUsername, message)); @@ -114,7 +115,7 @@ public static void sendSpyMessage(final @NotNull OfflinePlayer sender, final @No .getInstance().config().consoleName() : Optional.ofNullable(recipient.getName()) .orElse("Unknown Player"); for (final @NotNull Player player : CloudnodeMSG.getInstance().getServer().getOnlinePlayers()) { - if (!player.hasPermission(Permission.SPY) || player.getUniqueId().equals(sender.getUniqueId()) || player + if (!player.hasPermission(Permissions.SPY) || player.getUniqueId().equals(sender.getUniqueId()) || player .getUniqueId().equals(recipient.getUniqueId())) continue; sendMessage(player, CloudnodeMSG.getInstance().config().spy(senderName, recipientName, message)); } diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permission.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permission.java deleted file mode 100644 index 6b4bcb8..0000000 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permission.java +++ /dev/null @@ -1,55 +0,0 @@ -package pro.cloudnode.smp.cloudnodemsg; - -import org.jetbrains.annotations.NotNull; - -public final class Permission { - /** - * Allows using the /msg and /r commands - */ - public final static @NotNull String USE = "cloudnodemsg.use"; - - /** - * Allow using the team message command (/teammsg) - */ - public final static @NotNull String USE_TEAM = "cloudnodemsg.use.team"; - - /** - * Allows reloading the plugin - */ - public final static @NotNull String RELOAD = "cloudnodemsg.reload"; - - /** - * Allows sending messages to vanished players - */ - public final static @NotNull String SEND_VANISHED = "cloudnodemsg.send.vanished"; - - /** - * Allows ignoring and unignoring players - */ - public final static @NotNull String IGNORE = "cloudnodemsg.ignore"; - - /** - * Player's messages are immune to ignoring - */ - public final static @NotNull String IGNORE_BYPASS = "cloudnodemsg.ignore.bypass"; - - /** - * Allows using the /togglemsg command - */ - public final static @NotNull String TOGGLE = "cloudnodemsg.toggle"; - - /** - * Allows using the /togglemsg command for others - */ - public final static @NotNull String TOGGLE_OTHER = "cloudnodemsg.toggle.other"; - - /** - * Allows to send private message even when the target have their private messages toggled - */ - public final static @NotNull String TOGGLE_BYPASS = "cloudnodemsg.toggle.bypass"; - - /** - * Allows to see the private messages of other players - */ - public final static @NotNull String SPY = "cloudnodemsg.spy"; -} diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permissions.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permissions.java new file mode 100644 index 0000000..35468ac --- /dev/null +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/Permissions.java @@ -0,0 +1,84 @@ +package pro.cloudnode.smp.cloudnodemsg; + +import org.bukkit.Bukkit; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Permissions { + private static final String NAME = "cloudnodemsg"; + + public static final Permission USE = create( + "use", + "Allows access to the private message (/msg) and reply (/r) commands", + PermissionDefault.TRUE + ); + + public static final Permission USE_TEAM = create( + "use.team", + "Allows access to the team message command (/teammsg)", + PermissionDefault.TRUE + ); + + public static final Permission IGNORE = create( + "ignore", + "Allows access to the /ignore and /unignore commands", + PermissionDefault.TRUE + ); + + public static final Permission IGNORE_BYPASS = create( + "ignore.bypass", + "Prevents the sender’s messages from being ignored" + ); + + public static final Permission TOGGLE = create( + "toggle", + "Allows toggling receiving private messages on and off with /togglemsg", + PermissionDefault.TRUE + ); + + public static final Permission TOGGLE_OTHER = create( + "toggle.other", + "Allows toggling receiving private messages on and off for others with /togglemsg ", + PermissionDefault.OP + ); + + public static final Permission TOGGLE_BYPASS = create( + "toggle.bypass", + "Allows sending private messages to recipients who have toggled them off", + PermissionDefault.OP + ); + + public static final Permission SEND_VANISHED = create( + "send.vanished", + "Allows sending messages to vanished recipients", + PermissionDefault.OP + ); + + public static final Permission SPY = create( + "spy", + "Makes you see all private and team messages sent between all players" + ); + + public static final Permission RELOAD = create( + "reload", + "Allows access to the /cloudnodemsg reload command", + PermissionDefault.OP + ); + + private static Permission create(final String node, final String description) { + return new Permission(String.format("%s.%s", NAME, node), description); + } + + private static Permission create( + final String node, + final String description, + final PermissionDefault permissionDefault + ) { + final var permission = create(node, description); + permission.setDefault(permissionDefault); + Bukkit.getPluginManager().addPermission(permission); + return permission; + } +} diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/IgnoreCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/IgnoreCommand.java index c33b8a9..4e06585 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/IgnoreCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/IgnoreCommand.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.CannotIgnoreError; import pro.cloudnode.smp.cloudnodemsg.error.NeverJoinedError; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; @@ -23,7 +23,7 @@ public final class IgnoreCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.IGNORE)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.IGNORE)) return new NoPermissionError().send(sender); if (!(sender instanceof final @NotNull Player player)) return new NotPlayerError().send(sender); if (args.length == 0) return sendMessage(player, CloudnodeMSG.getInstance().config().usage(label, usage)); final @NotNull OfflinePlayer target = CloudnodeMSG.getInstance().getServer().getOfflinePlayer(args[0]); @@ -33,7 +33,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la } public static boolean ignore(final @NotNull Player player, final @NotNull OfflinePlayer target) { - if (target.isOnline() && Objects.requireNonNull(target.getPlayer()).hasPermission(Permission.IGNORE_BYPASS)) + if (target.isOnline() && Objects.requireNonNull(target.getPlayer()).hasPermission(Permissions.IGNORE_BYPASS)) return new CannotIgnoreError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player); if (!target.isOnline() && !target.hasPlayedBefore()) return new NeverJoinedError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player); @@ -50,7 +50,7 @@ public static boolean unignore(final @NotNull Player player, final @NotNull Offl @Override public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, final @NotNull String @NotNull [] args) { - if (args.length == 1 && sender.hasPermission(Permission.IGNORE) && sender instanceof Player) return null; + if (args.length == 1 && sender.hasPermission(Permissions.IGNORE) && sender instanceof Player) return null; return new ArrayList<>(); } } diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MainCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MainCommand.java index 186a09c..6ee01e5 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MainCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MainCommand.java @@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; import java.util.ArrayList; @@ -31,7 +31,7 @@ private boolean info(final @NotNull CommandSender sender) { } private boolean reload(final @NotNull CommandSender sender) { - if (!sender.hasPermission(Permission.RELOAD)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.RELOAD)) return new NoPermissionError().send(sender); CloudnodeMSG.getInstance().reload(); return sendMessage(sender, CloudnodeMSG.getInstance().config().reloaded()); } @@ -39,7 +39,7 @@ private boolean reload(final @NotNull CommandSender sender) { @Override public @NotNull List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, final @NotNull String @NotNull [] args) { final @NotNull List<@NotNull String> completions = new ArrayList<>(); - if (args.length == 1) if (sender.hasPermission(Permission.RELOAD) && "reload".startsWith(args[0].toLowerCase())) + if (args.length == 1) if (sender.hasPermission(Permissions.RELOAD) && "reload".startsWith(args[0].toLowerCase())) completions.add("reload"); return completions; } diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java index 2ce01de..edc71d8 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java @@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; import pro.cloudnode.smp.cloudnodemsg.Message; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.InvalidPlayerError; import pro.cloudnode.smp.cloudnodemsg.error.MessageYourselfError; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; @@ -25,7 +25,7 @@ public final class MessageCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.USE)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.USE)) return new NoPermissionError().send(sender); if (args.length == 0) return sendMessage(sender, CloudnodeMSG.getInstance().config().usage(label, sender instanceof Player ? usage : usageConsole)); if (args.length == 1 && !(sender instanceof Player)) return sendMessage(sender, CloudnodeMSG.getInstance().config() @@ -44,7 +44,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la return sendMessage(player, CloudnodeMSG.getInstance().config().channelClosed(player.getName(), Optional.ofNullable(recipientOffline.getName()).orElse("Unknown Player"), label)); } } - if (recipient.isEmpty() || (CloudnodeMSG.isVanished(recipient.get()) && !player.hasPermission(Permission.SEND_VANISHED))) return new PlayerNotFoundError(args[0]).send(player); + if (recipient.isEmpty() || (CloudnodeMSG.isVanished(recipient.get()) && !player.hasPermission(Permissions.SEND_VANISHED))) return new PlayerNotFoundError(args[0]).send(player); if (!Message.isIncomingEnabled(recipient.get())) return new PlayerHasIncomingDisabledError(recipient.get().getName()).send(player); Message.createChannel(player, recipient.get()); return sendMessage(player, CloudnodeMSG.getInstance().config().channelCreated(player.getName(), recipient.get().getName(), label)); @@ -62,7 +62,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la @Override public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, final @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.USE)) return new ArrayList<>(); + if (!sender.hasPermission(Permissions.USE)) return new ArrayList<>(); // `null` works for list of players if (args.length == 1) return null; return new ArrayList<>(); diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ReplyCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ReplyCommand.java index a7757c5..5cc6cbb 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ReplyCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ReplyCommand.java @@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; import pro.cloudnode.smp.cloudnodemsg.Message; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.InvalidPlayerError; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; import pro.cloudnode.smp.cloudnodemsg.error.NobodyReplyError; @@ -19,7 +19,7 @@ public final class ReplyCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.USE)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.USE)) return new NoPermissionError().send(sender); if (args.length == 0) return sendMessage(sender, CloudnodeMSG.getInstance().config().usage(label, usage)); final @NotNull Optional<@NotNull OfflinePlayer> recipient = Message.getReplyTo(Message.offlinePlayer(sender)); diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/TeamMessageCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/TeamMessageCommand.java index cea49bf..0d377ba 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/TeamMessageCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/TeamMessageCommand.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; import pro.cloudnode.smp.cloudnodemsg.Message; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; import pro.cloudnode.smp.cloudnodemsg.error.NotInTeamError; import pro.cloudnode.smp.cloudnodemsg.error.NotPlayerError; @@ -20,7 +20,7 @@ public class TeamMessageCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.USE_TEAM)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.USE_TEAM)) return new NoPermissionError().send(sender); if (!(sender instanceof final @NotNull Player player)) return new NotPlayerError().send(sender); final @NotNull Optional<@NotNull Team> team = Optional.ofNullable(player.getScoreboard().getPlayerTeam(player)); if (team.isEmpty()) return new NotInTeamError().send(player); @@ -53,7 +53,7 @@ public static boolean sendTeamMessage(final @NotNull Player sender, final @NotNu if (Optional.ofNullable(player.getScoreboard().getPlayerTeam(player)).map(t -> t.equals(team)) .orElse(false)) sendMessage(player, CloudnodeMSG.getInstance().config().team(sender.getName(), team, message)); - else if (player.hasPermission(Permission.SPY)) + else if (player.hasPermission(Permissions.SPY)) sendMessage(player, CloudnodeMSG.getInstance().config().teamSpy(sender.getName(), team, message)); } sender.getServer().getConsoleSender() diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ToggleMessageCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ToggleMessageCommand.java index 6dbbd63..8d56f72 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ToggleMessageCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ToggleMessageCommand.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.NeverJoinedError; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; import pro.cloudnode.smp.cloudnodemsg.error.NotPlayerError; @@ -19,7 +19,7 @@ public final class ToggleMessageCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.TOGGLE) || (args.length == 1 && !sender.hasPermission(Permission.TOGGLE_OTHER))) + if (!sender.hasPermission(Permissions.TOGGLE) || (args.length == 1 && !sender.hasPermission(Permissions.TOGGLE_OTHER))) return new NoPermissionError().send(sender); if (args.length == 1) { final @NotNull OfflinePlayer recipient = CloudnodeMSG.getInstance().getServer().getOfflinePlayer(args[0]); @@ -50,7 +50,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la @Override public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final org.bukkit.command.@NotNull Command command, final @NotNull String s, final @NotNull String @NotNull [] strings) { - if (sender.hasPermission(Permission.TOGGLE_OTHER)) return null; + if (sender.hasPermission(Permissions.TOGGLE_OTHER)) return null; return new ArrayList<>(); } } diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/UnIgnoreCommand.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/UnIgnoreCommand.java index d165c38..322b042 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/UnIgnoreCommand.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/command/UnIgnoreCommand.java @@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError; import pro.cloudnode.smp.cloudnodemsg.error.NotIgnoredError; import pro.cloudnode.smp.cloudnodemsg.error.NotPlayerError; @@ -24,7 +24,7 @@ public final class UnIgnoreCommand extends Command { @Override public boolean run(final @NotNull CommandSender sender, final @NotNull String label, @NotNull String @NotNull [] args) { - if (!sender.hasPermission(Permission.IGNORE)) return new NoPermissionError().send(sender); + if (!sender.hasPermission(Permissions.IGNORE)) return new NoPermissionError().send(sender); if (!(sender instanceof final @NotNull Player player)) return new NotPlayerError().send(sender); if (args.length == 0) return sendMessage(sender, CloudnodeMSG.getInstance().config().usage(label, usage)); final @NotNull OfflinePlayer target = CloudnodeMSG.getInstance().getServer().getOfflinePlayer(args[0]); @@ -34,7 +34,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la @Override public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, final @NotNull String @NotNull [] args) { - if (args.length == 1 && sender.hasPermission(Permission.IGNORE) && sender instanceof final @NotNull Player player) { + if (args.length == 1 && sender.hasPermission(Permissions.IGNORE) && sender instanceof final @NotNull Player player) { final @NotNull HashSet<@NotNull UUID> ignored = Message.getIgnored(player); final @NotNull Server server = CloudnodeMSG.getInstance().getServer(); return new ArrayList<>(ignored.stream().map(u -> server.getOfflinePlayer(u).getName()) diff --git a/src/main/java/pro/cloudnode/smp/cloudnodemsg/listener/AsyncChatListener.java b/src/main/java/pro/cloudnode/smp/cloudnodemsg/listener/AsyncChatListener.java index 7fedef3..9651f5a 100644 --- a/src/main/java/pro/cloudnode/smp/cloudnodemsg/listener/AsyncChatListener.java +++ b/src/main/java/pro/cloudnode/smp/cloudnodemsg/listener/AsyncChatListener.java @@ -3,7 +3,6 @@ import io.papermc.paper.chat.ChatRenderer; import io.papermc.paper.event.player.AsyncChatEvent; import net.kyori.adventure.audience.Audience; -import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -14,7 +13,7 @@ import org.jetbrains.annotations.NotNull; import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG; import pro.cloudnode.smp.cloudnodemsg.Message; -import pro.cloudnode.smp.cloudnodemsg.Permission; +import pro.cloudnode.smp.cloudnodemsg.Permissions; import pro.cloudnode.smp.cloudnodemsg.command.TeamMessageCommand; import pro.cloudnode.smp.cloudnodemsg.error.InvalidPlayerError; import pro.cloudnode.smp.cloudnodemsg.error.NotInTeamError; @@ -38,7 +37,7 @@ public void ignore(final @NotNull AsyncChatEvent event) { final @NotNull HashSet<@NotNull OfflinePlayer> ignored = Message.getIgnored(player).stream() .map(server::getOfflinePlayer).collect(HashSet::new, HashSet::add, HashSet::addAll); - if (ignored.contains(sender) && !sender.hasPermission(Permission.IGNORE_BYPASS)) iterator.remove(); + if (ignored.contains(sender) && !sender.hasPermission(Permissions.IGNORE_BYPASS)) iterator.remove(); } } } From c630253fcad4755aa5e5a682799472ec48ac80c0 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Mon, 26 Jan 2026 12:23:26 +0200 Subject: [PATCH 2/3] improved IDE run configs --- .gitignore | 115 +------- .idea/.gitignore | 10 + .idea/artifacts/CloudnodeMSG.xml | 8 + .idea/codeStyles/Project.xml | 339 ++++++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 6 + .idea/compiler.xml | 13 + .idea/encodings.xml | 7 + .idea/jarRepositories.xml | 35 +++ .idea/misc.xml | 12 + .idea/modules.xml | 8 + .idea/runConfigurations/Server.xml | 14 + .idea/vcs.xml | 6 + .run/{Package.run.xml => Build.run.xml} | 6 +- CloudnodeMSG.iml | 14 + pom.xml | 1 + 15 files changed, 477 insertions(+), 117 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/artifacts/CloudnodeMSG.xml create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations/Server.xml create mode 100644 .idea/vcs.xml rename .run/{Package.run.xml => Build.run.xml} (83%) create mode 100644 CloudnodeMSG.iml diff --git a/.gitignore b/.gitignore index 4788b4b..dd4bac8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,113 +1,2 @@ -# User-specific stuff -.idea/ - -*.iml -*.ipr -*.iws - -# IntelliJ -out/ - -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -target/ - -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next - -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.flattened-pom.xml - -# Common working directory -run/ +target +server diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/artifacts/CloudnodeMSG.xml b/.idea/artifacts/CloudnodeMSG.xml new file mode 100644 index 0000000..7955b8c --- /dev/null +++ b/.idea/artifacts/CloudnodeMSG.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/server/plugins + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..2569ffc --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,339 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..6e6eec1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..bf9ff31 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..6273719 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b83499c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c293807 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Server.xml b/.idea/runConfigurations/Server.xml new file mode 100644 index 0000000..31068b4 --- /dev/null +++ b/.idea/runConfigurations/Server.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.run/Package.run.xml b/.run/Build.run.xml similarity index 83% rename from .run/Package.run.xml rename to .run/Build.run.xml index 598b4f7..11d2c6f 100644 --- a/.run/Package.run.xml +++ b/.run/Build.run.xml @@ -1,5 +1,5 @@ - +