Impl filter (todo: remove check in SubCommands) And we may can use reflect to register command, registerCmd is stupid...

This commit is contained in:
Ghost_chu committed 2021-06-13 21:20:55 +08:00
1 parent 34a2e48b9d
commit 548a5b71b4
1 file changed
+19 -7
@@ -22,10 +22,7 @@ package org.maxgamer.quickshop.command;
import com.google.common.collect.Sets;
import lombok.Data;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -397,8 +394,9 @@ public class CommandManager implements TabCompleter, CommandExecutor {
return true;
}
}
if (sender instanceof Player && plugin.getConfig().getBoolean("effect.sound.ontabcomplete")) {
boolean isPlayer = sender instanceof Player;
boolean isConsole = sender instanceof ConsoleCommandSender;
if (isPlayer && plugin.getConfig().getBoolean("effect.sound.ontabcomplete")) {
Player player = (Player) sender;
((Player) sender)
.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 80.0F, 1.0F);
@@ -420,6 +418,12 @@ public class CommandManager implements TabCompleter, CommandExecutor {
MsgUtil.sendDirectMessage(sender, container.getDisableText(sender));
return true;
}
if (container.isConsoleOnly() && !isConsole) {
continue;
}
if (container.isPlayerOnly() && !isPlayer) {
continue;
}
List<String> requirePermissions = container.getPermissions();
List<String> selectivePermissions = container.getSelectivePermissions();
if (!checkPermissions(sender, commandLabel, passThroughArgs, requirePermissions, PermissionType.REQUIRE, Action.EXECUTE)) {
@@ -494,7 +498,9 @@ public class CommandManager implements TabCompleter, CommandExecutor {
if (plugin.getBootError() != null) {
return Collections.emptyList();
}
if (sender instanceof Player && plugin.getConfig().getBoolean("effect.sound.ontabcomplete")) {
boolean isPlayer = sender instanceof Player;
boolean isConsole = sender instanceof ConsoleCommandSender;
if (isPlayer && plugin.getConfig().getBoolean("effect.sound.ontabcomplete")) {
Player player = (Player) sender;
((Player) sender).playSound(player.getLocation(), Sound.BLOCK_DISPENSER_FAIL, 80.0F, 1.0F);
}
@@ -509,6 +515,12 @@ public class CommandManager implements TabCompleter, CommandExecutor {
if (!container.getPrefix().toLowerCase().startsWith(cmdArg[0])) {
continue;
}
if (container.isConsoleOnly() && !isConsole) {
continue;
}
if (container.isPlayerOnly() && !isPlayer) {
continue;
}
List<String> requirePermissions = container.getPermissions();
List<String> selectivePermissions = container.getSelectivePermissions();
if (!checkPermissions(sender, commandLabel, passThroughArgs, requirePermissions, PermissionType.REQUIRE, Action.TAB_COMPLETE)) {