Fix migration commands never being executed
This commit is contained in:
parent
b72e5f5437
commit
e296b1df60
@ -12,10 +12,6 @@ load: STARTUP
|
|||||||
# when they check for the presence of a service provider, before LuckPerms has enabled.
|
# when they check for the presence of a service provider, before LuckPerms has enabled.
|
||||||
loadbefore: [Vault]
|
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:
|
commands:
|
||||||
luckperms:
|
luckperms:
|
||||||
description: Manage permissions
|
description: Manage permissions
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
package me.lucko.luckperms.common.commands;
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
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.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
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 String usage;
|
||||||
private final int minArgs; // equals 1 if the command doesn't take a mid argument, e.g. /lp user <USER> sub-command....
|
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);
|
super(name, description, null, Predicates.alwaysFalse(), null, children);
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
this.minArgs = minArgs;
|
this.minArgs = minArgs;
|
||||||
@ -85,7 +84,6 @@ public abstract class MainCommand<T> extends BaseCommand<Void, 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) {
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
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.*;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationMainCommand extends MainCommand<Object> {
|
public class MigrationMainCommand extends MainCommand<Object> {
|
||||||
|
private List<Command<Object, ?>> commands = null;
|
||||||
|
|
||||||
public MigrationMainCommand() {
|
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() {
|
private static List<Command<Object, ?>> getAvailableCommands() {
|
||||||
List<SubCommand<Object>> l = new ArrayList<>();
|
List<SubCommand<Object>> l = new ArrayList<>();
|
||||||
|
|
||||||
@ -85,6 +88,22 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
return l.stream().collect(Collectors.toList());
|
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
|
@Override
|
||||||
public boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return sender.getUuid().equals(Constants.getConsoleUUID());
|
return sender.getUuid().equals(Constants.getConsoleUUID());
|
||||||
@ -106,8 +125,8 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
protected Object getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
return null;
|
return new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user