mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-08-26 14:12:45 +02:00
Multiple fixes/improvements to command system
This commit is contained in:
parent
ebbc0511bf
commit
776ec45701
|
@ -12,7 +12,7 @@ class MainCommand extends Command {
|
|||
private final CommandManager manager;
|
||||
|
||||
public MainCommand(CommandManager manager) {
|
||||
super("luckpermsbungee", "luckperms.use", "bperms", "lpb", "bpermissions", "bp", "bperm");
|
||||
super("luckpermsbungee", null, "bperms", "lpb", "bpermissions", "bp", "bperm");
|
||||
this.manager = manager;
|
||||
|
||||
}
|
||||
|
|
|
@ -68,11 +68,9 @@ public class CommandManager {
|
|||
if (args.size() == 0) {
|
||||
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6.");
|
||||
|
||||
if (sender.hasPermission("luckperms.info")) {
|
||||
for (MainCommand c : mainCommands) {
|
||||
Util.sendPluginMessage(sender, "&e-> &d" + c.getUsage());
|
||||
}
|
||||
}
|
||||
mainCommands.stream()
|
||||
.filter(c -> c.canUse(sender))
|
||||
.forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + c.getUsage()));
|
||||
|
||||
} else {
|
||||
String c = args.get(0);
|
||||
|
|
|
@ -39,4 +39,13 @@ public abstract class MainCommand {
|
|||
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canUse(Sender sender) {
|
||||
for (SubCommand sc : getSubCommands()) {
|
||||
if (sc.isAuthorized(sender)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class SubCommand {
|
|||
}
|
||||
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.hasPermission(permission);
|
||||
return sender.hasPermission(permission) || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
|
||||
public void sendUsage(Sender sender) {
|
||||
|
|
|
@ -48,4 +48,9 @@ public class CreateGroupCommand extends MainCommand {
|
|||
public List<SubCommand> getSubCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.creategroup") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,4 +60,9 @@ public class DeleteGroupCommand extends MainCommand {
|
|||
public List<SubCommand> getSubCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.deletegroup") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@ public abstract class GroupSubCommand extends SubCommand {
|
|||
|
||||
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args);
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.hasPermission(getPermission()) || sender.hasPermission("luckperms.group.*") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
|
||||
protected void saveGroup(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||
plugin.getDatastore().saveGroup(group, success -> {
|
||||
if (success) {
|
||||
|
|
|
@ -32,6 +32,11 @@ public class ListGroupsCommand extends MainCommand {
|
|||
|
||||
@Override
|
||||
public List<SubCommand> getSubCommands() {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.listgroups") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,9 @@ public class DebugCommand extends MainCommand {
|
|||
public List<? extends SubCommand> getSubCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.debug") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,9 @@ public class InfoCommand extends MainCommand {
|
|||
public List<? extends SubCommand> getSubCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.info") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,9 @@ public class SyncCommand extends MainCommand {
|
|||
public List<? extends SubCommand> getSubCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canUse(Sender sender) {
|
||||
return sender.hasPermission("luckperms.sync") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@ public abstract class UserSubCommand extends SubCommand {
|
|||
|
||||
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args);
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.hasPermission(getPermission()) || sender.hasPermission("luckperms.user.*") || sender.hasPermission("luckperms.*");
|
||||
}
|
||||
|
||||
protected void saveUser(User user, Sender sender, LuckPermsPlugin plugin) {
|
||||
user.refreshPermissions();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user