mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-22 20:09:47 +00:00
Huge cleanup
This commit is contained in:
1 parent
0e449cdd7a
commit
84335afacd
43 files changed
+351
-378
No files matched your search
@@ -1,32 +1,29 @@
|
||||
package me.lucko.luckperms.commands;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public abstract class MainCommand {
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@Getter
|
||||
private final String usage;
|
||||
|
||||
@Getter
|
||||
private final int requiredArgsLength;
|
||||
|
||||
protected MainCommand(String name, String usage, int requiredArgsLength) {
|
||||
this.name = name;
|
||||
this.usage = usage;
|
||||
this.requiredArgsLength = requiredArgsLength;
|
||||
}
|
||||
|
||||
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, List<String> args);
|
||||
public abstract List<? extends SubCommand> getSubCommands();
|
||||
|
||||
protected void sendUsage(Sender sender) {
|
||||
if (getSubCommands().isEmpty()) {
|
||||
Util.sendPluginMessage(sender, "&e-> &d" + getUsage());
|
||||
return;
|
||||
}
|
||||
|
||||
List<SubCommand> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
|
||||
if (subs.size() > 0) {
|
||||
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
|
||||
@@ -41,11 +38,6 @@ public abstract class MainCommand {
|
||||
}
|
||||
|
||||
protected boolean canUse(Sender sender) {
|
||||
for (SubCommand sc : getSubCommands()) {
|
||||
if (sc.isAuthorized(sender)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user