fix ranks in commandblocker for inactive admins

This commit is contained in:
9378062 2022-04-08 11:04:55 -04:00
parent 245f7dd4d3
commit 9f0b8fb56a

View File

@ -6,6 +6,8 @@ import dev.plex.cmdblocker.BaseCommand;
import dev.plex.cmdblocker.MatchCommand; import dev.plex.cmdblocker.MatchCommand;
import dev.plex.cmdblocker.RegexCommand; import dev.plex.cmdblocker.RegexCommand;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -38,7 +40,8 @@ public class CommandListener extends PlexListener
Player player = event.getPlayer(); Player player = event.getPlayer();
String message = event.getMessage().substring(1).stripLeading(); // stripLeading() is VITAL for workaround blocking (/ minecraft:summon) String message = event.getMessage().substring(1).stripLeading(); // stripLeading() is VITAL for workaround blocking (/ minecraft:summon)
for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands()) { for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands()) {
if (DataUtils.getPlayer(player.getUniqueId()).getRankFromString().ordinal() > blockedCommand.getRank().ordinal()) PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
if (Math.min(plexPlayer.getRankFromString().ordinal(), (plexPlayer.isAdminActive() ? Rank.EXECUTIVE : Rank.OP).ordinal()) > blockedCommand.getRank().ordinal())
{ {
continue; continue;
} }