diff --git a/src/main/java/dev/plex/cmdblocker/BaseCommand.java b/src/main/java/dev/plex/cmdblocker/BaseCommand.java index 9618431..6f5cf2d 100644 --- a/src/main/java/dev/plex/cmdblocker/BaseCommand.java +++ b/src/main/java/dev/plex/cmdblocker/BaseCommand.java @@ -17,6 +17,6 @@ public class BaseCommand public String toString() { - return "BaseCommand (Rank: " + rank.name() + ", Message: " + message + ")"; + return "BaseCommand (Rank: " + (rank == null ? "ALL" : rank.name()) + ", Message: " + message + ")"; } } diff --git a/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java b/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java index 2bc1ef4..5891420 100644 --- a/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java +++ b/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java @@ -50,10 +50,10 @@ public class CommandBlockerManager extends PlexBase Rank rank = switch (rawRank) { - case "e" -> Rank.IMPOSTOR; + case "e" -> null; case "a" -> Rank.ADMIN; case "s" -> Rank.SENIOR_ADMIN; - default -> Rank.IMPOSTOR; + default -> null; }; if (rawType.equals("r")) diff --git a/src/main/java/dev/plex/cmdblocker/MatchCommand.java b/src/main/java/dev/plex/cmdblocker/MatchCommand.java index 7b8721a..530ae6c 100644 --- a/src/main/java/dev/plex/cmdblocker/MatchCommand.java +++ b/src/main/java/dev/plex/cmdblocker/MatchCommand.java @@ -16,6 +16,6 @@ public class MatchCommand extends BaseCommand public String toString() { - return "MatchCommand (Rank: " + getRank().name() + ", Match: " + match + ", Message: " + getMessage() + ")"; + return "MatchCommand (Rank: " + (getRank() == null ? "ALL" : getRank().name()) + ", Match: " + match + ", Message: " + getMessage() + ")"; } } diff --git a/src/main/java/dev/plex/cmdblocker/RegexCommand.java b/src/main/java/dev/plex/cmdblocker/RegexCommand.java index 9ade48f..8004e9a 100644 --- a/src/main/java/dev/plex/cmdblocker/RegexCommand.java +++ b/src/main/java/dev/plex/cmdblocker/RegexCommand.java @@ -18,6 +18,6 @@ public class RegexCommand extends BaseCommand public String toString() { - return "RegexCommand (Rank: " + getRank().name() + ", Regex: " + regex.toString() + ", Message: " + getMessage() + ")"; + return "RegexCommand (Rank: " + (getRank() == null ? "ALL" : getRank().name()) + ", Regex: " + regex.toString() + ", Message: " + getMessage() + ")"; } } \ No newline at end of file diff --git a/src/main/java/dev/plex/listener/impl/CommandListener.java b/src/main/java/dev/plex/listener/impl/CommandListener.java index 597c2dc..7c2d678 100644 --- a/src/main/java/dev/plex/listener/impl/CommandListener.java +++ b/src/main/java/dev/plex/listener/impl/CommandListener.java @@ -42,9 +42,8 @@ public class CommandListener extends PlexListener for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands()) { PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); - if (plexPlayer.getRankFromString().isAtLeast(blockedCommand.getRank())) + if (blockedCommand.getRank() != null && plexPlayer.getRankFromString().isAtLeast(blockedCommand.getRank())) { - PlexLog.debug("we got here, continuing"); continue; } @@ -53,7 +52,6 @@ public class CommandListener extends PlexListener { if (regexCommand.getRegex().matcher(message).lookingAt()) { - PlexLog.debug("command blocked"); isBlocked = true; } } @@ -61,13 +59,13 @@ public class CommandListener extends PlexListener { if (message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase())) { - PlexLog.debug("command blocked"); isBlocked = true; } } if (isBlocked) { event.setCancelled(true); + //PlexLog.debug("Command blocked."); player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage())); return; } diff --git a/src/main/java/dev/plex/rank/enums/Rank.java b/src/main/java/dev/plex/rank/enums/Rank.java index 8df56a5..177b9a0 100644 --- a/src/main/java/dev/plex/rank/enums/Rank.java +++ b/src/main/java/dev/plex/rank/enums/Rank.java @@ -45,11 +45,6 @@ public enum Rank return this.level >= rank.getLevel(); } - public boolean isAtMost(Rank rank) - { - return this.level <= rank.getLevel(); - } - public Component getPrefix() { return MiniMessage.miniMessage().deserialize(this.prefix); diff --git a/src/main/resources/commands.yml b/src/main/resources/commands.yml index 22d9048..d168eeb 100644 --- a/src/main/resources/commands.yml +++ b/src/main/resources/commands.yml @@ -7,7 +7,7 @@ # Symbols to use: # - r for RegEx # - m for matching -# - The ranks are "e" for executive and below, "s" for senior admin and below, "a" for admin and below, "o" for op and below, "n" for nonop and below, and "i" for impostor +# - The ranks are "e" for everyone, "s" for senior admin, and "a" for admin # - MATCHING MODE: The command is just the command without slashes. Optional arguments are specified as well. It also accepts full plugins via specifying the plugin name followed by a ":" (e.g. "viaversion:") # - REGEX MODE: The command is regex that matches the desired command. It matches case insensitively. # - Finally the block message. MUST NOT CONTAIN ":". Use _ to use the default command blocked message as specified in messages.yml, or you can optionally put your own in