mirror of
https://github.com/plexusorg/Plex.git
synced 2025-01-03 14:17:37 +00:00
mOre FEATURES!! (+fixes)
This commit is contained in:
parent
1c4f43187d
commit
5f7a89d7cd
@ -4,9 +4,13 @@ import dev.plex.Plex;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -73,15 +77,30 @@ public class CommandBlockerManager
|
||||
}
|
||||
else if (rawType.equals("m"))
|
||||
{
|
||||
String blockedArgs = regexOrMatch.substring(regexOrMatch.indexOf(' ') + 1);
|
||||
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(regexOrMatch.substring(0, regexOrMatch.indexOf(' ')));
|
||||
int ind = regexOrMatch.indexOf(' ');
|
||||
if (ind == -1 && regexOrMatch.endsWith(":"))
|
||||
{
|
||||
//block all commands from this plugin for the specified rank
|
||||
Plugin plugin = Arrays.stream(Plex.get().getServer().getPluginManager().getPlugins()).findAny().orElse(null);
|
||||
if (plugin != null)
|
||||
{
|
||||
List<Command> commandList = PluginCommandYamlParser.parse(plugin);
|
||||
for (Command command : commandList)
|
||||
{
|
||||
blockedCommands.add(new MatchCommand(command.getName(), rank, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
String blockedArgs = ind == -1 ? "" : regexOrMatch.substring(ind + 1);
|
||||
if (!blockedArgs.isEmpty()) blockedArgs = " " + blockedArgs; // necessary in case no args
|
||||
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(ind == -1 ? regexOrMatch : regexOrMatch.substring(0, ind));
|
||||
if (pluginCommand != null)
|
||||
{
|
||||
blockedCommands.add(new MatchCommand(pluginCommand.getName() + " " + blockedArgs, rank, message));
|
||||
blockedCommands.add(new MatchCommand(pluginCommand.getName() + blockedArgs, rank, message));
|
||||
List<String> aliases = pluginCommand.getAliases();
|
||||
for (String alias : aliases)
|
||||
{
|
||||
blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, message));
|
||||
blockedCommands.add(new MatchCommand(alias + blockedArgs, rank, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class CommandListener extends PlexListener
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
String message = event.getMessage().substring(1);
|
||||
String message = event.getMessage().substring(1).stripLeading(); // stripLeading() is VITAL for workaround blocking (/ minecraft:summon)
|
||||
for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands()) {
|
||||
if (DataUtils.getPlayer(player.getUniqueId()).getRankFromString().ordinal() > blockedCommand.getRank().ordinal())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user