mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
fix and improve 👍
fix !
This commit is contained in:
parent
79b687c80d
commit
cf45863632
@ -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 + ")";
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
@ -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() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -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() + ")";
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user