mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
made perms enum
added some missing stuff
This commit is contained in:
+4
-4
@@ -10,6 +10,7 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
@@ -71,7 +72,7 @@ public class CommandWhitelistVelocity {
|
||||
@Subscribe
|
||||
public void onUserCommandSendEvent(PlayerAvailableCommandsEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("commandwhitelist.bypass")) return;
|
||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
||||
event.getRootNode().getChildren().removeIf((commandNode) ->
|
||||
server.getCommandManager().hasCommand(commandNode.getName())
|
||||
@@ -84,7 +85,7 @@ public class CommandWhitelistVelocity {
|
||||
if (!(event.getCommandSource() instanceof Player)) return;
|
||||
Player player = (Player) event.getCommandSource();
|
||||
|
||||
if (player.hasPermission("commandwhitelist.bypass")) return;
|
||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||
|
||||
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
||||
String command = event.getCommand().split(" ")[0];
|
||||
@@ -122,8 +123,7 @@ public class CommandWhitelistVelocity {
|
||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
||||
if (s.getKey().equalsIgnoreCase("default"))
|
||||
suggestionList.addAll(s.getValue().getSubCommands());
|
||||
if (player.hasPermission("commandwhitelist.group." + s.getKey()))
|
||||
continue;
|
||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
||||
suggestionList.addAll(s.getValue().getSubCommands());
|
||||
}
|
||||
return suggestionList;
|
||||
|
||||
+8
-7
@@ -2,6 +2,7 @@ package eu.endermite.commandwhitelist.velocity.command;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -20,7 +21,7 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
String label = invocation.alias();
|
||||
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission("commandwhitelist.reload"), sender.hasPermission("commandwhitelist.admin")));
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,14 +29,14 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
|
||||
switch (commandType) {
|
||||
case RELOAD:
|
||||
if (!sender.hasPermission("commandwhitelist.reload")) {
|
||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||
return;
|
||||
}
|
||||
CommandWhitelistVelocity.reloadConfig(sender);
|
||||
return;
|
||||
case ADD:
|
||||
if (!sender.hasPermission("commandwhitelist.admin")) {
|
||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||
return;
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
sender.sendMessage(Component.text("/"+label+" add <group> <command>"));
|
||||
return;
|
||||
case REMOVE:
|
||||
if (!sender.hasPermission("commandwhitelist.admin")) {
|
||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||
return;
|
||||
}
|
||||
@@ -62,11 +63,11 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
return;
|
||||
case HELP:
|
||||
default:
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission("commandwhitelist.reload"), sender.hasPermission("commandwhitelist.admin")));
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission("commandwhitelist.reload"), sender.hasPermission("commandwhitelist.admin")));
|
||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
if (source.hasPermission("commandwhitelist.reload") && "reload".startsWith(args[0]))
|
||||
if (source.hasPermission(CWPermission.RELOAD.permission()) && "reload".startsWith(args[0]))
|
||||
suggestions.add("reload");
|
||||
}
|
||||
return suggestions;
|
||||
|
||||
Reference in New Issue
Block a user