mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 00:46:40 +00:00
part 2
This commit is contained in:
@ -6,8 +6,8 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public class BaseCommand
|
||||
{
|
||||
public final Rank rank;
|
||||
public final String message;
|
||||
private final Rank rank;
|
||||
private final String message;
|
||||
|
||||
public BaseCommand(Rank r, String m)
|
||||
{
|
||||
|
@ -2,11 +2,16 @@ package dev.plex.cmdblocker;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Getter
|
||||
public class CommandBlockerManager
|
||||
{
|
||||
private List<BaseCommand> blockedCommands = new ArrayList<>();
|
||||
@ -31,15 +36,30 @@ public class CommandBlockerManager
|
||||
pieces.add(rawPieces[2]); // RegEx or match
|
||||
pieces.add(cmd.substring(lastDelim + 1)); // Message (w/o : in it)
|
||||
|
||||
if (pieces.get(3).equals("_"))
|
||||
{
|
||||
pieces.set(3, PlexUtils.messageString("commandBlocked"));
|
||||
}
|
||||
|
||||
Rank rank = Plex.get().getRankManager().getRankFromString(pieces.get(1));
|
||||
|
||||
if (pieces.get(0).equals("r"))
|
||||
{
|
||||
blockedCommands.add(new RegexCommand(Pattern.compile(pieces.get(2)), rank, pieces.get(3)));
|
||||
blockedCommands.add(new RegexCommand(Pattern.compile(pieces.get(2), Pattern.CASE_INSENSITIVE), rank, pieces.get(3)));
|
||||
}
|
||||
else if (pieces.get(0).equals("m"))
|
||||
{
|
||||
blockedCommands.add(new MatchCommand(pieces.get(2), rank, pieces.get(3)));
|
||||
String blockedArgs = pieces.get(2).substring(pieces.get(2).indexOf(' ') + 1);
|
||||
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(pieces.get(2).substring(0, pieces.get(2).indexOf(' ')));
|
||||
if (pluginCommand != null)
|
||||
{
|
||||
List<String> aliases = pluginCommand.getAliases();
|
||||
for (String alias : aliases)
|
||||
{
|
||||
blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, pieces.get(3)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public class MatchCommand extends BaseCommand
|
||||
{
|
||||
public final String match;
|
||||
private final String match;
|
||||
|
||||
public MatchCommand(String r1, Rank r2, String m1)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import java.util.regex.Pattern;
|
||||
@Getter
|
||||
public class RegexCommand extends BaseCommand
|
||||
{
|
||||
public final Pattern regex;
|
||||
private final Pattern regex;
|
||||
|
||||
public RegexCommand(Pattern r1, Rank r2, String m1)
|
||||
{
|
||||
|
Reference in New Issue
Block a user