Fix migration commands never being executed

This commit is contained in:
Luck 2016-11-15 18:17:35 +00:00
parent b72e5f5437
commit e296b1df60
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 24 additions and 11 deletions

View File

@ -12,10 +12,6 @@ load: STARTUP
# when they check for the presence of a service provider, before LuckPerms has enabled.
loadbefore: [Vault]
# These are all soft dependencies for the migration feature. We check to see if these plugins are enabled
# when setting up LuckPerms commands. That way, commands only appear if the corresponding plugin is loaded.
softdepend: [PermissionsEx, GroupManager, PowerfulPerms, zPermissions, bPermissions]
commands:
luckperms:
description: Manage permissions

View File

@ -23,7 +23,6 @@
package me.lucko.luckperms.common.commands;
import lombok.Getter;
import lombok.NonNull;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
@ -42,7 +41,7 @@ public abstract class MainCommand<T> extends BaseCommand<Void, T> {
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) {
public MainCommand(String name, String description, String usage, int minArgs, List<Command<T, ?>> children) {
super(name, description, null, Predicates.alwaysFalse(), null, children);
this.usage = usage;
this.minArgs = minArgs;
@ -85,7 +84,6 @@ public abstract class MainCommand<T> extends BaseCommand<Void, T> {
T t = getTarget(name, plugin, sender);
if (t != null) {
CommandResult result;
try {
result = sub.execute(plugin, sender, t, strippedArgs, label);
} catch (CommandException e) {

View File

@ -22,7 +22,6 @@
package me.lucko.luckperms.common.commands.migration;
import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.*;
import me.lucko.luckperms.common.commands.sender.Sender;
@ -32,13 +31,17 @@ import me.lucko.luckperms.common.constants.Message;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class MigrationMainCommand extends MainCommand<Object> {
private List<Command<Object, ?>> commands = null;
public MigrationMainCommand() {
super("Migration", "Migration commands", "/%s migration", 1, ImmutableList.copyOf(getAvailableCommands()));
super("Migration", "Migration commands", "/%s migration", 1, null);
}
@SuppressWarnings("unchecked")
private static List<Command<Object, ?>> getAvailableCommands() {
List<SubCommand<Object>> l = new ArrayList<>();
@ -85,6 +88,22 @@ public class MigrationMainCommand extends MainCommand<Object> {
return l.stream().collect(Collectors.toList());
}
@SuppressWarnings("deprecation")
@Deprecated
@Override
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
if (commands == null) {
commands = getAvailableCommands();
}
return Optional.of(commands);
}
@SuppressWarnings("deprecation")
public List<Command<Object, ?>> getSubCommands() {
return getChildren().orElse(null);
}
@Override
public boolean isAuthorized(Sender sender) {
return sender.getUuid().equals(Constants.getConsoleUUID());
@ -106,8 +125,8 @@ public class MigrationMainCommand extends MainCommand<Object> {
}
@Override
protected Void getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
return null;
protected Object getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
return new Object();
}
@Override