mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 19:46:32 +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.track.TrackMainCommand;
|
||||||
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
||||||
import me.lucko.luckperms.common.commands.usersbulkedit.UsersBulkEditMainCommand;
|
import me.lucko.luckperms.common.commands.usersbulkedit.UsersBulkEditMainCommand;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -53,7 +54,7 @@ public class CommandManager {
|
|||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<MainCommand> mainCommands = ImmutableList.<MainCommand>builder()
|
private final List<BaseCommand> mainCommands = ImmutableList.<BaseCommand>builder()
|
||||||
.add(new UserMainCommand())
|
.add(new UserMainCommand())
|
||||||
.add(new GroupMainCommand())
|
.add(new GroupMainCommand())
|
||||||
.add(new TrackMainCommand())
|
.add(new TrackMainCommand())
|
||||||
@ -76,7 +77,6 @@ public class CommandManager {
|
|||||||
.add(new ListTracks())
|
.add(new ListTracks())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic on command method to be called from the command executor object of the platform
|
* 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
|
* 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
|
* @param args the arguments provided
|
||||||
* @return if the command was successful
|
* @return if the command was successful
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public CommandResult onCommand(Sender sender, String label, List<String> args) {
|
public CommandResult onCommand(Sender sender, String label, List<String> args) {
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
sendCommandUsage(sender, label);
|
sendCommandUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<MainCommand> o = mainCommands.stream()
|
Optional<BaseCommand> o = mainCommands.stream()
|
||||||
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -115,35 +116,70 @@ public class CommandManager {
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MainCommand main = o.get();
|
final Command main = o.get();
|
||||||
if (!main.isAuthorized(sender)) {
|
if (!main.isAuthorized(sender)) {
|
||||||
sendCommandUsage(sender, label);
|
sendCommandUsage(sender, label);
|
||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main.getRequiredArgsLength() == 0) {
|
List<String> arguments = new ArrayList<>(args);
|
||||||
try {
|
handleRewrites(arguments);
|
||||||
return main.execute(plugin, sender, null, label);
|
arguments.remove(0); // remove the first command part.
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return CommandResult.FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 1) {
|
if (main.getArgumentCheck().test(arguments.size())) {
|
||||||
main.sendUsage(sender, label);
|
main.sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> arguments = new ArrayList<>(args);
|
CommandResult result;
|
||||||
handleRewrites(arguments);
|
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> onTabComplete(Sender sender, List<String> args) {
|
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))
|
.filter(m -> m.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -171,7 +207,7 @@ public class CommandManager {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<MainCommand> o = mains.stream()
|
Optional<Command> o = mains.stream()
|
||||||
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -180,7 +216,7 @@ public class CommandManager {
|
|||||||
return Collections.emptyList();
|
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) {
|
private void sendCommandUsage(Sender sender, String label) {
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands;
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -34,50 +34,27 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class MainCommand<T> extends BaseCommand<Void, T> {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
|
||||||
public abstract class MainCommand<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the main command
|
|
||||||
*/
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The command usage
|
|
||||||
*/
|
|
||||||
private final String usage;
|
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....
|
||||||
|
|
||||||
/**
|
public MainCommand(String name, String description, String usage, int minArgs, @NonNull List<Command<T, ?>> children) {
|
||||||
* How many arguments are required for the command to run
|
super(name, description, null, Predicates.alwaysFalse(), null, children);
|
||||||
*/
|
this.usage = usage;
|
||||||
private final int requiredArgsLength;
|
this.minArgs = minArgs;
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of the sub commands under this main command
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final List<SubCommand<T>> subCommands;
|
|
||||||
|
|
||||||
MainCommand(String name, String usage, int requiredArgsLength) {
|
|
||||||
this(name, usage, requiredArgsLength, ImmutableList.of());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Called when this main command is ran
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) throws CommandException {
|
||||||
* @param plugin a link to the main plugin instance
|
if (args.size() < minArgs) {
|
||||||
* @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) {
|
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SubCommand<T>> o = getSubCommands().stream()
|
Optional<Command<T, ?>> o = getSubCommands().stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(requiredArgsLength - 1)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(minArgs - 1)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
|
|
||||||
@ -86,19 +63,19 @@ public abstract class MainCommand<T> {
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SubCommand<T> sub = o.get();
|
final Command<T, ?> sub = o.get();
|
||||||
if (!sub.isAuthorized(sender)) {
|
if (!sub.isAuthorized(sender)) {
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> strippedArgs = new ArrayList<>();
|
List<String> strippedArgs = new ArrayList<>();
|
||||||
if (args.size() > requiredArgsLength) {
|
if (args.size() > minArgs) {
|
||||||
strippedArgs.addAll(args.subList(requiredArgsLength, args.size()));
|
strippedArgs.addAll(args.subList(minArgs, args.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sub.getIsArgumentInvalid().test(strippedArgs.size())) {
|
if (sub.getArgumentCheck().test(strippedArgs.size())) {
|
||||||
sub.sendDetailedUsage(sender);
|
sub.sendDetailedUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,11 +83,13 @@ public abstract class MainCommand<T> {
|
|||||||
T t = getTarget(name, plugin, sender);
|
T t = getTarget(name, plugin, sender);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
CommandResult result;
|
CommandResult result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = sub.execute(plugin, sender, t, strippedArgs, label);
|
result = sub.execute(plugin, sender, t, strippedArgs, label);
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
result = handleException(e, sender, sub);
|
result = CommandManager.handleException(e, sender, label, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup(t, plugin);
|
cleanup(t, plugin);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -118,99 +97,9 @@ public abstract class MainCommand<T> {
|
|||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CommandResult handleException(CommandException e, Sender sender, SubCommand command) {
|
@Override
|
||||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
final List<String> objects = getTargets(plugin);
|
||||||
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);
|
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
if (args.size() <= 1) {
|
||||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||||
@ -222,7 +111,7 @@ public abstract class MainCommand<T> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SubCommand<T>> subs = getSubCommands().stream()
|
final List<Command<T, ?>> subs = getSubCommands().stream()
|
||||||
.filter(s -> s.isAuthorized(sender))
|
.filter(s -> s.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -239,7 +128,7 @@ public abstract class MainCommand<T> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SubCommand<T>> o = subs.stream()
|
Optional<Command<T, ?>> o = subs.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -248,6 +137,56 @@ public abstract class MainCommand<T> {
|
|||||||
return Collections.emptyList();
|
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;
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
@ -43,62 +41,22 @@ import java.util.stream.Collectors;
|
|||||||
* Abstract SubCommand class
|
* Abstract SubCommand class
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
public abstract class SubCommand<T> extends Command<T, Void> {
|
||||||
public abstract class SubCommand<T> {
|
|
||||||
|
|
||||||
/**
|
public SubCommand(String name, String description, Permission permission, Predicate<Integer> argumentCheck, List<Arg> args) {
|
||||||
* The name of the sub command
|
super(name, description, permission, argumentCheck, args);
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the command usage to a sender
|
* Send the command usage to a sender
|
||||||
* @param sender the sender to send the usage to
|
* @param sender the sender to send the usage to
|
||||||
*/
|
*/
|
||||||
public void sendUsage(Sender sender) {
|
@Override
|
||||||
|
public void sendUsage(Sender sender, String label) {
|
||||||
String usage = "";
|
String usage = "";
|
||||||
if (args != null) {
|
if (getArgs().isPresent()) {
|
||||||
usage += "&3 - &7";
|
usage += "&3 - &7";
|
||||||
for (Arg arg : args) {
|
for (Arg arg : getArgs().get()) {
|
||||||
usage += arg.asPrettyString() + " ";
|
usage += arg.asPrettyString() + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,30 +64,22 @@ public abstract class SubCommand<T> {
|
|||||||
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage);
|
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, "&3&lCommand Usage &3- &b" + getName());
|
||||||
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
|
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||||
if (args != null) {
|
if (getArgs().isPresent()) {
|
||||||
Util.sendPluginMessage(sender, "&3Arguments:");
|
Util.sendPluginMessage(sender, "&3Arguments:");
|
||||||
for (Arg arg : args) {
|
for (Arg arg : getArgs().get()) {
|
||||||
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
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.Optional;
|
||||||
import java.util.stream.Collectors;
|
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 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);
|
super(name, description, null, Predicates.alwaysFalse(), null);
|
||||||
this.secondaryCommands = secondaryCommands;
|
this.secondaryCommands = secondaryCommands;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -51,7 +51,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SecondarySubCommand> o = secondaryCommands.stream()
|
Optional<SharedSubCommand> o = secondaryCommands.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -61,7 +61,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SecondarySubCommand sub = o.get();
|
final SharedSubCommand sub = o.get();
|
||||||
if (!sub.isAuthorized(sender, user)) {
|
if (!sub.isAuthorized(sender, user)) {
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
@ -86,7 +86,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
return result;
|
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.ArgumentException) {
|
||||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||||
command.sendDetailedUsage(sender);
|
command.sendDetailedUsage(sender);
|
||||||
@ -125,8 +125,8 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
final List<SecondarySubCommand> subs = secondaryCommands.stream()
|
final List<SharedSubCommand> subs = secondaryCommands.stream()
|
||||||
.filter(s -> s.isAuthorized(sender, user))
|
.filter(s -> s.isAuthorized(sender, user))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SecondarySubCommand> o = subs.stream()
|
Optional<SharedSubCommand> o = subs.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -157,7 +157,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
for (SecondarySubCommand subCommand : secondaryCommands) {
|
for (SharedSubCommand subCommand : secondaryCommands) {
|
||||||
if (subCommand.isAuthorized(sender, user)) {
|
if (subCommand.isAuthorized(sender, user)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendUsageDetailed(Sender sender, boolean user, String label) {
|
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))
|
.filter(s -> s.isAuthorized(sender, user))
|
||||||
.collect(Collectors.toList());
|
.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));
|
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);
|
s.sendUsage(sender);
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public abstract class SecondarySubCommand {
|
public abstract class SharedSubCommand {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the sub command
|
* The name of the sub command
|
@ -23,13 +23,13 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.meta;
|
package me.lucko.luckperms.common.commands.generic.meta;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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) {
|
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 MetaInfo())
|
||||||
.add(new MetaSet())
|
.add(new MetaSet())
|
||||||
.add(new MetaUnset())
|
.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.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -36,7 +36,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddPrefix extends SecondarySubCommand {
|
public class MetaAddPrefix extends SharedSubCommand {
|
||||||
public MetaAddPrefix() {
|
public MetaAddPrefix() {
|
||||||
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX,
|
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX,
|
||||||
Predicates.notInRange(2, 4),
|
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.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -36,7 +36,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddSuffix extends SecondarySubCommand {
|
public class MetaAddSuffix extends SharedSubCommand {
|
||||||
public MetaAddSuffix() {
|
public MetaAddSuffix() {
|
||||||
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX,
|
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX,
|
||||||
Predicates.notInRange(2, 4),
|
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.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddTempPrefix extends SecondarySubCommand {
|
public class MetaAddTempPrefix extends SharedSubCommand {
|
||||||
public MetaAddTempPrefix() {
|
public MetaAddTempPrefix() {
|
||||||
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX,
|
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX,
|
||||||
Permission.GROUP_META_ADDTEMP_PREFIX, Predicates.notInRange(3, 5),
|
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.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddTempSuffix extends SecondarySubCommand {
|
public class MetaAddTempSuffix extends SharedSubCommand {
|
||||||
public MetaAddTempSuffix() {
|
public MetaAddTempSuffix() {
|
||||||
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX,
|
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX,
|
||||||
Permission.GROUP_META_ADDTEMP_SUFFIX, Predicates.notInRange(3, 5),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaClear extends SecondarySubCommand {
|
public class MetaClear extends SharedSubCommand {
|
||||||
public MetaClear() {
|
public MetaClear() {
|
||||||
super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.notInRange(0, 2),
|
super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.notInRange(0, 2),
|
||||||
Arg.list(
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -37,7 +37,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MetaInfo extends SecondarySubCommand {
|
public class MetaInfo extends SharedSubCommand {
|
||||||
public MetaInfo() {
|
public MetaInfo() {
|
||||||
super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicates.alwaysFalse(), null);
|
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.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemovePrefix extends SecondarySubCommand {
|
public class MetaRemovePrefix extends SharedSubCommand {
|
||||||
public MetaRemovePrefix() {
|
public MetaRemovePrefix() {
|
||||||
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
||||||
Predicates.notInRange(2, 4),
|
Predicates.notInRange(2, 4),
|
||||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveSuffix extends SecondarySubCommand {
|
public class MetaRemoveSuffix extends SharedSubCommand {
|
||||||
public MetaRemoveSuffix() {
|
public MetaRemoveSuffix() {
|
||||||
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
||||||
Predicates.notInRange(2, 4),
|
Predicates.notInRange(2, 4),
|
||||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
public class MetaRemoveTempPrefix extends SharedSubCommand {
|
||||||
public MetaRemoveTempPrefix() {
|
public MetaRemoveTempPrefix() {
|
||||||
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicates.notInRange(2, 4),
|
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
public class MetaRemoveTempSuffix extends SharedSubCommand {
|
||||||
public MetaRemoveTempSuffix() {
|
public MetaRemoveTempSuffix() {
|
||||||
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicates.notInRange(2, 4),
|
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
@ -38,7 +38,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaSet extends SecondarySubCommand {
|
public class MetaSet extends SharedSubCommand {
|
||||||
public MetaSet() {
|
public MetaSet() {
|
||||||
super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.notInRange(2, 4),
|
super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.api.MetaUtils;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaSetTemp extends SecondarySubCommand {
|
public class MetaSetTemp extends SharedSubCommand {
|
||||||
public MetaSetTemp() {
|
public MetaSetTemp() {
|
||||||
super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.notInRange(3, 5),
|
super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.notInRange(3, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
|
@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaUnset extends SecondarySubCommand {
|
public class MetaUnset extends SharedSubCommand {
|
||||||
public MetaUnset() {
|
public MetaUnset() {
|
||||||
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET,
|
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET,
|
||||||
Predicates.notInRange(1, 3),
|
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.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaUnsetTemp extends SecondarySubCommand {
|
public class MetaUnsetTemp extends SharedSubCommand {
|
||||||
public MetaUnsetTemp() {
|
public MetaUnsetTemp() {
|
||||||
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP,
|
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP,
|
||||||
Predicates.notInRange(1, 3),
|
Predicates.notInRange(1, 3),
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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) {
|
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 ParentInfo())
|
||||||
.add(new ParentSet())
|
.add(new ParentSet())
|
||||||
.add(new ParentAdd())
|
.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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentAdd extends SecondarySubCommand {
|
public class ParentAdd extends SharedSubCommand {
|
||||||
public ParentAdd() {
|
public ParentAdd() {
|
||||||
super("add", "Sets another group for the object to inherit permissions from", Permission.USER_PARENT_ADD,
|
super("add", "Sets another group for the object to inherit permissions from", Permission.USER_PARENT_ADD,
|
||||||
Permission.GROUP_PARENT_ADD, Predicates.notInRange(1, 3),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentAddTemp extends SecondarySubCommand {
|
public class ParentAddTemp extends SharedSubCommand {
|
||||||
public ParentAddTemp() {
|
public ParentAddTemp() {
|
||||||
super("addtemp", "Sets another group for the object to inherit permissions from temporarily",
|
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),
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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.List;
|
||||||
|
|
||||||
public class ParentInfo extends SecondarySubCommand {
|
public class ParentInfo extends SharedSubCommand {
|
||||||
public ParentInfo() {
|
public ParentInfo() {
|
||||||
super("info", "Lists the groups that this object inherits from",
|
super("info", "Lists the groups that this object inherits from",
|
||||||
Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicates.alwaysFalse(), null);
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentRemove extends SecondarySubCommand {
|
public class ParentRemove extends SharedSubCommand {
|
||||||
public ParentRemove() {
|
public ParentRemove() {
|
||||||
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE,
|
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE,
|
||||||
Permission.GROUP_PARENT_REMOVE, Predicates.notInRange(1, 3),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentRemoveTemp extends SecondarySubCommand {
|
public class ParentRemoveTemp extends SharedSubCommand {
|
||||||
public ParentRemoveTemp() {
|
public ParentRemoveTemp() {
|
||||||
super("removetemp", "Removes a previously set temporary inheritance rule",
|
super("removetemp", "Removes a previously set temporary inheritance rule",
|
||||||
Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicates.notInRange(1, 3),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentSet extends SecondarySubCommand {
|
public class ParentSet extends SharedSubCommand {
|
||||||
public ParentSet() {
|
public ParentSet() {
|
||||||
super("set", "Removes all other groups the object inherits already and adds them to the one given",
|
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),
|
Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicates.notInRange(1, 3),
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedMainCommand;
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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) {
|
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 PermissionInfo())
|
||||||
.add(new PermissionSet())
|
.add(new PermissionSet())
|
||||||
.add(new PermissionUnset())
|
.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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionCheck extends SecondarySubCommand {
|
public class PermissionCheck extends SharedSubCommand {
|
||||||
public PermissionCheck() {
|
public PermissionCheck() {
|
||||||
super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK,
|
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),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.InheritanceInfo;
|
import me.lucko.luckperms.common.core.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
@ -33,7 +33,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionCheckInherits extends SecondarySubCommand {
|
public class PermissionCheckInherits extends SharedSubCommand {
|
||||||
public PermissionCheckInherits() {
|
public PermissionCheckInherits() {
|
||||||
super("checkinherits", "Checks to see if the object inherits a certain permission node",
|
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),
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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.List;
|
||||||
|
|
||||||
public class PermissionInfo extends SecondarySubCommand {
|
public class PermissionInfo extends SharedSubCommand {
|
||||||
public PermissionInfo() {
|
public PermissionInfo() {
|
||||||
super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicates.alwaysFalse(), null);
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||||
|
|
||||||
public class PermissionSet extends SecondarySubCommand {
|
public class PermissionSet extends SharedSubCommand {
|
||||||
public PermissionSet() {
|
public PermissionSet() {
|
||||||
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
||||||
Predicates.notInRange(2, 4),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
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;
|
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||||
|
|
||||||
public class PermissionSetTemp extends SecondarySubCommand {
|
public class PermissionSetTemp extends SharedSubCommand {
|
||||||
public PermissionSetTemp() {
|
public PermissionSetTemp() {
|
||||||
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
||||||
Permission.GROUP_PERM_SETTEMP, Predicates.notInRange(3, 5),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PermissionUnset extends SecondarySubCommand {
|
public class PermissionUnset extends SharedSubCommand {
|
||||||
public PermissionUnset() {
|
public PermissionUnset() {
|
||||||
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET,
|
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET,
|
||||||
Predicates.notInRange(1, 3),
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.*;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -35,7 +35,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PermissionUnsetTemp extends SecondarySubCommand {
|
public class PermissionUnsetTemp extends SharedSubCommand {
|
||||||
public PermissionUnsetTemp() {
|
public PermissionUnsetTemp() {
|
||||||
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP,
|
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP,
|
||||||
Permission.GROUP_PERM_UNSETTEMP, Predicates.notInRange(1, 3),
|
Permission.GROUP_PERM_UNSETTEMP, Predicates.notInRange(1, 3),
|
||||||
|
@ -23,23 +23,29 @@
|
|||||||
package me.lucko.luckperms.common.commands.group;
|
package me.lucko.luckperms.common.commands.group;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CreateGroup extends SingleMainCommand {
|
public class CreateGroup extends SingleCommand {
|
||||||
public CreateGroup() {
|
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
|
@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) {
|
if (args.size() == 0) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
|
@ -23,26 +23,32 @@
|
|||||||
package me.lucko.luckperms.common.commands.group;
|
package me.lucko.luckperms.common.commands.group;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DeleteGroup extends SingleMainCommand {
|
public class DeleteGroup extends SingleCommand {
|
||||||
public DeleteGroup() {
|
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
|
@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) {
|
if (args.size() == 0) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
@ -78,7 +84,7 @@ public class DeleteGroup extends SingleMainCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
final List<String> groups = new ArrayList<>(plugin.getGroupManager().getAll().keySet());
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
if (args.size() <= 1) {
|
||||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.group;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.meta.CommandMeta;
|
||||||
import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks;
|
import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks;
|
||||||
import me.lucko.luckperms.common.commands.generic.parent.CommandParent;
|
import me.lucko.luckperms.common.commands.generic.parent.CommandParent;
|
||||||
@ -40,7 +40,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class GroupMainCommand extends MainCommand<Group> {
|
public class GroupMainCommand extends MainCommand<Group> {
|
||||||
public GroupMainCommand() {
|
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 GroupInfo())
|
||||||
.add(new CommandPermission<>(false))
|
.add(new CommandPermission<>(false))
|
||||||
.add(new CommandParent<>(false))
|
.add(new CommandParent<>(false))
|
||||||
@ -76,7 +76,7 @@ public class GroupMainCommand extends MainCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return new ArrayList<>(plugin.getGroupManager().getAll().keySet());
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.commands.Util;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ListGroups extends SingleMainCommand {
|
public class ListGroups extends SingleCommand {
|
||||||
public ListGroups() {
|
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
|
@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()) {
|
if (!plugin.getDatastore().loadAllGroups().getUnchecked()) {
|
||||||
Message.GROUPS_LOAD_ERROR.send(sender);
|
Message.GROUPS_LOAD_ERROR.send(sender);
|
||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.commands.log.subcommands.*;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class LogMainCommand extends MainCommand<Log> {
|
public class LogMainCommand extends MainCommand<Log> {
|
||||||
public LogMainCommand() {
|
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 LogRecent())
|
||||||
.add(new LogSearch())
|
.add(new LogSearch())
|
||||||
.add(new LogNotify())
|
.add(new LogNotify())
|
||||||
@ -67,13 +67,13 @@ public class LogMainCommand extends MainCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<SubCommand<Log>> subs = getSubCommands().stream()
|
final List<Command<Log, ?>> subs = getSubCommands().stream()
|
||||||
.filter(s -> s.isAuthorized(sender))
|
.filter(s -> s.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class LogMainCommand extends MainCommand<Log> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SubCommand<Log>> o = subs.stream()
|
Optional<Command<Log, ?>> o = subs.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -99,6 +99,6 @@ public class LogMainCommand extends MainCommand<Log> {
|
|||||||
return Collections.emptyList();
|
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;
|
package me.lucko.luckperms.common.commands.migration;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
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.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationMainCommand extends MainCommand<Object> {
|
public class MigrationMainCommand extends MainCommand<Object> {
|
||||||
private final List<SubCommand<Object>> subCommands = new ArrayList<>();
|
|
||||||
|
|
||||||
public MigrationMainCommand() {
|
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 {
|
try {
|
||||||
Class.forName("org.anjocaido.groupmanager.GroupManager");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("ru.tehkode.permissions.bukkit.PermissionsEx");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("com.github.cheesesoftware.PowerfulPermsAPI.PowerfulPermsPlugin");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("net.alpenblock.bungeeperms.BungeePerms");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("de.bananaco.bpermissions.api.WorldManager");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("ninja.leaping.permissionsex.sponge.PermissionsExPlugin");
|
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) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
|
return l.stream().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SubCommand<Object>> getSubCommands() {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return subCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isAuthorized(Sender sender) {
|
|
||||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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())) {
|
if (!sender.getUuid().equals(Constants.getConsoleUUID())) {
|
||||||
Message.MIGRATION_NOT_CONSOLE.send(sender);
|
Message.MIGRATION_NOT_CONSOLE.send(sender);
|
||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.execute(plugin, sender, args, label);
|
return super.execute(plugin, sender, v, args, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void cleanup(Object object, LuckPermsPlugin plugin) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
protected Void getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
return Collections.emptyList();
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DebugCommand extends SingleMainCommand {
|
public class DebugCommand extends SingleCommand {
|
||||||
public DebugCommand() {
|
public DebugCommand() {
|
||||||
super("Debug", "/%s debug", 0, Permission.DEBUG);
|
super("Debug", "Print debugging output", "/%s debug", Permission.DEBUG, Predicates.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.");
|
plugin.getLog().info(sender.getName() + " used the debug command.");
|
||||||
Message.DEBUG.send(sender,
|
Message.DEBUG.send(sender,
|
||||||
plugin.getPlayerCount(),
|
plugin.getPlayerCount(),
|
||||||
|
@ -25,9 +25,10 @@ package me.lucko.luckperms.common.commands.misc;
|
|||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
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.storage.Datastore;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
import me.lucko.luckperms.common.users.User;
|
import me.lucko.luckperms.common.users.User;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -45,13 +47,17 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ExportCommand extends SingleMainCommand {
|
public class ExportCommand extends SingleCommand {
|
||||||
public ExportCommand() {
|
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
|
@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();
|
final Logger log = plugin.getLog();
|
||||||
|
|
||||||
if (!sender.getUuid().equals(Constants.getConsoleUUID())) {
|
if (!sender.getUuid().equals(Constants.getConsoleUUID())) {
|
||||||
@ -164,7 +170,7 @@ public class ExportCommand extends SingleMainCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
package me.lucko.luckperms.common.commands.misc;
|
package me.lucko.luckperms.common.commands.misc;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Importer;
|
import me.lucko.luckperms.common.data.Importer;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -36,13 +38,17 @@ import java.nio.charset.Charset;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ImportCommand extends SingleMainCommand {
|
public class ImportCommand extends SingleCommand {
|
||||||
public ImportCommand() {
|
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
|
@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) {
|
if (args.size() == 0) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.config.LPConfiguration;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.Util.formatBoolean;
|
import static me.lucko.luckperms.common.commands.Util.formatBoolean;
|
||||||
|
|
||||||
public class InfoCommand extends SingleMainCommand {
|
public class InfoCommand extends SingleCommand {
|
||||||
public InfoCommand() {
|
public InfoCommand() {
|
||||||
super("Info", "/%s info", 0, Permission.INFO);
|
super("Info", "Print general plugin info", "/%s info", Permission.INFO, Predicates.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
final LPConfiguration c = plugin.getConfiguration();
|
||||||
Message.INFO.send(sender,
|
Message.INFO.send(sender,
|
||||||
plugin.getVersion(),
|
plugin.getVersion(),
|
||||||
|
@ -25,19 +25,21 @@ package me.lucko.luckperms.common.commands.misc;
|
|||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NetworkSyncCommand extends SingleMainCommand {
|
public class NetworkSyncCommand extends SingleCommand {
|
||||||
public NetworkSyncCommand() {
|
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
|
@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);
|
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||||
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
||||||
Message.UPDATE_TASK_COMPLETE_NETWORK.send(sender);
|
Message.UPDATE_TASK_COMPLETE_NETWORK.send(sender);
|
||||||
|
@ -23,22 +23,24 @@
|
|||||||
package me.lucko.luckperms.common.commands.misc;
|
package me.lucko.luckperms.common.commands.misc;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
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.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class QueueCommand extends SingleMainCommand {
|
public class QueueCommand extends SingleCommand {
|
||||||
public QueueCommand() {
|
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
|
@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())) {
|
if (args.get(0).equalsIgnoreCase(getName())) {
|
||||||
// Prevent infinite loops
|
// Prevent infinite loops
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
@ -49,7 +51,7 @@ public class QueueCommand extends SingleMainCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SyncCommand extends SingleMainCommand {
|
public class SyncCommand extends SingleCommand {
|
||||||
public SyncCommand() {
|
public SyncCommand() {
|
||||||
super("Sync", "/%s sync", 0, Permission.SYNC);
|
super("Sync", "Sync changes with the storage", "/%s sync", Permission.SYNC, Predicates.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||||
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
plugin.getUpdateTaskBuffer().request().getUnchecked();
|
||||||
Message.UPDATE_TASK_COMPLETE.send(sender);
|
Message.UPDATE_TASK_COMPLETE.send(sender);
|
||||||
|
@ -23,23 +23,30 @@
|
|||||||
package me.lucko.luckperms.common.commands.misc;
|
package me.lucko.luckperms.common.commands.misc;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class VerboseCommand extends SingleMainCommand {
|
public class VerboseCommand extends SingleCommand {
|
||||||
public VerboseCommand() {
|
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
|
@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()) {
|
if (args.isEmpty()) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
|
@ -23,23 +23,29 @@
|
|||||||
package me.lucko.luckperms.common.commands.track;
|
package me.lucko.luckperms.common.commands.track;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CreateTrack extends SingleMainCommand {
|
public class CreateTrack extends SingleCommand {
|
||||||
public CreateTrack() {
|
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
|
@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) {
|
if (args.size() == 0) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
|
@ -23,26 +23,32 @@
|
|||||||
package me.lucko.luckperms.common.commands.track;
|
package me.lucko.luckperms.common.commands.track;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DeleteTrack extends SingleMainCommand {
|
public class DeleteTrack extends SingleCommand {
|
||||||
public DeleteTrack() {
|
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
|
@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) {
|
if (args.size() == 0) {
|
||||||
sendUsage(sender, label);
|
sendUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
@ -72,7 +78,7 @@ public class DeleteTrack extends SingleMainCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
final List<String> tracks = new ArrayList<>(plugin.getTrackManager().getAll().keySet());
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.commands.Util;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ListTracks extends SingleMainCommand {
|
public class ListTracks extends SingleCommand {
|
||||||
public ListTracks() {
|
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
|
@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()) {
|
if (!plugin.getDatastore().loadAllTracks().getUnchecked()) {
|
||||||
Message.TRACKS_LOAD_ERROR.send(sender);
|
Message.TRACKS_LOAD_ERROR.send(sender);
|
||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.commands.track.subcommands.*;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TrackMainCommand extends MainCommand<Track> {
|
public class TrackMainCommand extends MainCommand<Track> {
|
||||||
public TrackMainCommand() {
|
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 TrackInfo())
|
||||||
.add(new TrackAppend())
|
.add(new TrackAppend())
|
||||||
.add(new TrackInsert())
|
.add(new TrackInsert())
|
||||||
@ -70,7 +70,7 @@ public class TrackMainCommand extends MainCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return new ArrayList<>(plugin.getTrackManager().getAll().keySet());
|
return new ArrayList<>(plugin.getTrackManager().getAll().keySet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class TrackAppend extends SubCommand<Track> {
|
|||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
sendDetailedUsage(sender);
|
sendDetailedUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public class TrackAppend extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getGroupTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class TrackInsert extends SubCommand<Track> {
|
|||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
sendDetailedUsage(sender);
|
sendDetailedUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class TrackInsert extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getGroupTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class TrackRemove extends SubCommand<Track> {
|
|||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
sendDetailedUsage(sender);
|
sendDetailedUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class TrackRemove extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getGroupTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.user;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.Util;
|
||||||
import me.lucko.luckperms.common.commands.generic.meta.CommandMeta;
|
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.other.HolderShowTracks;
|
||||||
@ -42,7 +42,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class UserMainCommand extends MainCommand<User> {
|
public class UserMainCommand extends MainCommand<User> {
|
||||||
public UserMainCommand() {
|
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 UserInfo())
|
||||||
.add(new CommandPermission<>(true))
|
.add(new CommandPermission<>(true))
|
||||||
.add(new CommandParent<>(true))
|
.add(new CommandParent<>(true))
|
||||||
@ -100,7 +100,7 @@ public class UserMainCommand extends MainCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return plugin.getPlayerList();
|
return plugin.getPlayerList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -183,7 +183,7 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getTrackTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getTrackTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getGroupTabComplete(args, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ package me.lucko.luckperms.common.commands.usersbulkedit;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
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.BulkEditGroup;
|
||||||
import me.lucko.luckperms.common.commands.usersbulkedit.subcommands.BulkEditPermission;
|
import me.lucko.luckperms.common.commands.usersbulkedit.subcommands.BulkEditPermission;
|
||||||
import me.lucko.luckperms.common.storage.Datastore;
|
import me.lucko.luckperms.common.storage.Datastore;
|
||||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
||||||
|
|
||||||
public UsersBulkEditMainCommand() {
|
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 BulkEditGroup())
|
||||||
.add(new BulkEditPermission())
|
.add(new BulkEditPermission())
|
||||||
.build()
|
.build()
|
||||||
@ -57,13 +57,13 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjects(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<SubCommand<Datastore>> subs = getSubCommands().stream()
|
final List<Command<Datastore, ?>> subs = getSubCommands().stream()
|
||||||
.filter(s -> s.isAuthorized(sender))
|
.filter(s -> s.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SubCommand<Datastore>> o = subs.stream()
|
Optional<Command<Datastore, ?>> o = subs.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.findAny();
|
.findAny();
|
||||||
@ -89,6 +89,6 @@ public class UsersBulkEditMainCommand extends MainCommand<Datastore> {
|
|||||||
return Collections.emptyList();
|
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"})
|
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class Predicates {
|
public class Predicates {
|
||||||
|
private static final Predicate FALSE = o -> false;
|
||||||
|
private static final Predicate TRUE = o -> true;
|
||||||
|
|
||||||
public static <T> Predicate<T> alwaysFalse() {
|
public static <T> Predicate<T> alwaysFalse() {
|
||||||
return t -> false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Predicate<T> alwaysTrue() {
|
public static <T> Predicate<T> alwaysTrue() {
|
||||||
return t -> true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<Integer> notInRange(Integer start, Integer end) {
|
public static Predicate<Integer> notInRange(Integer start, Integer end) {
|
||||||
|
Loading…
Reference in New Issue
Block a user