fix and improve 👍

fix !
This commit is contained in:
ayunami2000 2022-04-08 22:13:51 -04:00
parent 79b687c80d
commit cf45863632
7 changed files with 8 additions and 15 deletions

View File

@ -17,6 +17,6 @@ public class BaseCommand
public String toString() public String toString()
{ {
return "BaseCommand (Rank: " + rank.name() + ", Message: " + message + ")"; return "BaseCommand (Rank: " + (rank == null ? "ALL" : rank.name()) + ", Message: " + message + ")";
} }
} }

View File

@ -50,10 +50,10 @@ public class CommandBlockerManager extends PlexBase
Rank rank = switch (rawRank) Rank rank = switch (rawRank)
{ {
case "e" -> Rank.IMPOSTOR; case "e" -> null;
case "a" -> Rank.ADMIN; case "a" -> Rank.ADMIN;
case "s" -> Rank.SENIOR_ADMIN; case "s" -> Rank.SENIOR_ADMIN;
default -> Rank.IMPOSTOR; default -> null;
}; };
if (rawType.equals("r")) if (rawType.equals("r"))

View File

@ -16,6 +16,6 @@ public class MatchCommand extends BaseCommand
public String toString() public String toString()
{ {
return "MatchCommand (Rank: " + getRank().name() + ", Match: " + match + ", Message: " + getMessage() + ")"; return "MatchCommand (Rank: " + (getRank() == null ? "ALL" : getRank().name()) + ", Match: " + match + ", Message: " + getMessage() + ")";
} }
} }

View File

@ -18,6 +18,6 @@ public class RegexCommand extends BaseCommand
public String toString() 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() + ")";
} }
} }

View File

@ -42,9 +42,8 @@ public class CommandListener extends PlexListener
for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands()) for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands())
{ {
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); 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; continue;
} }
@ -53,7 +52,6 @@ public class CommandListener extends PlexListener
{ {
if (regexCommand.getRegex().matcher(message).lookingAt()) if (regexCommand.getRegex().matcher(message).lookingAt())
{ {
PlexLog.debug("command blocked");
isBlocked = true; isBlocked = true;
} }
} }
@ -61,13 +59,13 @@ public class CommandListener extends PlexListener
{ {
if (message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase())) if (message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase()))
{ {
PlexLog.debug("command blocked");
isBlocked = true; isBlocked = true;
} }
} }
if (isBlocked) if (isBlocked)
{ {
event.setCancelled(true); event.setCancelled(true);
//PlexLog.debug("Command blocked.");
player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage())); player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
return; return;
} }

View File

@ -45,11 +45,6 @@ public enum Rank
return this.level >= rank.getLevel(); return this.level >= rank.getLevel();
} }
public boolean isAtMost(Rank rank)
{
return this.level <= rank.getLevel();
}
public Component getPrefix() public Component getPrefix()
{ {
return MiniMessage.miniMessage().deserialize(this.prefix); return MiniMessage.miniMessage().deserialize(this.prefix);

View File

@ -7,7 +7,7 @@
# Symbols to use: # Symbols to use:
# - r for RegEx # - r for RegEx
# - m for matching # - 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:") # - 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. # - 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 # - 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