mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Command refactor
This commit is contained in:
parent
1c534d7475
commit
158d8b086a
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class BaseCommand<T, S> extends Command<T, S> {
|
||||
|
||||
public BaseCommand(String name, String description, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args, List<Command<S, ?>> children) {
|
||||
super(name, description, permission, argumentCheck, args, children);
|
||||
}
|
||||
|
||||
public abstract String getUsage();
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class Command<T, S> {
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@Getter
|
||||
private final String description;
|
||||
|
||||
// Could be null
|
||||
private final Permission permission;
|
||||
|
||||
@Getter
|
||||
private final Predicate<Integer> argumentCheck;
|
||||
|
||||
// Could be null
|
||||
private final List<Arg> args;
|
||||
|
||||
// Could be null
|
||||
private final List<Command<S, ?>> children;
|
||||
|
||||
public Command(String name, String description, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args, List<Command<S, ?>> children) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.permission = permission;
|
||||
this.argumentCheck = argumentCheck;
|
||||
this.args = args == null ? null : ImmutableList.copyOf(args);
|
||||
this.children = children == null ? null : ImmutableList.copyOf(children);
|
||||
}
|
||||
|
||||
public Command(String name, String description, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args) {
|
||||
this(name, description, permission, argumentCheck, args, null);
|
||||
}
|
||||
|
||||
public Command(String name, String description, Predicate<Integer> argumentCheck) {
|
||||
this(name, description, null, argumentCheck, null, null);
|
||||
}
|
||||
|
||||
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) throws CommandException;
|
||||
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract void sendUsage(Sender sender, String label);
|
||||
public abstract void sendDetailedUsage(Sender sender, String label);
|
||||
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return permission == null || permission.isAuthorized(sender);
|
||||
}
|
||||
|
||||
public Optional<Permission> getPermission() {
|
||||
return Optional.ofNullable(permission);
|
||||
}
|
||||
|
||||
public Optional<List<Arg>> getArgs() {
|
||||
return Optional.ofNullable(args);
|
||||
}
|
||||
|
||||
public Optional<List<Command<S, ?>>> getChildren() {
|
||||
return Optional.ofNullable(children);
|
||||
}
|
||||
|
||||
}
|
@ -40,6 +40,7 @@ import me.lucko.luckperms.common.commands.track.ListTracks;
|
||||
import me.lucko.luckperms.common.commands.track.TrackMainCommand;
|
||||
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
||||
import me.lucko.luckperms.common.commands.usersbulkedit.UsersBulkEditMainCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -53,7 +54,7 @@ public class CommandManager {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
@Getter
|
||||
private final List<MainCommand> mainCommands = ImmutableList.<MainCommand>builder()
|
||||
private final List<BaseCommand> mainCommands = ImmutableList.<BaseCommand>builder()
|
||||
.add(new UserMainCommand())
|
||||
.add(new GroupMainCommand())
|
||||
.add(new TrackMainCommand())
|
||||
@ -76,7 +77,6 @@ public class CommandManager {
|
||||
.add(new ListTracks())
|
||||
.build();
|
||||
|
||||
|
||||
/**
|
||||
* Generic on command method to be called from the command executor object of the platform
|
||||
* Unlike {@link #onCommand(Sender, String, List)}, this method is called in a new thread
|
||||
@ -99,13 +99,14 @@ public class CommandManager {
|
||||
* @param args the arguments provided
|
||||
* @return if the command was successful
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommandResult onCommand(Sender sender, String label, List<String> args) {
|
||||
if (args.size() == 0) {
|
||||
sendCommandUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Optional<MainCommand> o = mainCommands.stream()
|
||||
Optional<BaseCommand> o = mainCommands.stream()
|
||||
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -115,35 +116,70 @@ public class CommandManager {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final MainCommand main = o.get();
|
||||
final Command main = o.get();
|
||||
if (!main.isAuthorized(sender)) {
|
||||
sendCommandUsage(sender, label);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
if (main.getRequiredArgsLength() == 0) {
|
||||
try {
|
||||
return main.execute(plugin, sender, null, label);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
List<String> arguments = new ArrayList<>(args);
|
||||
handleRewrites(arguments);
|
||||
arguments.remove(0); // remove the first command part.
|
||||
|
||||
if (args.size() == 1) {
|
||||
if (main.getArgumentCheck().test(arguments.size())) {
|
||||
main.sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
List<String> arguments = new ArrayList<>(args);
|
||||
handleRewrites(arguments);
|
||||
|
||||
CommandResult result;
|
||||
try {
|
||||
return main.execute(plugin, sender, arguments.subList(1, arguments.size()), label);
|
||||
result = main.execute(plugin, sender, null, arguments, label);
|
||||
} catch (CommandException e) {
|
||||
result = handleException(e, sender, label, main);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return CommandResult.FAILURE;
|
||||
result = CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static CommandResult handleException(CommandException e, Sender sender, String label, Command command) {
|
||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||
command.sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.UseInheritException) {
|
||||
Message.USE_INHERIT_COMMAND.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidServerException) {
|
||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.PastDateException) {
|
||||
Message.PAST_DATE_ERROR.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
}
|
||||
|
||||
// Not something we can catch.
|
||||
e.printStackTrace();
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +190,7 @@ public class CommandManager {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> onTabComplete(Sender sender, List<String> args) {
|
||||
final List<MainCommand> mains = mainCommands.stream()
|
||||
final List<Command> mains = mainCommands.stream()
|
||||
.filter(m -> m.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -171,7 +207,7 @@ public class CommandManager {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<MainCommand> o = mains.stream()
|
||||
Optional<Command> o = mains.stream()
|
||||
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -180,7 +216,7 @@ public class CommandManager {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return o.get().onTabComplete(sender, args.subList(1, args.size()), plugin);
|
||||
return o.get().tabComplete(plugin, sender, args.subList(1, args.size()));
|
||||
}
|
||||
|
||||
private void sendCommandUsage(Sender sender, String label) {
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -34,50 +34,27 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public abstract class MainCommand<T> {
|
||||
public abstract class MainCommand<T> extends BaseCommand<Void, T> {
|
||||
|
||||
/**
|
||||
* The name of the main command
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The command usage
|
||||
*/
|
||||
private final String usage;
|
||||
|
||||
/**
|
||||
* How many arguments are required for the command to run
|
||||
*/
|
||||
private final int requiredArgsLength;
|
||||
|
||||
/**
|
||||
* A list of the sub commands under this main command
|
||||
*/
|
||||
@Getter
|
||||
private final List<SubCommand<T>> subCommands;
|
||||
private final String usage;
|
||||
private final int minArgs; // equals 1 if the command doesn't take a mid argument, e.g. /lp user <USER> sub-command....
|
||||
|
||||
MainCommand(String name, String usage, int requiredArgsLength) {
|
||||
this(name, usage, requiredArgsLength, ImmutableList.of());
|
||||
public MainCommand(String name, String description, String usage, int minArgs, @NonNull List<Command<T, ?>> children) {
|
||||
super(name, description, null, Predicates.alwaysFalse(), null, children);
|
||||
this.usage = usage;
|
||||
this.minArgs = minArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this main command is ran
|
||||
* @param plugin a link to the main plugin instance
|
||||
* @param sender the sender to executed the command
|
||||
* @param args the stripped arguments given
|
||||
* @param label the command label used
|
||||
*/
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() < requiredArgsLength) {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) throws CommandException {
|
||||
if (args.size() < minArgs) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Optional<SubCommand<T>> o = getSubCommands().stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(requiredArgsLength - 1)))
|
||||
Optional<Command<T, ?>> o = getSubCommands().stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(minArgs - 1)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
|
||||
@ -86,19 +63,19 @@ public abstract class MainCommand<T> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final SubCommand<T> sub = o.get();
|
||||
final Command<T, ?> sub = o.get();
|
||||
if (!sub.isAuthorized(sender)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
List<String> strippedArgs = new ArrayList<>();
|
||||
if (args.size() > requiredArgsLength) {
|
||||
strippedArgs.addAll(args.subList(requiredArgsLength, args.size()));
|
||||
if (args.size() > minArgs) {
|
||||
strippedArgs.addAll(args.subList(minArgs, args.size()));
|
||||
}
|
||||
|
||||
if (sub.getIsArgumentInvalid().test(strippedArgs.size())) {
|
||||
sub.sendDetailedUsage(sender);
|
||||
if (sub.getArgumentCheck().test(strippedArgs.size())) {
|
||||
sub.sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
@ -106,11 +83,13 @@ public abstract class MainCommand<T> {
|
||||
T t = getTarget(name, plugin, sender);
|
||||
if (t != null) {
|
||||
CommandResult result;
|
||||
|
||||
try {
|
||||
result = sub.execute(plugin, sender, t, strippedArgs, label);
|
||||
} catch (CommandException e) {
|
||||
result = handleException(e, sender, sub);
|
||||
result = CommandManager.handleException(e, sender, label, sub);
|
||||
}
|
||||
|
||||
cleanup(t, plugin);
|
||||
return result;
|
||||
}
|
||||
@ -118,99 +97,9 @@ public abstract class MainCommand<T> {
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
private static CommandResult handleException(CommandException e, Sender sender, SubCommand command) {
|
||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||
command.sendDetailedUsage(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.UseInheritException) {
|
||||
Message.USE_INHERIT_COMMAND.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidServerException) {
|
||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.PastDateException) {
|
||||
Message.PAST_DATE_ERROR.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
}
|
||||
|
||||
// Not something we can catch.
|
||||
e.printStackTrace();
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object the command is acting upon, and runs the callback if successful
|
||||
* @param target the name of the object to be looked up
|
||||
* @param plugin a link to the main plugin instance
|
||||
* @param sender the user who send the command (used to send error messages if the lookup was unsuccessful)
|
||||
*/
|
||||
protected abstract T getTarget(String target, LuckPermsPlugin plugin, Sender sender);
|
||||
|
||||
protected abstract void cleanup(T t, LuckPermsPlugin plugin);
|
||||
|
||||
/**
|
||||
* Get a list of {@link T} objects for tab completion
|
||||
* @param plugin a link to the main plugin instance
|
||||
* @return a list of strings
|
||||
*/
|
||||
protected abstract List<String> getObjects(LuckPermsPlugin plugin);
|
||||
|
||||
/**
|
||||
* Send the command usage to a sender
|
||||
* @param sender the sender to send the usage to
|
||||
* @param label the command label used
|
||||
*/
|
||||
protected void sendUsage(Sender sender, String label) {
|
||||
if (getSubCommands().isEmpty()) {
|
||||
Util.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
|
||||
return;
|
||||
}
|
||||
|
||||
List<SubCommand> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (subs.size() > 0) {
|
||||
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)");
|
||||
|
||||
for (SubCommand s : subs) {
|
||||
s.sendUsage(sender);
|
||||
}
|
||||
|
||||
} else {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a sender has permission to use this command
|
||||
* @param sender the sender trying to use the command
|
||||
* @return true if the sender can use the command
|
||||
*/
|
||||
protected boolean isAuthorized(Sender sender) {
|
||||
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
|
||||
}
|
||||
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
final List<String> objects = getObjects(plugin);
|
||||
@Override
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<String> objects = getTargets(plugin);
|
||||
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||
@ -222,7 +111,7 @@ public abstract class MainCommand<T> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
final List<SubCommand<T>> subs = getSubCommands().stream()
|
||||
final List<Command<T, ?>> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -239,7 +128,7 @@ public abstract class MainCommand<T> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SubCommand<T>> o = subs.stream()
|
||||
Optional<Command<T, ?>> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -248,6 +137,56 @@ public abstract class MainCommand<T> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return o.get().onTabComplete(plugin, sender, args.subList(2, args.size()));
|
||||
return o.get().tabComplete(plugin, sender, args.subList(2, args.size()));
|
||||
}
|
||||
|
||||
protected abstract List<String> getTargets(LuckPermsPlugin plugin);
|
||||
protected abstract T getTarget(String target, LuckPermsPlugin plugin, Sender sender);
|
||||
protected abstract void cleanup(T t, LuckPermsPlugin plugin);
|
||||
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
/*
|
||||
if (getSubCommands().isEmpty()) {
|
||||
Util.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
|
||||
return;
|
||||
*/
|
||||
|
||||
List<Command> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (subs.size() > 0) {
|
||||
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(usage, label) + " ...)");
|
||||
|
||||
for (Command s : subs) {
|
||||
s.sendUsage(sender, label);
|
||||
}
|
||||
|
||||
} else {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Optional<List<Command<T, ?>>> getChildren() {
|
||||
return super.getChildren();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<Command<T, ?>> getSubCommands() {
|
||||
return getChildren().get();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class SingleCommand extends BaseCommand<Void, Void> {
|
||||
|
||||
@Getter
|
||||
private final String usage;
|
||||
|
||||
public SingleCommand(String name, String description, String usage, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args) {
|
||||
super(name, description, permission, argumentCheck, args, null);
|
||||
this.usage = usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) throws CommandException {
|
||||
return execute(plugin, sender, args, label);
|
||||
}
|
||||
|
||||
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) throws CommandException;
|
||||
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
String usage = "";
|
||||
if (getArgs().isPresent()) {
|
||||
usage += "&3 - &7";
|
||||
for (Arg arg : getArgs().get()) {
|
||||
usage += arg.asPrettyString() + " ";
|
||||
}
|
||||
}
|
||||
|
||||
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (getArgs().isPresent()) {
|
||||
Util.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Arg arg : getArgs().get()) {
|
||||
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An extension of {@link MainCommand} for implementations without any subcommands
|
||||
*/
|
||||
public class SingleMainCommand extends MainCommand<Object> {
|
||||
private final Permission permission;
|
||||
|
||||
public SingleMainCommand(String name, String usage, int requiredArgsLength, Permission permission) {
|
||||
super(name, usage, requiredArgsLength);
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
// Do nothing, allow the implementation to override this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Object o, LuckPermsPlugin plugin) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubCommand<Object>> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthorized(Sender sender) {
|
||||
return permission.isAuthorized(sender);
|
||||
}
|
||||
}
|
@ -22,8 +22,6 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
@ -43,62 +41,22 @@ import java.util.stream.Collectors;
|
||||
* Abstract SubCommand class
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public abstract class SubCommand<T> {
|
||||
public abstract class SubCommand<T> extends Command<T, Void> {
|
||||
|
||||
/**
|
||||
* The name of the sub command
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* A brief description of what the sub command does
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* The permission needed to use this command
|
||||
*/
|
||||
private final Permission permission;
|
||||
|
||||
/**
|
||||
* Predicate to test if the argument length given is invalid
|
||||
*/
|
||||
private final Predicate<? super Integer> isArgumentInvalid;
|
||||
|
||||
private final ImmutableList<Arg> args;
|
||||
|
||||
/**
|
||||
* Called when this sub command is ran
|
||||
* @param plugin a link to the main plugin instance
|
||||
* @param sender the sender to executed the command
|
||||
* @param t the object the command is operating on
|
||||
* @param args the stripped arguments given
|
||||
* @param label the command label used
|
||||
*/
|
||||
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) throws CommandException;
|
||||
|
||||
/**
|
||||
* Returns a list of suggestions, which are empty by default. Sub classes that give tab complete suggestions override
|
||||
* this method to give their own list.
|
||||
* @param plugin the plugin instance
|
||||
* @param sender who is tab completing
|
||||
* @param args the arguments so far
|
||||
* @return a list of suggestions
|
||||
*/
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return Collections.emptyList();
|
||||
public SubCommand(String name, String description, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args) {
|
||||
super(name, description, permission, argumentCheck, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the command usage to a sender
|
||||
* @param sender the sender to send the usage to
|
||||
*/
|
||||
public void sendUsage(Sender sender) {
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
String usage = "";
|
||||
if (args != null) {
|
||||
if (getArgs().isPresent()) {
|
||||
usage += "&3 - &7";
|
||||
for (Arg arg : args) {
|
||||
for (Arg arg : getArgs().get()) {
|
||||
usage += arg.asPrettyString() + " ";
|
||||
}
|
||||
}
|
||||
@ -106,30 +64,22 @@ public abstract class SubCommand<T> {
|
||||
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage);
|
||||
}
|
||||
|
||||
public void sendDetailedUsage(Sender sender) {
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (args != null) {
|
||||
if (getArgs().isPresent()) {
|
||||
Util.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Arg arg : args) {
|
||||
for (Arg arg : getArgs().get()) {
|
||||
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a sender has permission to use this command
|
||||
* @param sender the sender trying to use the command
|
||||
* @return true if the sender can use the command
|
||||
*/
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return permission.isAuthorized(sender);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------------
|
||||
* Utility methods used by #onTabComplete and #execute implementations in sub classes
|
||||
* Utility methods used by #tabComplete and #execute implementations in sub classes
|
||||
* ----------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
@ -34,11 +34,11 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand<T> {
|
||||
public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T> {
|
||||
private boolean user;
|
||||
private final List<SecondarySubCommand> secondaryCommands;
|
||||
private final List<SharedSubCommand> secondaryCommands;
|
||||
|
||||
public SecondaryMainCommand(String name, String description, boolean user, List<SecondarySubCommand> secondaryCommands) {
|
||||
public SharedMainCommand(String name, String description, boolean user, List<SharedSubCommand> secondaryCommands) {
|
||||
super(name, description, null, Predicates.alwaysFalse(), null);
|
||||
this.secondaryCommands = secondaryCommands;
|
||||
this.user = user;
|
||||
@ -51,7 +51,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Optional<SecondarySubCommand> o = secondaryCommands.stream()
|
||||
Optional<SharedSubCommand> o = secondaryCommands.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -61,7 +61,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final SecondarySubCommand sub = o.get();
|
||||
final SharedSubCommand sub = o.get();
|
||||
if (!sub.isAuthorized(sender, user)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
@ -86,7 +86,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
return result;
|
||||
}
|
||||
|
||||
private static CommandResult handleException(CommandException e, Sender sender, SecondarySubCommand command) {
|
||||
private static CommandResult handleException(CommandException e, Sender sender, SharedSubCommand command) {
|
||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||
command.sendDetailedUsage(sender);
|
||||
@ -125,8 +125,8 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<SecondarySubCommand> subs = secondaryCommands.stream()
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<SharedSubCommand> subs = secondaryCommands.stream()
|
||||
.filter(s -> s.isAuthorized(sender, user))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -143,7 +143,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SecondarySubCommand> o = subs.stream()
|
||||
Optional<SharedSubCommand> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -157,7 +157,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
for (SecondarySubCommand subCommand : secondaryCommands) {
|
||||
for (SharedSubCommand subCommand : secondaryCommands) {
|
||||
if (subCommand.isAuthorized(sender, user)) {
|
||||
return true;
|
||||
}
|
||||
@ -166,7 +166,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
}
|
||||
|
||||
private void sendUsageDetailed(Sender sender, boolean user, String label) {
|
||||
List<SecondarySubCommand> subs = secondaryCommands.stream()
|
||||
List<SharedSubCommand> subs = secondaryCommands.stream()
|
||||
.filter(s -> s.isAuthorized(sender, user))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -177,7 +177,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
||||
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
|
||||
}
|
||||
|
||||
for (SecondarySubCommand s : subs) {
|
||||
for (SharedSubCommand s : subs) {
|
||||
s.sendUsage(sender);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import java.util.function.Predicate;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public abstract class SecondarySubCommand {
|
||||
public abstract class SharedSubCommand {
|
||||
|
||||
/**
|
||||
* The name of the sub command
|
@ -23,13 +23,13 @@
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
|
||||
public class CommandMeta<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public class CommandMeta<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandMeta(boolean user) {
|
||||
super("Meta", "Edit metadata values", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
super("Meta", "Edit metadata values", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new MetaInfo())
|
||||
.add(new MetaSet())
|
||||
.add(new MetaUnset())
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -36,7 +36,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaAddPrefix extends SecondarySubCommand {
|
||||
public class MetaAddPrefix extends SharedSubCommand {
|
||||
public MetaAddPrefix() {
|
||||
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX,
|
||||
Predicates.notInRange(2, 4),
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -36,7 +36,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaAddSuffix extends SecondarySubCommand {
|
||||
public class MetaAddSuffix extends SharedSubCommand {
|
||||
public MetaAddSuffix() {
|
||||
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX,
|
||||
Predicates.notInRange(2, 4),
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaAddTempPrefix extends SecondarySubCommand {
|
||||
public class MetaAddTempPrefix extends SharedSubCommand {
|
||||
public MetaAddTempPrefix() {
|
||||
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX,
|
||||
Permission.GROUP_META_ADDTEMP_PREFIX, Predicates.notInRange(3, 5),
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaAddTempSuffix extends SecondarySubCommand {
|
||||
public class MetaAddTempSuffix extends SharedSubCommand {
|
||||
public MetaAddTempSuffix() {
|
||||
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX,
|
||||
Permission.GROUP_META_ADDTEMP_SUFFIX, Predicates.notInRange(3, 5),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -34,7 +34,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaClear extends SecondarySubCommand {
|
||||
public class MetaClear extends SharedSubCommand {
|
||||
public MetaClear() {
|
||||
super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.notInRange(0, 2),
|
||||
Arg.list(
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MetaInfo extends SecondarySubCommand {
|
||||
public class MetaInfo extends SharedSubCommand {
|
||||
public MetaInfo() {
|
||||
super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaRemovePrefix extends SecondarySubCommand {
|
||||
public class MetaRemovePrefix extends SharedSubCommand {
|
||||
public MetaRemovePrefix() {
|
||||
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
||||
Predicates.notInRange(2, 4),
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaRemoveSuffix extends SecondarySubCommand {
|
||||
public class MetaRemoveSuffix extends SharedSubCommand {
|
||||
public MetaRemoveSuffix() {
|
||||
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
||||
Predicates.notInRange(2, 4),
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
||||
public class MetaRemoveTempPrefix extends SharedSubCommand {
|
||||
public MetaRemoveTempPrefix() {
|
||||
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicates.notInRange(2, 4),
|
||||
Arg.list(
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
||||
public class MetaRemoveTempSuffix extends SharedSubCommand {
|
||||
public MetaRemoveTempSuffix() {
|
||||
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicates.notInRange(2, 4),
|
||||
Arg.list(
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||
@ -38,7 +38,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaSet extends SecondarySubCommand {
|
||||
public class MetaSet extends SharedSubCommand {
|
||||
public MetaSet() {
|
||||
super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.notInRange(2, 4),
|
||||
Arg.list(
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||
@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaSetTemp extends SecondarySubCommand {
|
||||
public class MetaSetTemp extends SharedSubCommand {
|
||||
public MetaSetTemp() {
|
||||
super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.notInRange(3, 5),
|
||||
Arg.list(
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaUnset extends SecondarySubCommand {
|
||||
public class MetaUnset extends SharedSubCommand {
|
||||
public MetaUnset() {
|
||||
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET,
|
||||
Predicates.notInRange(1, 3),
|
||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaUnsetTemp extends SecondarySubCommand {
|
||||
public class MetaUnsetTemp extends SharedSubCommand {
|
||||
public MetaUnsetTemp() {
|
||||
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP,
|
||||
Predicates.notInRange(1, 3),
|
||||
|
@ -23,13 +23,13 @@
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
|
||||
public class CommandParent<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public class CommandParent<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandParent(boolean user) {
|
||||
super("Parent", "Edit inheritances", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
super("Parent", "Edit inheritances", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new ParentInfo())
|
||||
.add(new ParentSet())
|
||||
.add(new ParentAdd())
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||
|
||||
public class ParentAdd extends SecondarySubCommand {
|
||||
public class ParentAdd extends SharedSubCommand {
|
||||
public ParentAdd() {
|
||||
super("add", "Sets another group for the object to inherit permissions from", Permission.USER_PARENT_ADD,
|
||||
Permission.GROUP_PARENT_ADD, Predicates.notInRange(1, 3),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||
|
||||
public class ParentAddTemp extends SecondarySubCommand {
|
||||
public class ParentAddTemp extends SharedSubCommand {
|
||||
public ParentAddTemp() {
|
||||
super("addtemp", "Sets another group for the object to inherit permissions from temporarily",
|
||||
Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicates.notInRange(2, 4),
|
||||
|
@ -27,7 +27,7 @@ import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParentInfo extends SecondarySubCommand {
|
||||
public class ParentInfo extends SharedSubCommand {
|
||||
public ParentInfo() {
|
||||
super("info", "Lists the groups that this object inherits from",
|
||||
Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicates.alwaysFalse(), null);
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||
|
||||
public class ParentRemove extends SecondarySubCommand {
|
||||
public class ParentRemove extends SharedSubCommand {
|
||||
public ParentRemove() {
|
||||
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE,
|
||||
Permission.GROUP_PARENT_REMOVE, Predicates.notInRange(1, 3),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||
|
||||
public class ParentRemoveTemp extends SecondarySubCommand {
|
||||
public class ParentRemoveTemp extends SharedSubCommand {
|
||||
public ParentRemoveTemp() {
|
||||
super("removetemp", "Removes a previously set temporary inheritance rule",
|
||||
Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicates.notInRange(1, 3),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||
|
||||
public class ParentSet extends SecondarySubCommand {
|
||||
public class ParentSet extends SharedSubCommand {
|
||||
public ParentSet() {
|
||||
super("set", "Removes all other groups the object inherits already and adds them to the one given",
|
||||
Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicates.notInRange(1, 3),
|
||||
|
@ -23,13 +23,13 @@
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
|
||||
public class CommandPermission<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public class CommandPermission<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandPermission(boolean user) {
|
||||
super("Permission", "Edit permissions", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
super("Permission", "Edit permissions", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new PermissionInfo())
|
||||
.add(new PermissionSet())
|
||||
.add(new PermissionUnset())
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionCheck extends SecondarySubCommand {
|
||||
public class PermissionCheck extends SharedSubCommand {
|
||||
public PermissionCheck() {
|
||||
super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK,
|
||||
Permission.GROUP_PERM_CHECK, Predicates.notInRange(1, 3),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.InheritanceInfo;
|
||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||
@ -33,7 +33,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionCheckInherits extends SecondarySubCommand {
|
||||
public class PermissionCheckInherits extends SharedSubCommand {
|
||||
public PermissionCheckInherits() {
|
||||
super("checkinherits", "Checks to see if the object inherits a certain permission node",
|
||||
Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS, Predicates.notInRange(1, 3),
|
||||
|
@ -27,7 +27,7 @@ import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionInfo extends SecondarySubCommand {
|
||||
public class PermissionInfo extends SharedSubCommand {
|
||||
public PermissionInfo() {
|
||||
super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||
|
||||
public class PermissionSet extends SecondarySubCommand {
|
||||
public class PermissionSet extends SharedSubCommand {
|
||||
public PermissionSet() {
|
||||
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
||||
Predicates.notInRange(2, 4),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||
|
||||
public class PermissionSetTemp extends SecondarySubCommand {
|
||||
public class PermissionSetTemp extends SharedSubCommand {
|
||||
public PermissionSetTemp() {
|
||||
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
||||
Permission.GROUP_PERM_SETTEMP, Predicates.notInRange(3, 5),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionUnset extends SecondarySubCommand {
|
||||
public class PermissionUnset extends SharedSubCommand {
|
||||
public PermissionUnset() {
|
||||
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET,
|
||||
Predicates.notInRange(1, 3),
|
||||
|
@ -24,7 +24,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionUnsetTemp extends SecondarySubCommand {
|
||||
public class PermissionUnsetTemp extends SharedSubCommand {
|
||||
public PermissionUnsetTemp() {
|
||||
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP,
|
||||
Permission.GROUP_PERM_UNSETTEMP, Predicates.notInRange(1, 3),
|
||||
|
@ -23,23 +23,29 @@
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGroup extends SingleMainCommand {
|
||||
public class CreateGroup extends SingleCommand {
|
||||
public CreateGroup() {
|
||||
super("CreateGroup", "/%s creategroup <group>", 1, Permission.CREATE_GROUP);
|
||||
super("CreateGroup", "Create a new group", "/%s creategroup <group>", Permission.CREATE_GROUP, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("name", true, "the name of the group")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
|
@ -23,26 +23,32 @@
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.groups.Group;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DeleteGroup extends SingleMainCommand {
|
||||
public class DeleteGroup extends SingleCommand {
|
||||
public DeleteGroup() {
|
||||
super("DeleteGroup", "/%s deletegroup <group>", 1, Permission.DELETE_GROUP);
|
||||
super("DeleteGroup", "Delete a group", "/%s deletegroup <group>", Permission.DELETE_GROUP, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("name", true, "the name of the group")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
@ -78,7 +84,7 @@ public class DeleteGroup extends SingleMainCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<String> groups = new ArrayList<>(plugin.getGroupManager().getAll().keySet());
|
||||
|
||||
if (args.size() <= 1) {
|
||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Command;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.meta.CommandMeta;
|
||||
import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks;
|
||||
import me.lucko.luckperms.common.commands.generic.parent.CommandParent;
|
||||
@ -40,7 +40,7 @@ import java.util.List;
|
||||
|
||||
public class GroupMainCommand extends MainCommand<Group> {
|
||||
public GroupMainCommand() {
|
||||
super("Group", "/%s group <group>", 2, ImmutableList.<SubCommand<Group>>builder()
|
||||
super("Group", "Group commands", "/%s group <group>", 2, ImmutableList.<Command<Group, ?>>builder()
|
||||
.add(new GroupInfo())
|
||||
.add(new CommandPermission<>(false))
|
||||
.add(new CommandParent<>(false))
|
||||
@ -76,7 +76,7 @@ public class GroupMainCommand extends MainCommand<Group> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return new ArrayList<>(plugin.getGroupManager().getAll().keySet());
|
||||
}
|
||||
}
|
||||
|
@ -25,23 +25,24 @@ package me.lucko.luckperms.common.commands.group;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.groups.Group;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListGroups extends SingleMainCommand {
|
||||
public class ListGroups extends SingleCommand {
|
||||
public ListGroups() {
|
||||
super("ListGroups", "/%s listgroups", 0, Permission.LIST_GROUPS);
|
||||
super("ListGroups", "List all groups on the platform", "/%s listgroups", Permission.LIST_GROUPS, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (!plugin.getDatastore().loadAllGroups().getUnchecked()) {
|
||||
Message.GROUPS_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Command;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.log.subcommands.*;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.data.Log;
|
||||
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class LogMainCommand extends MainCommand<Log> {
|
||||
public LogMainCommand() {
|
||||
super("Log", "/%s log", 1, ImmutableList.<SubCommand<Log>>builder()
|
||||
super("Log", "Log commands", "/%s log", 1, ImmutableList.<Command<Log, ?>>builder()
|
||||
.add(new LogRecent())
|
||||
.add(new LogSearch())
|
||||
.add(new LogNotify())
|
||||
@ -67,13 +67,13 @@ public class LogMainCommand extends MainCommand<Log> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
final List<SubCommand<Log>> subs = getSubCommands().stream()
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<Command<Log, ?>> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -90,7 +90,7 @@ public class LogMainCommand extends MainCommand<Log> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SubCommand<Log>> o = subs.stream()
|
||||
Optional<Command<Log, ?>> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -99,6 +99,6 @@ public class LogMainCommand extends MainCommand<Log> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return o.get().onTabComplete(plugin, sender, args.subList(1, args.size()));
|
||||
return o.get().tabComplete(plugin, sender, args.subList(1, args.size()));
|
||||
}
|
||||
}
|
||||
|
@ -22,98 +22,91 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.migration;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MigrationMainCommand extends MainCommand<Object> {
|
||||
private final List<SubCommand<Object>> subCommands = new ArrayList<>();
|
||||
|
||||
public MigrationMainCommand() {
|
||||
super("Migration", "/%s migration", 1, null);
|
||||
super("Migration", "Migration commands", "/%s migration", 1, ImmutableList.copyOf(getAvailableCommands()));
|
||||
}
|
||||
|
||||
private static List<Command<Object, ?>> getAvailableCommands() {
|
||||
List<SubCommand<Object>> l = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Class.forName("org.anjocaido.groupmanager.GroupManager");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationGroupManager").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationGroupManager").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("ru.tehkode.permissions.bukkit.PermissionsEx");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPermissionsEx").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPermissionsEx").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("com.github.cheesesoftware.PowerfulPermsAPI.PowerfulPermsPlugin");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPowerfulPerms").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPowerfulPerms").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationZPermissions").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationZPermissions").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("net.alpenblock.bungeeperms.BungeePerms");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bungee.migration.MigrationBungeePerms").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bungee.migration.MigrationBungeePerms").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("de.bananaco.bpermissions.api.WorldManager");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationBPermissions").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationBPermissions").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
try {
|
||||
Class.forName("ninja.leaping.permissionsex.sponge.PermissionsExPlugin");
|
||||
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.sponge.migration.MigrationPermissionsEx").newInstance());
|
||||
l.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.sponge.migration.MigrationPermissionsEx").newInstance());
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
return l.stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubCommand<Object>> getSubCommands() {
|
||||
return subCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthorized(Sender sender) {
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) throws CommandException {
|
||||
if (!sender.getUuid().equals(Constants.getConsoleUUID())) {
|
||||
Message.MIGRATION_NOT_CONSOLE.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
return super.execute(plugin, sender, args, label);
|
||||
return super.execute(plugin, sender, v, args, label);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Object object, LuckPermsPlugin plugin) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
return Collections.emptyList();
|
||||
protected Void getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Object o, LuckPermsPlugin plugin) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,19 +25,20 @@ package me.lucko.luckperms.common.commands.misc;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DebugCommand extends SingleMainCommand {
|
||||
public class DebugCommand extends SingleCommand {
|
||||
public DebugCommand() {
|
||||
super("Debug", "/%s debug", 0, Permission.DEBUG);
|
||||
super("Debug", "Print debugging output", "/%s debug", Permission.DEBUG, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
plugin.getLog().info(sender.getName() + " used the debug command.");
|
||||
Message.DEBUG.send(sender,
|
||||
plugin.getPlayerCount(),
|
||||
|
@ -25,9 +25,10 @@ package me.lucko.luckperms.common.commands.misc;
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
@ -35,6 +36,7 @@ import me.lucko.luckperms.common.groups.Group;
|
||||
import me.lucko.luckperms.common.storage.Datastore;
|
||||
import me.lucko.luckperms.common.tracks.Track;
|
||||
import me.lucko.luckperms.common.users.User;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@ -45,13 +47,17 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExportCommand extends SingleMainCommand {
|
||||
public class ExportCommand extends SingleCommand {
|
||||
public ExportCommand() {
|
||||
super("Export", "/%s export <file>", 1, Permission.MIGRATION);
|
||||
super("Export", "Export data to a file", "/%s export <file>", Permission.MIGRATION, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("file", true, "the file to export to")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
final Logger log = plugin.getLog();
|
||||
|
||||
if (!sender.getUuid().equals(Constants.getConsoleUUID())) {
|
||||
@ -164,7 +170,7 @@ public class ExportCommand extends SingleMainCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthorized(Sender sender) {
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,14 @@
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.data.Importer;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -36,13 +38,17 @@ import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportCommand extends SingleMainCommand {
|
||||
public class ImportCommand extends SingleCommand {
|
||||
public ImportCommand() {
|
||||
super("Import", "/%s import <file>", 1, Permission.IMPORT);
|
||||
super("Import", "Import data from a file", "/%s import <file>", Permission.IMPORT, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("file", true, "the file to import from")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
|
@ -25,22 +25,23 @@ package me.lucko.luckperms.common.commands.misc;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.Util.formatBoolean;
|
||||
|
||||
public class InfoCommand extends SingleMainCommand {
|
||||
public class InfoCommand extends SingleCommand {
|
||||
public InfoCommand() {
|
||||
super("Info", "/%s info", 0, Permission.INFO);
|
||||
super("Info", "Print general plugin info", "/%s info", Permission.INFO, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
final LPConfiguration c = plugin.getConfiguration();
|
||||
Message.INFO.send(sender,
|
||||
plugin.getVersion(),
|
||||
|
@ -25,19 +25,21 @@ package me.lucko.luckperms.common.commands.misc;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetworkSyncCommand extends SingleMainCommand {
|
||||
public class NetworkSyncCommand extends SingleCommand {
|
||||
public NetworkSyncCommand() {
|
||||
super("NetworkSync", "/%s networksync", 0, Permission.SYNC);
|
||||
super("NetworkSync", "Sync changes with the storage and request that all other servers on the network do the same",
|
||||
"/%s networksync", Permission.SYNC, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
||||
Message.UPDATE_TASK_COMPLETE_NETWORK.send(sender);
|
||||
|
@ -23,22 +23,24 @@
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QueueCommand extends SingleMainCommand {
|
||||
public class QueueCommand extends SingleCommand {
|
||||
public QueueCommand() {
|
||||
super("QueueCommand", "/%s queuecommand <command args...>", 1, Permission.MIGRATION);
|
||||
super("QueueCommand", "Queue a command for execution", "/%s queuecommand <command args...>", Permission.MIGRATION, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("command args...", true, "the command's arguments")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.get(0).equalsIgnoreCase(getName())) {
|
||||
// Prevent infinite loops
|
||||
return CommandResult.FAILURE;
|
||||
@ -49,7 +51,7 @@ public class QueueCommand extends SingleMainCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthorized(Sender sender) {
|
||||
public boolean isAuthorized(Sender sender) {
|
||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||
}
|
||||
}
|
||||
|
@ -25,19 +25,20 @@ package me.lucko.luckperms.common.commands.misc;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SyncCommand extends SingleMainCommand {
|
||||
public class SyncCommand extends SingleCommand {
|
||||
public SyncCommand() {
|
||||
super("Sync", "/%s sync", 0, Permission.SYNC);
|
||||
super("Sync", "Sync changes with the storage", "/%s sync", Permission.SYNC, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
||||
Message.UPDATE_TASK_COMPLETE.send(sender);
|
||||
|
@ -23,23 +23,30 @@
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class VerboseCommand extends SingleMainCommand {
|
||||
public class VerboseCommand extends SingleCommand {
|
||||
public VerboseCommand() {
|
||||
super("Verbose", "/%s verbose <true|false> [filters...]", 1, Permission.VERBOSE);
|
||||
super("Verbose", "Enable verbose permission check output", "/%s verbose <true|false> [filters...]", Permission.VERBOSE, Predicates.is(0),
|
||||
Arg.list(
|
||||
Arg.create("true|false", true, "whether to enable the feature"),
|
||||
Arg.create("filters...", false, "the name of the user / start of the node to filter by")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
|
@ -23,23 +23,29 @@
|
||||
package me.lucko.luckperms.common.commands.track;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CreateTrack extends SingleMainCommand {
|
||||
public class CreateTrack extends SingleCommand {
|
||||
public CreateTrack() {
|
||||
super("CreateTrack", "/%s createtrack <track>", 1, Permission.CREATE_TRACK);
|
||||
super("CreateTrack", "Create a new track", "/%s createtrack <track>", Permission.CREATE_TRACK, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("name", true, "the name of the track")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
|
@ -23,26 +23,32 @@
|
||||
package me.lucko.luckperms.common.commands.track;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.tracks.Track;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DeleteTrack extends SingleMainCommand {
|
||||
public class DeleteTrack extends SingleCommand {
|
||||
public DeleteTrack() {
|
||||
super("DeleteTrack", "/%s deletetrack <track>", 1, Permission.DELETE_TRACK);
|
||||
super("DeleteTrack", "Delete a track", "/%s deletetrack <track>", Permission.DELETE_TRACK, Predicates.not(1),
|
||||
Arg.list(
|
||||
Arg.create("name", true, "the name of the track")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
@ -72,7 +78,7 @@ public class DeleteTrack extends SingleMainCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<String> tracks = new ArrayList<>(plugin.getTrackManager().getAll().keySet());
|
||||
|
||||
if (args.size() <= 1) {
|
||||
|
@ -25,21 +25,22 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ListTracks extends SingleMainCommand {
|
||||
public class ListTracks extends SingleCommand {
|
||||
public ListTracks() {
|
||||
super("ListTracks", "/%s listtracks", 0, Permission.LIST_TRACKS);
|
||||
super("ListTracks", "List all tracks on the platform", "/%s listtracks", Permission.LIST_TRACKS, Predicates.alwaysFalse(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (!plugin.getDatastore().loadAllTracks().getUnchecked()) {
|
||||
Message.TRACKS_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.track;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Command;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.track.subcommands.*;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.tracks.Track;
|
||||
@ -36,7 +36,7 @@ import java.util.List;
|
||||
|
||||
public class TrackMainCommand extends MainCommand<Track> {
|
||||
public TrackMainCommand() {
|
||||
super("Track", "/%s track <track>", 2, ImmutableList.<SubCommand<Track>>builder()
|
||||
super("Track", "Track commands", "/%s track <track>", 2, ImmutableList.<Command<Track, ?>>builder()
|
||||
.add(new TrackInfo())
|
||||
.add(new TrackAppend())
|
||||
.add(new TrackInsert())
|
||||
@ -70,7 +70,7 @@ public class TrackMainCommand extends MainCommand<Track> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return new ArrayList<>(plugin.getTrackManager().getAll().keySet());
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class TrackAppend extends SubCommand<Track> {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
sendDetailedUsage(sender);
|
||||
sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class TrackAppend extends SubCommand<Track> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class TrackInsert extends SubCommand<Track> {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
sendDetailedUsage(sender);
|
||||
sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class TrackInsert extends SubCommand<Track> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class TrackRemove extends SubCommand<Track> {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
sendDetailedUsage(sender);
|
||||
sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class TrackRemove extends SubCommand<Track> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.user;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Command;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.Util;
|
||||
import me.lucko.luckperms.common.commands.generic.meta.CommandMeta;
|
||||
import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks;
|
||||
@ -42,7 +42,7 @@ import java.util.UUID;
|
||||
|
||||
public class UserMainCommand extends MainCommand<User> {
|
||||
public UserMainCommand() {
|
||||
super("User", "/%s user <user>", 2, ImmutableList.<SubCommand<User>>builder()
|
||||
super("User", "User commands", "/%s user <user>", 2, ImmutableList.<Command<User, ?>>builder()
|
||||
.add(new UserInfo())
|
||||
.add(new CommandPermission<>(true))
|
||||
.add(new CommandParent<>(true))
|
||||
@ -100,7 +100,7 @@ public class UserMainCommand extends MainCommand<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return plugin.getPlayerList();
|
||||
}
|
||||
}
|
@ -183,7 +183,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getTrackTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getTrackTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.usersbulkedit;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Command;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.usersbulkedit.subcommands.BulkEditGroup;
|
||||
import me.lucko.luckperms.common.commands.usersbulkedit.subcommands.BulkEditPermission;
|
||||
import me.lucko.luckperms.common.storage.Datastore;
|
||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
||||
|
||||
public UsersBulkEditMainCommand() {
|
||||
super("UsersBulkEdit", "/%s usersbulkedit", 1, ImmutableList.<SubCommand<Datastore>>builder()
|
||||
super("UsersBulkEdit", "User bulk edit commands", "/%s usersbulkedit", 1, ImmutableList.<Command<Datastore, ?>>builder()
|
||||
.add(new BulkEditGroup())
|
||||
.add(new BulkEditPermission())
|
||||
.build()
|
||||
@ -57,13 +57,13 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
final List<SubCommand<Datastore>> subs = getSubCommands().stream()
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<Command<Datastore, ?>> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@ -80,7 +80,7 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SubCommand<Datastore>> o = subs.stream()
|
||||
Optional<Command<Datastore, ?>> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -89,6 +89,6 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return o.get().onTabComplete(plugin, sender, args.subList(1, args.size()));
|
||||
return o.get().tabComplete(plugin, sender, args.subList(1, args.size()));
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,15 @@ import java.util.stream.IntStream;
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
@UtilityClass
|
||||
public class Predicates {
|
||||
private static final Predicate FALSE = o -> false;
|
||||
private static final Predicate TRUE = o -> true;
|
||||
|
||||
public static <T> Predicate<T> alwaysFalse() {
|
||||
return t -> false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public static <T> Predicate<T> alwaysTrue() {
|
||||
return t -> true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public static Predicate<Integer> notInRange(Integer start, Integer end) {
|
||||
|
Loading…
Reference in New Issue
Block a user