mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Cleanup command abstraction classes
This commit is contained in:
parent
4c83d439af
commit
2ccb475aa0
@ -25,10 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit;
|
package me.lucko.luckperms.bukkit;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
|
import me.lucko.luckperms.common.command.utils.ArgumentTokenizer;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -40,10 +38,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BukkitCommandExecutor extends CommandManager implements CommandExecutor, TabExecutor {
|
public class BukkitCommandExecutor extends CommandManager implements CommandExecutor, TabExecutor {
|
||||||
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN);
|
|
||||||
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
|
|
||||||
private static final Joiner ARGUMENT_JOINER = Joiner.on(' ');
|
|
||||||
|
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
public BukkitCommandExecutor(LPBukkitPlugin plugin) {
|
public BukkitCommandExecutor(LPBukkitPlugin plugin) {
|
||||||
@ -53,18 +47,16 @@ public class BukkitCommandExecutor extends CommandManager implements CommandExec
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, @NonNull String[] args) {
|
public boolean onCommand(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, @NonNull String[] args) {
|
||||||
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
|
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
|
||||||
List<String> arguments = stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
|
List<String> arguments = ArgumentTokenizer.EXECUTE.tokenizeInput(args);
|
||||||
|
executeCommand(wrapped, label, arguments);
|
||||||
onCommand(lpSender, label, arguments);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, @NonNull String[] args) {
|
public List<String> onTabComplete(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, @NonNull String[] args) {
|
||||||
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
|
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
|
||||||
List<String> arguments = stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
|
List<String> arguments = ArgumentTokenizer.TAB_COMPLETE.tokenizeInput(args);
|
||||||
|
return tabCompleteCommand(wrapped, arguments);
|
||||||
return onTabComplete(lpSender, arguments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,12 +113,9 @@ public final class LuckPermsDefaultsMap implements Map<Boolean, Set<Permission>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return wrappers around this map impl
|
// return wrappers around this map impl
|
||||||
@Override
|
@Override public @NonNull Collection<Set<Permission>> values() { return this.values; }
|
||||||
public @NonNull Collection<Set<Permission>> values() { return this.values; }
|
@Override public @NonNull Set<Entry<Boolean, Set<Permission>>> entrySet() { return this.entrySet; }
|
||||||
@Override
|
@Override public @NonNull Set<Boolean> keySet() { return KEY_SET; }
|
||||||
public @NonNull Set<Entry<Boolean, Set<Permission>>> entrySet() { return this.entrySet; }
|
|
||||||
@Override
|
|
||||||
public @NonNull Set<Boolean> keySet() { return KEY_SET; }
|
|
||||||
|
|
||||||
// return accurate results for the Map spec
|
// return accurate results for the Map spec
|
||||||
@Override public int size() { return 2; }
|
@Override public int size() { return 2; }
|
||||||
|
@ -32,7 +32,7 @@ import de.bananaco.bpermissions.api.World;
|
|||||||
import de.bananaco.bpermissions.api.WorldManager;
|
import de.bananaco.bpermissions.api.WorldManager;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -67,7 +67,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class MigrationBPermissions extends SubCommand<Object> {
|
public class MigrationBPermissions extends ChildCommand<Object> {
|
||||||
private static final Field UCONFIG_FIELD;
|
private static final Field UCONFIG_FIELD;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -68,7 +68,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationGroupManager extends SubCommand<Object> {
|
public class MigrationGroupManager extends ChildCommand<Object> {
|
||||||
public MigrationGroupManager(LocaleManager locale) {
|
public MigrationGroupManager(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_GROUPMANAGER.localize(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0));
|
super(CommandSpec.MIGRATION_GROUPMANAGER.localize(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.bukkit.migration;
|
|||||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -56,7 +56,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
public class MigrationPermissionsBukkit extends ChildCommand<Object> {
|
||||||
public MigrationPermissionsBukkit(LocaleManager locale) {
|
public MigrationPermissionsBukkit(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.bukkit.migration;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -74,7 +74,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationPermissionsEx extends SubCommand<Object> {
|
public class MigrationPermissionsEx extends ChildCommand<Object> {
|
||||||
private static final Method GET_DATA_METHOD;
|
private static final Method GET_DATA_METHOD;
|
||||||
private static final Field TIMED_PERMISSIONS_FIELD;
|
private static final Field TIMED_PERMISSIONS_FIELD;
|
||||||
private static final Field TIMED_PERMISSIONS_TIME_FIELD;
|
private static final Field TIMED_PERMISSIONS_TIME_FIELD;
|
||||||
|
@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
@ -78,7 +78,7 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
// Only supports the latest versions of the PP API. (it seems to change randomly almost every release)
|
// Only supports the latest versions of the PP API. (it seems to change randomly almost every release)
|
||||||
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
public class MigrationPowerfulPerms extends ChildCommand<Object> {
|
||||||
public MigrationPowerfulPerms(LocaleManager locale) {
|
public MigrationPowerfulPerms(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", CommandPermission.MIGRATION, Predicates.not(5));
|
super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", CommandPermission.MIGRATION, Predicates.not(5));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -69,7 +69,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class MigrationZPermissions extends SubCommand<Object> {
|
public class MigrationZPermissions extends ChildCommand<Object> {
|
||||||
public MigrationZPermissions(LocaleManager locale) {
|
public MigrationZPermissions(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bungee;
|
package me.lucko.luckperms.bungee;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
|
import me.lucko.luckperms.common.command.utils.ArgumentTokenizer;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -38,10 +36,6 @@ import net.md_5.bungee.api.plugin.TabExecutor;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BungeeCommandExecutor extends Command implements TabExecutor {
|
public class BungeeCommandExecutor extends Command implements TabExecutor {
|
||||||
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN);
|
|
||||||
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
|
|
||||||
private static final Joiner ARGUMENT_JOINER = Joiner.on(' ');
|
|
||||||
|
|
||||||
private final LPBungeePlugin plugin;
|
private final LPBungeePlugin plugin;
|
||||||
private final CommandManager manager;
|
private final CommandManager manager;
|
||||||
|
|
||||||
@ -53,17 +47,15 @@ public class BungeeCommandExecutor extends Command implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
|
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
|
||||||
List<String> arguments = CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
|
List<String> arguments = ArgumentTokenizer.EXECUTE.tokenizeInput(args);
|
||||||
|
this.manager.executeCommand(wrapped, "lpb", arguments);
|
||||||
this.manager.onCommand(lpSender, "lpb", arguments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
|
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
|
||||||
List<String> arguments = CommandManager.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
|
List<String> arguments = ArgumentTokenizer.TAB_COMPLETE.tokenizeInput(args);
|
||||||
|
return this.manager.tabCompleteCommand(wrapped, arguments);
|
||||||
return this.manager.onTabComplete(lpSender, arguments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.bungee.migration;
|
package me.lucko.luckperms.bungee.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -55,7 +55,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class MigrationBungeePerms extends SubCommand<Object> {
|
public class MigrationBungeePerms extends ChildCommand<Object> {
|
||||||
public MigrationBungeePerms(LocaleManager locale) {
|
public MigrationBungeePerms(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ import java.util.Objects;
|
|||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public class ApiActionLog implements ActionLog {
|
public class ApiActionLog implements ActionLog {
|
||||||
private final Log handle;
|
private final Log handle;
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public class ApiContextManager implements net.luckperms.api.context.ContextManager {
|
public class ApiContextManager implements net.luckperms.api.context.ContextManager {
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
private final ContextManager handle;
|
private final ContextManager handle;
|
||||||
|
|
||||||
public ApiContextManager(LuckPermsPlugin plugin, ContextManager handle) {
|
public ApiContextManager(LuckPermsPlugin plugin, ContextManager<?> handle) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.handle = handle;
|
this.handle = handle;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.utils.ArgumentTokenizer;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.sender.DummySender;
|
import me.lucko.luckperms.common.sender.DummySender;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -207,7 +208,6 @@ public class LegacyImporter implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ImportCommand extends DummySender {
|
private static class ImportCommand extends DummySender {
|
||||||
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
|
|
||||||
private static final Splitter SPACE_SPLITTER = Splitter.on(" ");
|
private static final Splitter SPACE_SPLITTER = Splitter.on(" ");
|
||||||
|
|
||||||
private final CommandManager commandManager;
|
private final CommandManager commandManager;
|
||||||
@ -241,7 +241,7 @@ public class LegacyImporter implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> args = CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(getCommand()));
|
List<String> args = ArgumentTokenizer.EXECUTE.tokenizeInput(getCommand());
|
||||||
|
|
||||||
// rewrite rule for switchprimarygroup command
|
// rewrite rule for switchprimarygroup command
|
||||||
if (args.size() >= 3 && args.get(0).equals("user") && args.get(2).equals("switchprimarygroup")) {
|
if (args.size() >= 3 && args.get(0).equals("user") && args.get(2).equals("switchprimarygroup")) {
|
||||||
@ -250,7 +250,7 @@ public class LegacyImporter implements Runnable {
|
|||||||
args.add(3, "switchprimarygroup");
|
args.add(3, "switchprimarygroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult result = this.commandManager.onCommand(this, "lp", args, Runnable::run).get();
|
CommandResult result = this.commandManager.executeCommand(this, "lp", args, Runnable::run).get();
|
||||||
setResult(result);
|
setResult(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
setResult(CommandResult.FAILURE);
|
setResult(CommandResult.FAILURE);
|
||||||
|
@ -30,14 +30,15 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
|
||||||
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
||||||
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
||||||
import me.lucko.luckperms.common.commands.group.GroupMainCommand;
|
import me.lucko.luckperms.common.commands.group.GroupParentCommand;
|
||||||
import me.lucko.luckperms.common.commands.group.ListGroups;
|
import me.lucko.luckperms.common.commands.group.ListGroups;
|
||||||
import me.lucko.luckperms.common.commands.log.LogMainCommand;
|
import me.lucko.luckperms.common.commands.log.LogParentCommand;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationMainCommand;
|
import me.lucko.luckperms.common.commands.migration.MigrationParentCommand;
|
||||||
import me.lucko.luckperms.common.commands.misc.ApplyEditsCommand;
|
import me.lucko.luckperms.common.commands.misc.ApplyEditsCommand;
|
||||||
import me.lucko.luckperms.common.commands.misc.BulkUpdateCommand;
|
import me.lucko.luckperms.common.commands.misc.BulkUpdateCommand;
|
||||||
import me.lucko.luckperms.common.commands.misc.CheckCommand;
|
import me.lucko.luckperms.common.commands.misc.CheckCommand;
|
||||||
@ -54,35 +55,35 @@ import me.lucko.luckperms.common.commands.misc.VerboseCommand;
|
|||||||
import me.lucko.luckperms.common.commands.track.CreateTrack;
|
import me.lucko.luckperms.common.commands.track.CreateTrack;
|
||||||
import me.lucko.luckperms.common.commands.track.DeleteTrack;
|
import me.lucko.luckperms.common.commands.track.DeleteTrack;
|
||||||
import me.lucko.luckperms.common.commands.track.ListTracks;
|
import me.lucko.luckperms.common.commands.track.ListTracks;
|
||||||
import me.lucko.luckperms.common.commands.track.TrackMainCommand;
|
import me.lucko.luckperms.common.commands.track.TrackParentCommand;
|
||||||
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
import me.lucko.luckperms.common.commands.user.UserParentCommand;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
import net.luckperms.api.query.QueryOptions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.regex.Pattern;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Root command manager for the '/luckperms' command.
|
||||||
|
*/
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
public static final Pattern COMMAND_SEPARATOR_PATTERN = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
|
||||||
|
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
@ -91,19 +92,19 @@ public class CommandManager {
|
|||||||
|
|
||||||
private final TabCompletions tabCompletions;
|
private final TabCompletions tabCompletions;
|
||||||
|
|
||||||
private final List<Command<?, ?>> mainCommands;
|
private final Map<String, Command<?>> mainCommands;
|
||||||
|
|
||||||
public CommandManager(LuckPermsPlugin plugin) {
|
public CommandManager(LuckPermsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
LocaleManager locale = plugin.getLocaleManager();
|
LocaleManager locale = plugin.getLocaleManager();
|
||||||
|
|
||||||
this.tabCompletions = new TabCompletions(plugin);
|
this.tabCompletions = new TabCompletions(plugin);
|
||||||
this.mainCommands = ImmutableList.<Command<?, ?>>builder()
|
this.mainCommands = ImmutableList.<Command<?>>builder()
|
||||||
.add(new UserMainCommand(locale))
|
.add(new UserParentCommand(locale))
|
||||||
.add(new GroupMainCommand(locale))
|
.add(new GroupParentCommand(locale))
|
||||||
.add(new TrackMainCommand(locale))
|
.add(new TrackParentCommand(locale))
|
||||||
.addAll(plugin.getExtraCommands())
|
.addAll(plugin.getExtraCommands())
|
||||||
.add(new LogMainCommand(locale))
|
.add(new LogParentCommand(locale))
|
||||||
.add(new SyncCommand(locale))
|
.add(new SyncCommand(locale))
|
||||||
.add(new InfoCommand(locale))
|
.add(new InfoCommand(locale))
|
||||||
.add(new EditorCommand(locale))
|
.add(new EditorCommand(locale))
|
||||||
@ -116,7 +117,7 @@ public class CommandManager {
|
|||||||
.add(new ExportCommand(locale))
|
.add(new ExportCommand(locale))
|
||||||
.add(new ReloadConfigCommand(locale))
|
.add(new ReloadConfigCommand(locale))
|
||||||
.add(new BulkUpdateCommand(locale))
|
.add(new BulkUpdateCommand(locale))
|
||||||
.add(new MigrationMainCommand(locale))
|
.add(new MigrationParentCommand(locale))
|
||||||
.add(new ApplyEditsCommand(locale))
|
.add(new ApplyEditsCommand(locale))
|
||||||
.add(new CreateGroup(locale))
|
.add(new CreateGroup(locale))
|
||||||
.add(new DeleteGroup(locale))
|
.add(new DeleteGroup(locale))
|
||||||
@ -124,7 +125,9 @@ public class CommandManager {
|
|||||||
.add(new CreateTrack(locale))
|
.add(new CreateTrack(locale))
|
||||||
.add(new DeleteTrack(locale))
|
.add(new DeleteTrack(locale))
|
||||||
.add(new ListTracks(locale))
|
.add(new ListTracks(locale))
|
||||||
.build();
|
.build()
|
||||||
|
.stream()
|
||||||
|
.collect(ImmutableCollectors.toMap(c -> c.getName().toLowerCase(), Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuckPermsPlugin getPlugin() {
|
public LuckPermsPlugin getPlugin() {
|
||||||
@ -135,11 +138,11 @@ public class CommandManager {
|
|||||||
return this.tabCompletions;
|
return this.tabCompletions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<CommandResult> onCommand(Sender sender, String label, List<String> args) {
|
public CompletableFuture<CommandResult> executeCommand(Sender sender, String label, List<String> args) {
|
||||||
return onCommand(sender, label, args, this.executor);
|
return executeCommand(sender, label, args, this.executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<CommandResult> onCommand(Sender sender, String label, List<String> args, Executor executor) {
|
public CompletableFuture<CommandResult> executeCommand(Sender sender, String label, List<String> args, Executor executor) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
return execute(sender, label, args);
|
return execute(sender, label, args);
|
||||||
@ -152,12 +155,10 @@ public class CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermissionForAny(Sender sender) {
|
public boolean hasPermissionForAny(Sender sender) {
|
||||||
return this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender));
|
return this.mainCommands.values().stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private CommandResult execute(Sender sender, String label, List<String> arguments) {
|
||||||
private CommandResult execute(Sender sender, String label, List<String> args) {
|
|
||||||
List<String> arguments = new ArrayList<>(args);
|
|
||||||
handleRewrites(arguments, true);
|
handleRewrites(arguments, true);
|
||||||
|
|
||||||
// Handle no arguments
|
// Handle no arguments
|
||||||
@ -166,31 +167,27 @@ public class CommandManager {
|
|||||||
if (hasPermissionForAny(sender)) {
|
if (hasPermissionForAny(sender)) {
|
||||||
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
|
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
} else {
|
|
||||||
Collection<? extends Group> groups = this.plugin.getGroupManager().getAll().values();
|
|
||||||
if (groups.size() <= 1 && groups.stream().allMatch(g -> g.getOwnNodes(QueryOptions.nonContextual()).isEmpty())) {
|
|
||||||
Message.FIRST_TIME_SETUP.send(sender, label, sender.getName());
|
|
||||||
} else {
|
|
||||||
Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender);
|
|
||||||
}
|
|
||||||
return CommandResult.NO_PERMISSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collection<? extends Group> groups = this.plugin.getGroupManager().getAll().values();
|
||||||
|
if (groups.size() <= 1 && groups.stream().allMatch(g -> g.normalData().immutable().isEmpty())) {
|
||||||
|
Message.FIRST_TIME_SETUP.send(sender, label, sender.getName());
|
||||||
|
} else {
|
||||||
|
Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender);
|
||||||
|
}
|
||||||
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for the main command.
|
// Look for the main command.
|
||||||
Optional<Command<?, ?>> o = this.mainCommands.stream()
|
Command<?> main = this.mainCommands.get(arguments.get(0).toLowerCase());
|
||||||
.filter(m -> m.getName().equalsIgnoreCase(arguments.get(0)))
|
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
// Main command not found
|
// Main command not found
|
||||||
if (!o.isPresent()) {
|
if (main == null) {
|
||||||
sendCommandUsage(sender, label);
|
sendCommandUsage(sender, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the Sender has permission to use the main command.
|
// Check the Sender has permission to use the main command.
|
||||||
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;
|
||||||
@ -209,7 +206,7 @@ public class CommandManager {
|
|||||||
try {
|
try {
|
||||||
result = main.execute(this.plugin, sender, null, arguments, label);
|
result = main.execute(this.plugin, sender, null, arguments, label);
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
result = handleException(e, sender, label, main);
|
result = e.handle(sender, label, main);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
result = CommandResult.FAILURE;
|
result = CommandResult.FAILURE;
|
||||||
@ -218,56 +215,29 @@ public class CommandManager {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<String> tabCompleteCommand(Sender sender, List<String> arguments) {
|
||||||
* Generic tab complete method to be called from the command executor object of the platform
|
|
||||||
*
|
|
||||||
* @param sender who is tab completing
|
|
||||||
* @param args the arguments provided so far
|
|
||||||
* @return a list of suggestions
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<String> onTabComplete(Sender sender, List<String> args) {
|
|
||||||
List<String> arguments = new ArrayList<>(args);
|
|
||||||
|
|
||||||
// we rewrite tab completions too!
|
// we rewrite tab completions too!
|
||||||
handleRewrites(arguments, false);
|
handleRewrites(arguments, false);
|
||||||
|
|
||||||
final List<Command> mains = this.mainCommands.stream()
|
final List<Command<?>> mains = this.mainCommands.values().stream()
|
||||||
.filter(Command::shouldDisplay)
|
.filter(Command::shouldDisplay)
|
||||||
.filter(m -> m.isAuthorized(sender))
|
.filter(m -> m.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// Not yet past the point of entering a main command
|
return TabCompleter.create()
|
||||||
if (arguments.size() <= 1) {
|
.at(0, CompletionSupplier.startsWith(() -> mains.stream().map(c -> c.getName().toLowerCase())))
|
||||||
|
.from(1, partial -> mains.stream()
|
||||||
// Nothing yet entered
|
.filter(m -> m.getName().equalsIgnoreCase(arguments.get(0)))
|
||||||
if (arguments.isEmpty() || arguments.get(0).equals("")) {
|
.findFirst()
|
||||||
return mains.stream()
|
.map(cmd -> cmd.tabComplete(this.plugin, sender, arguments.subList(1, arguments.size())))
|
||||||
.map(m -> m.getName().toLowerCase())
|
.orElse(Collections.emptyList())
|
||||||
.collect(Collectors.toList());
|
)
|
||||||
}
|
.complete(arguments);
|
||||||
|
|
||||||
// Started typing a main command
|
|
||||||
return mains.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.filter(s -> s.startsWith(arguments.get(0).toLowerCase()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a main command matching the first arg
|
|
||||||
Optional<Command> o = mains.stream()
|
|
||||||
.filter(m -> m.getName().equalsIgnoreCase(arguments.get(0)))
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
arguments.remove(0); // remove the main command arg.
|
|
||||||
|
|
||||||
// Pass the processing onto the main command
|
|
||||||
return o.map(cmd -> cmd.tabComplete(this.plugin, sender, arguments)).orElseGet(Collections::emptyList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendCommandUsage(Sender sender, String label) {
|
private void sendCommandUsage(Sender sender, String label) {
|
||||||
Message.BLANK.send(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
Message.BLANK.send(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||||
this.mainCommands.stream()
|
this.mainCommands.values().stream()
|
||||||
.filter(Command::shouldDisplay)
|
.filter(Command::shouldDisplay)
|
||||||
.filter(c -> c.isAuthorized(sender))
|
.filter(c -> c.isAuthorized(sender))
|
||||||
.forEach(c -> {
|
.forEach(c -> {
|
||||||
@ -289,39 +259,6 @@ public class CommandManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandResult handleException(CommandException e, Sender sender, String label, Command command) {
|
|
||||||
if (e instanceof ArgumentParser.ArgumentException) {
|
|
||||||
if (e instanceof ArgumentParser.DetailedUsageException) {
|
|
||||||
command.sendDetailedUsage(sender, label);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidServerWorldException) {
|
|
||||||
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.PastDateException) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidDateException) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate());
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidPriorityException) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority());
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not something we can catch.
|
|
||||||
e.printStackTrace();
|
|
||||||
return CommandResult.FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles aliases
|
* Handles aliases
|
||||||
*
|
*
|
||||||
@ -390,26 +327,4 @@ public class CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Strips outer quote marks from a list of parsed arguments.
|
|
||||||
*
|
|
||||||
* @param input the list of arguments to strip quotes from
|
|
||||||
* @return an ArrayList containing the contents of input without quotes
|
|
||||||
*/
|
|
||||||
public static List<String> stripQuotes(List<String> input) {
|
|
||||||
input = new ArrayList<>(input);
|
|
||||||
ListIterator<String> iterator = input.listIterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
String value = iterator.next();
|
|
||||||
if (value.length() < 3) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
|
|
||||||
iterator.set(value.substring(1, value.length() - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ import java.util.function.Predicate;
|
|||||||
/**
|
/**
|
||||||
* Abstract SubCommand class
|
* Abstract SubCommand class
|
||||||
*/
|
*/
|
||||||
public abstract class SubCommand<T> extends Command<T, Void> {
|
public abstract class ChildCommand<T> extends Command<T> {
|
||||||
|
|
||||||
public SubCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
public ChildCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
||||||
super(spec, name, permission, argumentCheck);
|
super(spec, name, permission, argumentCheck);
|
||||||
}
|
}
|
||||||
|
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.command.abstraction;
|
package me.lucko.luckperms.common.command.abstraction;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.locale.command.Argument;
|
import me.lucko.luckperms.common.locale.command.Argument;
|
||||||
@ -46,9 +44,8 @@ import java.util.function.Predicate;
|
|||||||
* An abstract command class
|
* An abstract command class
|
||||||
*
|
*
|
||||||
* @param <T> the argument type required by the command
|
* @param <T> the argument type required by the command
|
||||||
* @param <S> the type of any child commands
|
|
||||||
*/
|
*/
|
||||||
public abstract class Command<T, S> {
|
public abstract class Command<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The commands specification.
|
* The commands specification.
|
||||||
@ -72,25 +69,11 @@ public abstract class Command<T, S> {
|
|||||||
*/
|
*/
|
||||||
private final @NonNull Predicate<Integer> argumentCheck;
|
private final @NonNull Predicate<Integer> argumentCheck;
|
||||||
|
|
||||||
/**
|
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck) {
|
||||||
* Child commands. Nullable.
|
|
||||||
*/
|
|
||||||
private final @Nullable List<Command<S, ?>> children;
|
|
||||||
|
|
||||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck, @Nullable List<Command<S, ?>> children) {
|
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.argumentCheck = argumentCheck;
|
this.argumentCheck = argumentCheck;
|
||||||
this.children = children == null ? null : ImmutableList.copyOf(children);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck) {
|
|
||||||
this(spec, name, permission, argumentCheck, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @NonNull Predicate<Integer> argumentCheck) {
|
|
||||||
this(spec, name, null, argumentCheck, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,15 +115,6 @@ public abstract class Command<T, S> {
|
|||||||
return this.argumentCheck;
|
return this.argumentCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the commands children
|
|
||||||
*
|
|
||||||
* @return any child commands
|
|
||||||
*/
|
|
||||||
public @NonNull Optional<List<Command<S, ?>>> getChildren() {
|
|
||||||
return Optional.ofNullable(this.children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the commands description.
|
* Gets the commands description.
|
||||||
*
|
*
|
||||||
|
@ -25,9 +25,22 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.command.abstraction;
|
package me.lucko.luckperms.common.command.abstraction;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception to be thrown if there is an error processing a command
|
* Exception to be thrown if there is an error processing a command
|
||||||
*/
|
*/
|
||||||
public class CommandException extends Exception {
|
public abstract class CommandException extends Exception {
|
||||||
|
|
||||||
|
public abstract CommandResult handle(Sender sender);
|
||||||
|
|
||||||
|
public CommandResult handle(Sender sender, String label, Command<?> command) {
|
||||||
|
return handle(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandResult handle(Sender sender, GenericChildCommand command) {
|
||||||
|
return handle(sender);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.locale.command.Argument;
|
import me.lucko.luckperms.common.locale.command.Argument;
|
||||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -42,7 +43,7 @@ import java.util.function.Predicate;
|
|||||||
* A sub command which can be be applied to both groups and users.
|
* A sub command which can be be applied to both groups and users.
|
||||||
* This doesn't extend the other Command or SubCommand classes to avoid generics hell.
|
* This doesn't extend the other Command or SubCommand classes to avoid generics hell.
|
||||||
*/
|
*/
|
||||||
public abstract class SharedSubCommand {
|
public abstract class GenericChildCommand {
|
||||||
|
|
||||||
private final LocalizedCommandSpec spec;
|
private final LocalizedCommandSpec spec;
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ public abstract class SharedSubCommand {
|
|||||||
*/
|
*/
|
||||||
private final Predicate<? super Integer> argumentCheck;
|
private final Predicate<? super Integer> argumentCheck;
|
||||||
|
|
||||||
public SharedSubCommand(LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate<? super Integer> argumentCheck) {
|
public GenericChildCommand(LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate<? super Integer> argumentCheck) {
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.userPermission = userPermission;
|
this.userPermission = userPermission;
|
||||||
@ -119,8 +120,15 @@ public abstract class SharedSubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(Sender sender, boolean user) {
|
public boolean isAuthorized(Sender sender, HolderType type) {
|
||||||
return user ? this.userPermission.isAuthorized(sender) : this.groupPermission.isAuthorized(sender);
|
switch (type) {
|
||||||
|
case USER:
|
||||||
|
return this.userPermission.isAuthorized(sender);
|
||||||
|
case GROUP:
|
||||||
|
return this.groupPermission.isAuthorized(sender);
|
||||||
|
default:
|
||||||
|
throw new AssertionError(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* 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.command.abstraction;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
|
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A shared main command. Shared meaning it can apply to both users and groups.
|
||||||
|
* This extends sub command as they're actually sub commands of the main user/group commands.
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class GenericParentCommand<T extends PermissionHolder> extends ChildCommand<T> {
|
||||||
|
|
||||||
|
private final List<GenericChildCommand> children;
|
||||||
|
|
||||||
|
private final HolderType type;
|
||||||
|
|
||||||
|
public GenericParentCommand(LocalizedCommandSpec spec, String name, HolderType type, List<GenericChildCommand> children) {
|
||||||
|
super(spec, name, null, Predicates.alwaysFalse());
|
||||||
|
this.children = children;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List<String> args, String label) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
sendUsageDetailed(sender, label);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericChildCommand sub = this.children.stream()
|
||||||
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (sub == null) {
|
||||||
|
Message.COMMAND_NOT_RECOGNISED.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sub.isAuthorized(sender, this.type)) {
|
||||||
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
|
return CommandResult.NO_PERMISSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub.getArgumentCheck().test(args.size() - 1)) {
|
||||||
|
sub.sendDetailedUsage(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandResult result;
|
||||||
|
try {
|
||||||
|
result = sub.execute(plugin, sender, holder, args.subList(1, args.size()), label, this.type == HolderType.USER ? sub.getUserPermission() : sub.getGroupPermission());
|
||||||
|
} catch (CommandException e) {
|
||||||
|
result = e.handle(sender, sub);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
|
return TabCompleter.create()
|
||||||
|
.at(0, CompletionSupplier.startsWith(() -> this.children.stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender, this.type))
|
||||||
|
.map(s -> s.getName().toLowerCase())
|
||||||
|
))
|
||||||
|
.from(1, partial -> this.children.stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender, this.type))
|
||||||
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
|
.findFirst()
|
||||||
|
.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(1, args.size())))
|
||||||
|
.orElse(Collections.emptyList())
|
||||||
|
)
|
||||||
|
.complete(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAuthorized(Sender sender) {
|
||||||
|
return this.children.stream().anyMatch(sc -> sc.isAuthorized(sender, this.type));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendUsageDetailed(Sender sender, String label) {
|
||||||
|
List<GenericChildCommand> subs = this.children.stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender, this.type))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!subs.isEmpty()) {
|
||||||
|
switch (this.type) {
|
||||||
|
case USER:
|
||||||
|
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s user <user> " + getName().toLowerCase(), label));
|
||||||
|
break;
|
||||||
|
case GROUP:
|
||||||
|
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s group <group> " + getName().toLowerCase(), label));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new AssertionError(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GenericChildCommand s : subs) {
|
||||||
|
s.sendUsage(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of LuckPerms, licensed under the MIT License.
|
|
||||||
*
|
|
||||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.command.abstraction;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
|
||||||
import me.lucko.luckperms.common.util.Predicates;
|
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public abstract class MainCommand<T, I> extends Command<Void, T> {
|
|
||||||
|
|
||||||
// equals 1 if the command doesn't take a mid argument, e.g. /lp log sub-command....
|
|
||||||
// equals 2 if the command does take a mid argument, e.g. /lp user <USER> sub-command....
|
|
||||||
private final int minArgs;
|
|
||||||
|
|
||||||
public MainCommand(LocalizedCommandSpec spec, String name, int minArgs, List<Command<T, ?>> children) {
|
|
||||||
super(spec, name, null, Predicates.alwaysFalse(), children);
|
|
||||||
this.minArgs = minArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) {
|
|
||||||
if (args.size() < this.minArgs) {
|
|
||||||
sendUsage(sender, label);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<Command<T, ?>> o = getChildren().get().stream()
|
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(this.minArgs - 1)))
|
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
if (!o.isPresent()) {
|
|
||||||
Message.COMMAND_NOT_RECOGNISED.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Command<T, ?> sub = o.get();
|
|
||||||
if (!sub.isAuthorized(sender)) {
|
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
|
||||||
return CommandResult.NO_PERMISSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> strippedArgs = new ArrayList<>();
|
|
||||||
if (args.size() > this.minArgs) {
|
|
||||||
strippedArgs.addAll(args.subList(this.minArgs, args.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sub.getArgumentCheck().test(strippedArgs.size())) {
|
|
||||||
sub.sendDetailedUsage(sender, label);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String name = args.get(0);
|
|
||||||
I targetId = parseTarget(name, plugin, sender);
|
|
||||||
if (targetId == null) {
|
|
||||||
return CommandResult.LOADING_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReentrantLock lock = getLockForTarget(targetId);
|
|
||||||
lock.lock();
|
|
||||||
try {
|
|
||||||
T target = getTarget(targetId, plugin, sender);
|
|
||||||
if (target != null) {
|
|
||||||
CommandResult result;
|
|
||||||
try {
|
|
||||||
result = sub.execute(plugin, sender, target, strippedArgs, label);
|
|
||||||
} catch (CommandException e) {
|
|
||||||
result = CommandManager.handleException(e, sender, label, sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup(target, plugin);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return CommandResult.LOADING_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
|
||||||
final List<String> objects = getTargets(plugin);
|
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
|
||||||
if (args.isEmpty() || args.get(0).trim().isEmpty()) {
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
return objects.stream()
|
|
||||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Command<T, ?>> subs = getChildren().get().stream()
|
|
||||||
.filter(s -> s.isAuthorized(sender))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
if (args.get(1).trim().isEmpty()) {
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.filter(s -> s.toLowerCase().startsWith(args.get(1).toLowerCase()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<Command<T, ?>> o = subs.stream()
|
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
return o.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(2, args.size()))).orElseGet(Collections::emptyList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract List<String> getTargets(LuckPermsPlugin plugin);
|
|
||||||
|
|
||||||
protected abstract I parseTarget(String target, LuckPermsPlugin plugin, Sender sender);
|
|
||||||
|
|
||||||
protected abstract ReentrantLock getLockForTarget(I target);
|
|
||||||
|
|
||||||
protected abstract T getTarget(I target, LuckPermsPlugin plugin, Sender sender);
|
|
||||||
|
|
||||||
protected abstract void cleanup(T t, LuckPermsPlugin plugin);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUsage(Sender sender, String label) {
|
|
||||||
List<Command> subs = getChildren().get().stream()
|
|
||||||
.filter(s -> s.isAuthorized(sender))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!subs.isEmpty()) {
|
|
||||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format(getUsage(), label));
|
|
||||||
for (Command s : subs) {
|
|
||||||
s.sendUsage(sender, label);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendDetailedUsage(Sender sender, String label) {
|
|
||||||
sendUsage(sender, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAuthorized(Sender sender) {
|
|
||||||
return getChildren().get().stream().anyMatch(sc -> sc.isAuthorized(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull Optional<List<Command<T, ?>>> getChildren() {
|
|
||||||
return super.getChildren();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* 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.command.abstraction;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier;
|
||||||
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
|
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class ParentCommand<T, I> extends Command<Void> {
|
||||||
|
|
||||||
|
/** Child sub commands */
|
||||||
|
private final List<Command<T>> children;
|
||||||
|
/** The type of parent command */
|
||||||
|
private final Type type;
|
||||||
|
|
||||||
|
public ParentCommand(LocalizedCommandSpec spec, String name, Type type, List<Command<T>> children) {
|
||||||
|
super(spec, name, null, Predicates.alwaysFalse());
|
||||||
|
this.children = children;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NonNull List<Command<T>> getChildren() {
|
||||||
|
return this.children;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void ignored, List<String> args, String label) {
|
||||||
|
// check if required argument and/or subcommand is missing
|
||||||
|
if (args.size() < this.type.minArgs) {
|
||||||
|
sendUsage(sender, label);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command<T> sub = getChildren().stream()
|
||||||
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(this.type.cmdIndex)))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (sub == null) {
|
||||||
|
Message.COMMAND_NOT_RECOGNISED.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sub.isAuthorized(sender)) {
|
||||||
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
|
return CommandResult.NO_PERMISSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub.getArgumentCheck().test(args.size() - this.type.minArgs)) {
|
||||||
|
sub.sendDetailedUsage(sender, label);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String targetArgument = args.get(0);
|
||||||
|
I targetId = null;
|
||||||
|
if (this.type == Type.TAKES_ARGUMENT_FOR_TARGET) {
|
||||||
|
targetId = parseTarget(targetArgument, plugin, sender);
|
||||||
|
if (targetId == null) {
|
||||||
|
return CommandResult.LOADING_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReentrantLock lock = getLockForTarget(targetId);
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
T target = getTarget(targetId, plugin, sender);
|
||||||
|
if (target == null) {
|
||||||
|
return CommandResult.LOADING_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandResult result;
|
||||||
|
try {
|
||||||
|
result = sub.execute(plugin, sender, target, args.subList(this.type.minArgs, args.size()), label);
|
||||||
|
} catch (CommandException e) {
|
||||||
|
result = e.handle(sender, label, sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup(target, plugin);
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
|
switch (this.type) {
|
||||||
|
case TAKES_ARGUMENT_FOR_TARGET:
|
||||||
|
return TabCompleter.create()
|
||||||
|
.at(0, CompletionSupplier.startsWith(() -> getTargets(plugin).stream()))
|
||||||
|
.at(1, CompletionSupplier.startsWith(() -> getChildren().stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender))
|
||||||
|
.map(s -> s.getName().toLowerCase())
|
||||||
|
))
|
||||||
|
.from(2, partial -> getChildren().stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender))
|
||||||
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
||||||
|
.findFirst()
|
||||||
|
.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(2, args.size())))
|
||||||
|
.orElse(Collections.emptyList())
|
||||||
|
)
|
||||||
|
.complete(args);
|
||||||
|
case NO_TARGET_ARGUMENT:
|
||||||
|
return TabCompleter.create()
|
||||||
|
.at(0, CompletionSupplier.startsWith(() -> getChildren().stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender))
|
||||||
|
.map(s -> s.getName().toLowerCase())
|
||||||
|
))
|
||||||
|
.from(1, partial -> getChildren().stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender))
|
||||||
|
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||||
|
.findFirst()
|
||||||
|
.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(1, args.size())))
|
||||||
|
.orElse(Collections.emptyList())
|
||||||
|
)
|
||||||
|
.complete(args);
|
||||||
|
default:
|
||||||
|
throw new AssertionError(this.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUsage(Sender sender, String label) {
|
||||||
|
List<Command<?>> subs = getChildren().stream()
|
||||||
|
.filter(s -> s.isAuthorized(sender))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!subs.isEmpty()) {
|
||||||
|
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format(getUsage(), label));
|
||||||
|
for (Command<?> s : subs) {
|
||||||
|
s.sendUsage(sender, label);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendDetailedUsage(Sender sender, String label) {
|
||||||
|
sendUsage(sender, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAuthorized(Sender sender) {
|
||||||
|
return getChildren().stream().anyMatch(sc -> sc.isAuthorized(sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<String> getTargets(LuckPermsPlugin plugin);
|
||||||
|
|
||||||
|
protected abstract I parseTarget(String target, LuckPermsPlugin plugin, Sender sender);
|
||||||
|
|
||||||
|
protected abstract ReentrantLock getLockForTarget(I target);
|
||||||
|
|
||||||
|
protected abstract T getTarget(I target, LuckPermsPlugin plugin, Sender sender);
|
||||||
|
|
||||||
|
protected abstract void cleanup(T t, LuckPermsPlugin plugin);
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
// e.g. /lp log sub-command....
|
||||||
|
NO_TARGET_ARGUMENT(0),
|
||||||
|
// e.g. /lp user <USER> sub-command....
|
||||||
|
TAKES_ARGUMENT_FOR_TARGET(1);
|
||||||
|
|
||||||
|
private final int cmdIndex;
|
||||||
|
private final int minArgs;
|
||||||
|
|
||||||
|
Type(int cmdIndex) {
|
||||||
|
this.cmdIndex = cmdIndex;
|
||||||
|
this.minArgs = cmdIndex + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of LuckPerms, licensed under the MIT License.
|
|
||||||
*
|
|
||||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.command.abstraction;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
|
||||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
|
||||||
import me.lucko.luckperms.common.util.Predicates;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A shared main command. Shared meaning it can apply to both users and groups.
|
|
||||||
* This extends sub command as they're actually sub commands of the main user/group commands.
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T> {
|
|
||||||
|
|
||||||
private final List<SharedSubCommand> secondaryCommands;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this instance of the shared command is targeting a user. Otherwise, it targets a group.
|
|
||||||
*/
|
|
||||||
private final boolean user;
|
|
||||||
|
|
||||||
public SharedMainCommand(LocalizedCommandSpec spec, String name, boolean user, List<SharedSubCommand> secondaryCommands) {
|
|
||||||
super(spec, name, null, Predicates.alwaysFalse());
|
|
||||||
this.secondaryCommands = secondaryCommands;
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) {
|
|
||||||
if (args.isEmpty()) {
|
|
||||||
sendUsageDetailed(sender, this.user, label);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<SharedSubCommand> o = this.secondaryCommands.stream()
|
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
if (!o.isPresent()) {
|
|
||||||
Message.COMMAND_NOT_RECOGNISED.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final SharedSubCommand sub = o.get();
|
|
||||||
if (!sub.isAuthorized(sender, this.user)) {
|
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
|
||||||
return CommandResult.NO_PERMISSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> strippedArgs = new ArrayList<>();
|
|
||||||
if (args.size() > 1) {
|
|
||||||
strippedArgs.addAll(args.subList(1, args.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sub.getArgumentCheck().test(strippedArgs.size())) {
|
|
||||||
sub.sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandResult result;
|
|
||||||
try {
|
|
||||||
result = sub.execute(plugin, sender, t, strippedArgs, label, this.user ? sub.getUserPermission() : sub.getGroupPermission());
|
|
||||||
} catch (CommandException e) {
|
|
||||||
result = handleException(e, sender, sub);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
|
||||||
final List<SharedSubCommand> subs = this.secondaryCommands.stream()
|
|
||||||
.filter(s -> s.isAuthorized(sender, this.user))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
|
||||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<SharedSubCommand> o = subs.stream()
|
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
return o.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(1, args.size()))).orElseGet(Collections::emptyList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAuthorized(Sender sender) {
|
|
||||||
return this.secondaryCommands.stream().anyMatch(sc -> sc.isAuthorized(sender, this.user));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUsageDetailed(Sender sender, boolean user, String label) {
|
|
||||||
List<SharedSubCommand> subs = this.secondaryCommands.stream()
|
|
||||||
.filter(s -> s.isAuthorized(sender, user))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!subs.isEmpty()) {
|
|
||||||
if (user) {
|
|
||||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s user <user> " + getName().toLowerCase(), label));
|
|
||||||
} else {
|
|
||||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s group <group> " + getName().toLowerCase(), label));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (SharedSubCommand s : subs) {
|
|
||||||
s.sendUsage(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CommandResult handleException(CommandException e, Sender sender, SharedSubCommand command) {
|
|
||||||
if (e instanceof ArgumentParser.ArgumentException) {
|
|
||||||
if (e instanceof ArgumentParser.DetailedUsageException) {
|
|
||||||
command.sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidServerWorldException) {
|
|
||||||
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.PastDateException) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidDateException) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate());
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e instanceof ArgumentParser.InvalidPriorityException) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority());
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not something we can catch.
|
|
||||||
e.printStackTrace();
|
|
||||||
return CommandResult.FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,10 +39,10 @@ import java.util.function.Predicate;
|
|||||||
/**
|
/**
|
||||||
* Represents a single "main" command (one without any children)
|
* Represents a single "main" command (one without any children)
|
||||||
*/
|
*/
|
||||||
public abstract class SingleCommand extends Command<Void, Void> {
|
public abstract class SingleCommand extends Command<Void> {
|
||||||
|
|
||||||
public SingleCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
public SingleCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
||||||
super(spec, name, permission, argumentCheck, null);
|
super(spec, name, permission, argumentCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,21 +31,22 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public interface CompletionSupplier {
|
public interface CompletionSupplier {
|
||||||
|
|
||||||
CompletionSupplier EMPTY = partial -> Collections.emptyList();
|
CompletionSupplier EMPTY = partial -> Collections.emptyList();
|
||||||
|
|
||||||
static CompletionSupplier startsWith(String... strings) {
|
static CompletionSupplier startsWith(String... strings) {
|
||||||
return partial -> Arrays.stream(strings).filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
return startsWith(() -> Arrays.stream(strings));
|
||||||
}
|
}
|
||||||
|
|
||||||
static CompletionSupplier startsWith(Collection<String> strings) {
|
static CompletionSupplier startsWith(Collection<String> strings) {
|
||||||
return partial -> strings.stream().filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
return startsWith(strings::stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CompletionSupplier startsWith(Supplier<? extends Collection<String>> stringsSupplier) {
|
static CompletionSupplier startsWith(Supplier<Stream<String>> stringsSupplier) {
|
||||||
return partial -> stringsSupplier.get().stream().filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
return partial -> stringsSupplier.get().filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> supplyCompletions(String partial);
|
List<String> supplyCompletions(String partial);
|
||||||
|
@ -52,8 +52,8 @@ public final class TabCompletions {
|
|||||||
private final CompletionSupplier contexts;
|
private final CompletionSupplier contexts;
|
||||||
|
|
||||||
public TabCompletions(LuckPermsPlugin plugin) {
|
public TabCompletions(LuckPermsPlugin plugin) {
|
||||||
this.groups = CompletionSupplier.startsWith(() -> plugin.getGroupManager().getAll().keySet());
|
this.groups = CompletionSupplier.startsWith(() -> plugin.getGroupManager().getAll().keySet().stream());
|
||||||
this.tracks = CompletionSupplier.startsWith(() -> plugin.getTrackManager().getAll().keySet());
|
this.tracks = CompletionSupplier.startsWith(() -> plugin.getTrackManager().getAll().keySet().stream());
|
||||||
this.permissions = partial -> {
|
this.permissions = partial -> {
|
||||||
PermissionRegistry cache = plugin.getPermissionRegistry();
|
PermissionRegistry cache = plugin.getPermissionRegistry();
|
||||||
|
|
||||||
|
@ -25,10 +25,14 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.command.utils;
|
package me.lucko.luckperms.common.command.utils;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
|
import me.lucko.luckperms.common.commands.user.UserParentCommand;
|
||||||
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
||||||
import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl;
|
import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||||
@ -210,13 +214,39 @@ public class ArgumentParser {
|
|||||||
|
|
||||||
public static UUID parseUserTarget(int index, List<String> args, LuckPermsPlugin plugin, Sender sender) {
|
public static UUID parseUserTarget(int index, List<String> args, LuckPermsPlugin plugin, Sender sender) {
|
||||||
final String target = args.get(index);
|
final String target = args.get(index);
|
||||||
return UserMainCommand.parseTargetUniqueId(target, plugin, sender);
|
return UserParentCommand.parseTargetUniqueId(target, plugin, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class ArgumentException extends CommandException {}
|
public abstract static class ArgumentException extends CommandException {
|
||||||
public static class DetailedUsageException extends ArgumentException {}
|
|
||||||
public static class InvalidServerWorldException extends ArgumentException {}
|
}
|
||||||
public static class PastDateException extends ArgumentException {}
|
|
||||||
|
public static class DetailedUsageException extends ArgumentException {
|
||||||
|
@Override
|
||||||
|
public CommandResult handle(Sender sender) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult handle(Sender sender, String label, Command<?> command) {
|
||||||
|
command.sendDetailedUsage(sender, label);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult handle(Sender sender, GenericChildCommand command) {
|
||||||
|
command.sendDetailedUsage(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PastDateException extends ArgumentException {
|
||||||
|
@Override
|
||||||
|
public CommandResult handle(Sender sender) {
|
||||||
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class InvalidDateException extends ArgumentException {
|
public static class InvalidDateException extends ArgumentException {
|
||||||
private final String invalidDate;
|
private final String invalidDate;
|
||||||
@ -225,8 +255,10 @@ public class ArgumentParser {
|
|||||||
this.invalidDate = invalidDate;
|
this.invalidDate = invalidDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInvalidDate() {
|
@Override
|
||||||
return this.invalidDate;
|
public CommandResult handle(Sender sender) {
|
||||||
|
Message.ILLEGAL_DATE_ERROR.send(sender, this.invalidDate);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,8 +269,10 @@ public class ArgumentParser {
|
|||||||
this.invalidPriority = invalidPriority;
|
this.invalidPriority = invalidPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInvalidPriority() {
|
@Override
|
||||||
return this.invalidPriority;
|
public CommandResult handle(Sender sender) {
|
||||||
|
Message.META_INVALID_PRIORITY.send(sender, this.invalidPriority);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* 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.command.utils;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tokenizes command input into distinct "argument" tokens.
|
||||||
|
*
|
||||||
|
* <p>Splits on whitespace, except when surrounded by quotes.</p>
|
||||||
|
*/
|
||||||
|
public enum ArgumentTokenizer {
|
||||||
|
|
||||||
|
EXECUTE {
|
||||||
|
@Override
|
||||||
|
public List<String> tokenizeInput(String[] args) {
|
||||||
|
return stripQuotes(EXECUTE_ARGUMENT_SPLITTER.split(ARGUMENT_JOINER.join(args)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tokenizeInput(String args) {
|
||||||
|
return stripQuotes(EXECUTE_ARGUMENT_SPLITTER.split(args));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TAB_COMPLETE {
|
||||||
|
@Override
|
||||||
|
public List<String> tokenizeInput(String[] args) {
|
||||||
|
return stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.split(ARGUMENT_JOINER.join(args)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tokenizeInput(String args) {
|
||||||
|
return stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.split(args));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final Pattern ARGUMENT_SEPARATOR_PATTERN = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||||
|
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(ARGUMENT_SEPARATOR_PATTERN);
|
||||||
|
private static final Splitter EXECUTE_ARGUMENT_SPLITTER = TAB_COMPLETE_ARGUMENT_SPLITTER.omitEmptyStrings();
|
||||||
|
private static final Joiner ARGUMENT_JOINER = Joiner.on(' ');
|
||||||
|
|
||||||
|
public abstract List<String> tokenizeInput(String[] args);
|
||||||
|
|
||||||
|
public abstract List<String> tokenizeInput(String args);
|
||||||
|
|
||||||
|
private static List<String> stripQuotes(Iterable<String> input) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (String argument : input) {
|
||||||
|
if (argument.length() >= 3 && argument.charAt(0) == '"' && argument.charAt(argument.length() - 1) == '"') {
|
||||||
|
list.add(argument.substring(1, argument.length() - 1));
|
||||||
|
} else {
|
||||||
|
list.add(argument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@ -146,7 +146,7 @@ public final class MessageUtils {
|
|||||||
|
|
||||||
public static String contextSetToString(LocaleManager localeManager, ContextSet set) {
|
public static String contextSetToString(LocaleManager localeManager, ContextSet set) {
|
||||||
if (set.isEmpty()) {
|
if (set.isEmpty()) {
|
||||||
return Message.CONTEXT_PAIR__GLOBAL_INLINE.asString(localeManager);
|
return Message.CONTEXT_PAIR_GLOBAL_INLINE.asString(localeManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -27,17 +27,18 @@ 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.command.abstraction.SharedMainCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericParentCommand;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
|
|
||||||
import net.luckperms.api.node.ChatMetaType;
|
import net.luckperms.api.node.ChatMetaType;
|
||||||
|
|
||||||
public class CommandMeta<T extends PermissionHolder> extends SharedMainCommand<T> {
|
public class CommandMeta<T extends PermissionHolder> extends GenericParentCommand<T> {
|
||||||
public CommandMeta(LocaleManager locale, boolean user) {
|
public CommandMeta(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.META.localize(locale), "Meta", user, ImmutableList.<SharedSubCommand>builder()
|
super(CommandSpec.META.localize(locale), "Meta", type, ImmutableList.<GenericChildCommand>builder()
|
||||||
.add(new MetaInfo(locale))
|
.add(new MetaInfo(locale))
|
||||||
.add(new MetaSet(locale))
|
.add(new MetaSet(locale))
|
||||||
.add(new MetaUnset(locale))
|
.add(new MetaUnset(locale))
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.ChatMetaType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaAddChatMeta extends SharedSubCommand {
|
public class MetaAddChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaAddChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaAddChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -58,7 +58,7 @@ import net.luckperms.api.node.ChatMetaType;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaAddTempChatMeta extends SharedSubCommand {
|
public class MetaAddTempChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaAddTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaAddTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaClear extends SharedSubCommand {
|
public class MetaClear extends GenericChildCommand {
|
||||||
public MetaClear(LocaleManager locale) {
|
public MetaClear(LocaleManager locale) {
|
||||||
super(CommandSpec.META_CLEAR.localize(locale), "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse());
|
super(CommandSpec.META_CLEAR.localize(locale), "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
@ -67,7 +67,7 @@ import java.util.SortedSet;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class MetaInfo extends SharedSubCommand {
|
public class MetaInfo extends GenericChildCommand {
|
||||||
private static String processLocation(Node node, PermissionHolder holder) {
|
private static String processLocation(Node node, PermissionHolder holder) {
|
||||||
String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName();
|
String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName();
|
||||||
return location.equalsIgnoreCase(holder.getObjectName()) ? "self" : location;
|
return location.equalsIgnoreCase(holder.getObjectName()) ? "self" : location;
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.ChatMetaType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaRemoveChatMeta extends SharedSubCommand {
|
public class MetaRemoveChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaRemoveChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaRemoveChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.ChatMetaType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
public class MetaRemoveTempChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaRemoveTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaRemoveTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -56,7 +56,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaSet extends SharedSubCommand {
|
public class MetaSet extends GenericChildCommand {
|
||||||
public MetaSet(LocaleManager locale) {
|
public MetaSet(LocaleManager locale) {
|
||||||
super(CommandSpec.META_SET.localize(locale), "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1));
|
super(CommandSpec.META_SET.localize(locale), "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction;
|
|||||||
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
|
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -58,7 +58,7 @@ import net.luckperms.api.query.QueryOptions;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class MetaSetChatMeta extends SharedSubCommand {
|
public class MetaSetChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaSetChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaSetChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -60,7 +60,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaSetTemp extends SharedSubCommand {
|
public class MetaSetTemp extends GenericChildCommand {
|
||||||
public MetaSetTemp(LocaleManager locale) {
|
public MetaSetTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.META_SETTEMP.localize(locale), "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2));
|
super(CommandSpec.META_SETTEMP.localize(locale), "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction;
|
|||||||
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
|
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -62,7 +62,7 @@ import java.time.Duration;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class MetaSetTempChatMeta extends SharedSubCommand {
|
public class MetaSetTempChatMeta extends GenericChildCommand {
|
||||||
private final ChatMetaType type;
|
private final ChatMetaType type;
|
||||||
|
|
||||||
public MetaSetTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
public MetaSetTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaUnset extends SharedSubCommand {
|
public class MetaUnset extends GenericChildCommand {
|
||||||
public MetaUnset(LocaleManager locale) {
|
public MetaUnset(LocaleManager locale) {
|
||||||
super(CommandSpec.META_UNSET.localize(locale), "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0));
|
super(CommandSpec.META_UNSET.localize(locale), "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MetaUnsetTemp extends SharedSubCommand {
|
public class MetaUnsetTemp extends GenericChildCommand {
|
||||||
public MetaUnsetTemp(LocaleManager locale) {
|
public MetaUnsetTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.META_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0));
|
super(CommandSpec.META_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.common.commands.generic.other;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -39,6 +39,7 @@ import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -49,9 +50,9 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
public class HolderClear<T extends PermissionHolder> extends ChildCommand<T> {
|
||||||
public HolderClear(LocaleManager locale, boolean user) {
|
public HolderClear(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.HOLDER_CLEAR.localize(locale), "clear", user ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse());
|
super(CommandSpec.HOLDER_CLEAR.localize(locale), "clear", type == HolderType.USER ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,13 +28,14 @@ package me.lucko.luckperms.common.commands.generic.other;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -44,9 +45,9 @@ import me.lucko.luckperms.common.web.WebEditor;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HolderEditor<T extends PermissionHolder> extends SubCommand<T> {
|
public class HolderEditor<T extends PermissionHolder> extends ChildCommand<T> {
|
||||||
public HolderEditor(LocaleManager locale, boolean user) {
|
public HolderEditor(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.HOLDER_EDITOR.localize(locale), "editor", user ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse());
|
super(CommandSpec.HOLDER_EDITOR.localize(locale), "editor", type == HolderType.USER ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.other;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
@ -52,9 +52,9 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T> {
|
public class HolderShowTracks<T extends PermissionHolder> extends ChildCommand<T> {
|
||||||
public HolderShowTracks(LocaleManager locale, boolean user) {
|
public HolderShowTracks(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.HOLDER_SHOWTRACKS.localize(locale), "showtracks", user ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse());
|
super(CommandSpec.HOLDER_SHOWTRACKS.localize(locale), "showtracks", type == HolderType.USER ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,17 +27,18 @@ 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.command.abstraction.SharedMainCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericParentCommand;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class CommandParent<T extends PermissionHolder> extends SharedMainCommand<T> {
|
public class CommandParent<T extends PermissionHolder> extends GenericParentCommand<T> {
|
||||||
public CommandParent(LocaleManager locale, boolean user) {
|
public CommandParent(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.PARENT.localize(locale), "Parent", user, ImmutableList.<SharedSubCommand>builder()
|
super(CommandSpec.PARENT.localize(locale), "Parent", type, ImmutableList.<GenericChildCommand>builder()
|
||||||
.add(new ParentInfo(locale))
|
.add(new ParentInfo(locale))
|
||||||
.add(new ParentSet(locale))
|
.add(new ParentSet(locale))
|
||||||
.add(new ParentAdd(locale))
|
.add(new ParentAdd(locale))
|
||||||
@ -47,7 +48,7 @@ public class CommandParent<T extends PermissionHolder> extends SharedMainCommand
|
|||||||
.add(new ParentRemoveTemp(locale))
|
.add(new ParentRemoveTemp(locale))
|
||||||
.add(new ParentClear(locale))
|
.add(new ParentClear(locale))
|
||||||
.add(new ParentClearTrack(locale))
|
.add(new ParentClearTrack(locale))
|
||||||
.addAll(user ? Collections.singleton(new UserSwitchPrimaryGroup(locale)) : Collections.emptySet())
|
.addAll(type == HolderType.USER ? Collections.singleton(new UserSwitchPrimaryGroup(locale)) : Collections.emptySet())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -52,7 +52,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentAdd extends SharedSubCommand {
|
public class ParentAdd extends GenericChildCommand {
|
||||||
public ParentAdd(LocaleManager locale) {
|
public ParentAdd(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_ADD.localize(locale), "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0));
|
super(CommandSpec.PARENT_ADD.localize(locale), "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -56,7 +56,7 @@ import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentAddTemp extends SharedSubCommand {
|
public class ParentAddTemp extends GenericChildCommand {
|
||||||
public ParentAddTemp(LocaleManager locale) {
|
public ParentAddTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_ADD_TEMP.localize(locale), "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1));
|
super(CommandSpec.PARENT_ADD_TEMP.localize(locale), "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentClear extends SharedSubCommand {
|
public class ParentClear extends GenericChildCommand {
|
||||||
public ParentClear(LocaleManager locale) {
|
public ParentClear(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_CLEAR.localize(locale), "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse());
|
super(CommandSpec.PARENT_CLEAR.localize(locale), "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentClearTrack extends SharedSubCommand {
|
public class ParentClearTrack extends GenericChildCommand {
|
||||||
public ParentClearTrack(LocaleManager locale) {
|
public ParentClearTrack(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_CLEAR_TRACK.localize(locale), "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0));
|
super(CommandSpec.PARENT_CLEAR_TRACK.localize(locale), "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
@ -60,7 +60,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ParentInfo extends SharedSubCommand {
|
public class ParentInfo extends GenericChildCommand {
|
||||||
public ParentInfo(LocaleManager locale) {
|
public ParentInfo(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_INFO.localize(locale), "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2));
|
super(CommandSpec.PARENT_INFO.localize(locale), "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -55,7 +55,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentRemove extends SharedSubCommand {
|
public class ParentRemove extends GenericChildCommand {
|
||||||
public ParentRemove(LocaleManager locale) {
|
public ParentRemove(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_REMOVE.localize(locale), "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0));
|
super(CommandSpec.PARENT_REMOVE.localize(locale), "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -51,7 +51,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentRemoveTemp extends SharedSubCommand {
|
public class ParentRemoveTemp extends GenericChildCommand {
|
||||||
public ParentRemoveTemp(LocaleManager locale) {
|
public ParentRemoveTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_REMOVE_TEMP.localize(locale), "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0));
|
super(CommandSpec.PARENT_REMOVE_TEMP.localize(locale), "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentSet extends SharedSubCommand {
|
public class ParentSet extends GenericChildCommand {
|
||||||
public ParentSet(LocaleManager locale) {
|
public ParentSet(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_SET.localize(locale), "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0));
|
super(CommandSpec.PARENT_SET.localize(locale), "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -54,7 +54,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParentSetTrack extends SharedSubCommand {
|
public class ParentSetTrack extends GenericChildCommand {
|
||||||
public ParentSetTrack(LocaleManager locale) {
|
public ParentSetTrack(LocaleManager locale) {
|
||||||
super(CommandSpec.PARENT_SET_TRACK.localize(locale), "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1));
|
super(CommandSpec.PARENT_SET_TRACK.localize(locale), "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.generic.parent;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -53,7 +53,7 @@ import net.luckperms.api.node.NodeEqualityPredicate;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UserSwitchPrimaryGroup extends SharedSubCommand {
|
public class UserSwitchPrimaryGroup extends GenericChildCommand {
|
||||||
public UserSwitchPrimaryGroup(LocaleManager locale) {
|
public UserSwitchPrimaryGroup(LocaleManager locale) {
|
||||||
super(CommandSpec.USER_SWITCHPRIMARYGROUP.localize(locale), "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1));
|
super(CommandSpec.USER_SWITCHPRIMARYGROUP.localize(locale), "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,16 @@ 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.command.abstraction.SharedMainCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericParentCommand;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
|
|
||||||
public class CommandPermission<T extends PermissionHolder> extends SharedMainCommand<T> {
|
public class CommandPermission<T extends PermissionHolder> extends GenericParentCommand<T> {
|
||||||
public CommandPermission(LocaleManager locale, boolean user) {
|
public CommandPermission(LocaleManager locale, HolderType type) {
|
||||||
super(CommandSpec.PERMISSION.localize(locale), "Permission", user, ImmutableList.<SharedSubCommand>builder()
|
super(CommandSpec.PERMISSION.localize(locale), "Permission", type, ImmutableList.<GenericChildCommand>builder()
|
||||||
.add(new PermissionInfo(locale))
|
.add(new PermissionInfo(locale))
|
||||||
.add(new PermissionSet(locale))
|
.add(new PermissionSet(locale))
|
||||||
.add(new PermissionUnset(locale))
|
.add(new PermissionUnset(locale))
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.util.Tristate;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionCheck extends SharedSubCommand {
|
public class PermissionCheck extends GenericChildCommand {
|
||||||
public PermissionCheck(LocaleManager locale) {
|
public PermissionCheck(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_CHECK.localize(locale), "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0));
|
super(CommandSpec.PERMISSION_CHECK.localize(locale), "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -51,7 +51,7 @@ import net.luckperms.api.util.Tristate;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class PermissionCheckInherits extends SharedSubCommand {
|
public class PermissionCheckInherits extends GenericChildCommand {
|
||||||
public PermissionCheckInherits(LocaleManager locale) {
|
public PermissionCheckInherits(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_CHECK_INHERITS.localize(locale), "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0));
|
super(CommandSpec.PERMISSION_CHECK_INHERITS.localize(locale), "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -50,7 +50,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionClear extends SharedSubCommand {
|
public class PermissionClear extends GenericChildCommand {
|
||||||
public PermissionClear(LocaleManager locale) {
|
public PermissionClear(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_CLEAR.localize(locale), "clear", CommandPermission.USER_PERM_CLEAR, CommandPermission.GROUP_PERM_CLEAR, Predicates.alwaysFalse());
|
super(CommandSpec.PERMISSION_CLEAR.localize(locale), "clear", CommandPermission.USER_PERM_CLEAR, CommandPermission.GROUP_PERM_CLEAR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
@ -60,7 +60,7 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class PermissionInfo extends SharedSubCommand {
|
public class PermissionInfo extends GenericChildCommand {
|
||||||
public PermissionInfo(LocaleManager locale) {
|
public PermissionInfo(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_INFO.localize(locale), "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2));
|
super(CommandSpec.PERMISSION_INFO.localize(locale), "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -53,7 +53,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionSet extends SharedSubCommand {
|
public class PermissionSet extends GenericChildCommand {
|
||||||
public PermissionSet(LocaleManager locale) {
|
public PermissionSet(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_SET.localize(locale), "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0));
|
super(CommandSpec.PERMISSION_SET.localize(locale), "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -57,7 +57,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionSetTemp extends SharedSubCommand {
|
public class PermissionSetTemp extends GenericChildCommand {
|
||||||
public PermissionSetTemp(LocaleManager locale) {
|
public PermissionSetTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_SETTEMP.localize(locale), "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2));
|
super(CommandSpec.PERMISSION_SETTEMP.localize(locale), "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -53,7 +53,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionUnset extends SharedSubCommand {
|
public class PermissionUnset extends GenericChildCommand {
|
||||||
public PermissionUnset(LocaleManager locale) {
|
public PermissionUnset(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_UNSET.localize(locale), "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0));
|
super(CommandSpec.PERMISSION_UNSET.localize(locale), "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission;
|
|||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
import me.lucko.luckperms.common.command.abstraction.GenericChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -53,7 +53,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionUnsetTemp extends SharedSubCommand {
|
public class PermissionUnsetTemp extends GenericChildCommand {
|
||||||
public PermissionUnsetTemp(LocaleManager locale) {
|
public PermissionUnsetTemp(LocaleManager locale) {
|
||||||
super(CommandSpec.PERMISSION_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0));
|
super(CommandSpec.PERMISSION_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
@ -45,7 +45,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupClone extends SubCommand<Group> {
|
public class GroupClone extends ChildCommand<Group> {
|
||||||
public GroupClone(LocaleManager locale) {
|
public GroupClone(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_CLONE.localize(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1));
|
super(CommandSpec.GROUP_CLONE.localize(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.group;
|
package me.lucko.luckperms.common.commands.group;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
@ -45,7 +45,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GroupInfo extends SubCommand<Group> {
|
public class GroupInfo extends ChildCommand<Group> {
|
||||||
public GroupInfo(LocaleManager locale) {
|
public GroupInfo(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_INFO.localize(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse());
|
super(CommandSpec.GROUP_INFO.localize(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import me.lucko.luckperms.common.bulkupdate.comparison.Constraint;
|
|||||||
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
|
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
|
||||||
import me.lucko.luckperms.common.cache.LoadingMap;
|
import me.lucko.luckperms.common.cache.LoadingMap;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
@ -68,7 +68,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GroupListMembers extends SubCommand<Group> {
|
public class GroupListMembers extends ChildCommand<Group> {
|
||||||
public GroupListMembers(LocaleManager locale) {
|
public GroupListMembers(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_LISTMEMBERS.localize(locale), "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1));
|
super(CommandSpec.GROUP_LISTMEMBERS.localize(locale), "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
import me.lucko.luckperms.common.command.abstraction.ParentCommand;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
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.HolderClear;
|
import me.lucko.luckperms.common.commands.generic.other.HolderClear;
|
||||||
@ -40,6 +40,7 @@ import me.lucko.luckperms.common.commands.generic.permission.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.util.CaffeineFactory;
|
import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||||
@ -49,7 +50,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class GroupMainCommand extends MainCommand<Group, String> {
|
public class GroupParentCommand extends ParentCommand<Group, String> {
|
||||||
|
|
||||||
// we use a lock per unique group
|
// we use a lock per unique group
|
||||||
// this helps prevent race conditions where commands are being executed concurrently
|
// this helps prevent race conditions where commands are being executed concurrently
|
||||||
@ -59,18 +60,18 @@ public class GroupMainCommand extends MainCommand<Group, String> {
|
|||||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||||
.build(key -> new ReentrantLock());
|
.build(key -> new ReentrantLock());
|
||||||
|
|
||||||
public GroupMainCommand(LocaleManager locale) {
|
public GroupParentCommand(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP.localize(locale), "Group", 2, ImmutableList.<Command<Group, ?>>builder()
|
super(CommandSpec.GROUP.localize(locale), "Group", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.<Command<Group>>builder()
|
||||||
.add(new GroupInfo(locale))
|
.add(new GroupInfo(locale))
|
||||||
.add(new CommandPermission<>(locale, false))
|
.add(new CommandPermission<>(locale, HolderType.GROUP))
|
||||||
.add(new CommandParent<>(locale, false))
|
.add(new CommandParent<>(locale, HolderType.GROUP))
|
||||||
.add(new CommandMeta<>(locale, false))
|
.add(new CommandMeta<>(locale, HolderType.GROUP))
|
||||||
.add(new HolderEditor<>(locale, false))
|
.add(new HolderEditor<>(locale, HolderType.GROUP))
|
||||||
.add(new GroupListMembers(locale))
|
.add(new GroupListMembers(locale))
|
||||||
.add(new GroupSetWeight(locale))
|
.add(new GroupSetWeight(locale))
|
||||||
.add(new GroupSetDisplayName(locale))
|
.add(new GroupSetDisplayName(locale))
|
||||||
.add(new HolderShowTracks<>(locale, false))
|
.add(new HolderShowTracks<>(locale, HolderType.GROUP))
|
||||||
.add(new HolderClear<>(locale, false))
|
.add(new HolderClear<>(locale, HolderType.GROUP))
|
||||||
.add(new GroupRename(locale))
|
.add(new GroupRename(locale))
|
||||||
.add(new GroupClone(locale))
|
.add(new GroupClone(locale))
|
||||||
.build()
|
.build()
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -45,7 +45,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupRename extends SubCommand<Group> {
|
public class GroupRename extends ChildCommand<Group> {
|
||||||
public GroupRename(LocaleManager locale) {
|
public GroupRename(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_RENAME.localize(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1));
|
super(CommandSpec.GROUP_RENAME.localize(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.common.commands.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -52,7 +52,7 @@ import net.luckperms.api.node.types.DisplayNameNode;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupSetDisplayName extends SubCommand<Group> {
|
public class GroupSetDisplayName extends ChildCommand<Group> {
|
||||||
public GroupSetDisplayName(LocaleManager locale) {
|
public GroupSetDisplayName(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_SET_DISPLAY_NAME.localize(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.is(0));
|
super(CommandSpec.GROUP_SET_DISPLAY_NAME.localize(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.common.commands.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
@ -47,7 +47,7 @@ import net.luckperms.api.node.NodeType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupSetWeight extends SubCommand<Group> {
|
public class GroupSetWeight extends ChildCommand<Group> {
|
||||||
public GroupSetWeight(LocaleManager locale) {
|
public GroupSetWeight(LocaleManager locale) {
|
||||||
super(CommandSpec.GROUP_SETWEIGHT.localize(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1));
|
super(CommandSpec.GROUP_SETWEIGHT.localize(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
@ -49,7 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
public class LogGroupHistory extends SubCommand<Log> {
|
public class LogGroupHistory extends ChildCommand<Log> {
|
||||||
private static final int ENTRIES_PER_PAGE = 10;
|
private static final int ENTRIES_PER_PAGE = 10;
|
||||||
|
|
||||||
public LogGroupHistory(LocaleManager locale) {
|
public LogGroupHistory(LocaleManager locale) {
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -46,7 +46,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class LogNotify extends SubCommand<Log> {
|
public class LogNotify extends ChildCommand<Log> {
|
||||||
private static final String IGNORE_NODE = "luckperms.log.notify.ignoring";
|
private static final String IGNORE_NODE = "luckperms.log.notify.ignoring";
|
||||||
|
|
||||||
public LogNotify(LocaleManager locale) {
|
public LogNotify(LocaleManager locale) {
|
||||||
|
@ -29,24 +29,21 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
import me.lucko.luckperms.common.command.abstraction.ParentCommand;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class LogMainCommand extends MainCommand<Log, Object> {
|
public class LogParentCommand extends ParentCommand<Log, Void> {
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
public LogMainCommand(LocaleManager locale) {
|
public LogParentCommand(LocaleManager locale) {
|
||||||
super(CommandSpec.LOG.localize(locale), "Log", 1, ImmutableList.<Command<Log, ?>>builder()
|
super(CommandSpec.LOG.localize(locale), "Log", Type.NO_TARGET_ARGUMENT, ImmutableList.<Command<Log>>builder()
|
||||||
.add(new LogRecent(locale))
|
.add(new LogRecent(locale))
|
||||||
.add(new LogSearch(locale))
|
.add(new LogSearch(locale))
|
||||||
.add(new LogNotify(locale))
|
.add(new LogNotify(locale))
|
||||||
@ -58,17 +55,12 @@ public class LogMainCommand extends MainCommand<Log, Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReentrantLock getLockForTarget(Object target) {
|
protected ReentrantLock getLockForTarget(Void target) {
|
||||||
return this.lock; // all commands target the same log, so we share a lock between all "targets"
|
return this.lock; // all commands target the same log, so we share a lock between all "targets"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
protected Log getTarget(Void target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Log getTarget(Object target, LuckPermsPlugin plugin, Sender sender) {
|
|
||||||
Log log = plugin.getStorage().getLog().join();
|
Log log = plugin.getStorage().getLog().join();
|
||||||
|
|
||||||
if (log == null) {
|
if (log == null) {
|
||||||
@ -85,33 +77,14 @@ public class LogMainCommand extends MainCommand<Log, Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return null; // only used for tab completion in super, and we override this method
|
// should never be called if we specify Type.NO_TARGET_ARGUMENT in the constructor
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
protected Void parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
final List<Command<Log, ?>> subs = getChildren().get().stream()
|
// should never be called if we specify Type.NO_TARGET_ARGUMENT in the constructor
|
||||||
.filter(s -> s.isAuthorized(sender))
|
throw new UnsupportedOperationException();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (args.size() <= 1) {
|
|
||||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return subs.stream()
|
|
||||||
.map(m -> m.getName().toLowerCase())
|
|
||||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<Command<Log, ?>> o = subs.stream()
|
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
return o.map(cmd -> cmd.tabComplete(plugin, sender, args.subList(1, args.size()))).orElseGet(Collections::emptyList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -47,7 +47,7 @@ import java.util.Map;
|
|||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class LogRecent extends SubCommand<Log> {
|
public class LogRecent extends ChildCommand<Log> {
|
||||||
private static final int ENTRIES_PER_PAGE = 10;
|
private static final int ENTRIES_PER_PAGE = 10;
|
||||||
|
|
||||||
public LogRecent(LocaleManager locale) {
|
public LogRecent(LocaleManager locale) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
@ -45,7 +45,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
public class LogSearch extends SubCommand<Log> {
|
public class LogSearch extends ChildCommand<Log> {
|
||||||
private static final int ENTRIES_PER_PAGE = 10;
|
private static final int ENTRIES_PER_PAGE = 10;
|
||||||
|
|
||||||
public LogSearch(LocaleManager locale) {
|
public LogSearch(LocaleManager locale) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
@ -49,7 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
public class LogTrackHistory extends SubCommand<Log> {
|
public class LogTrackHistory extends ChildCommand<Log> {
|
||||||
private static final int ENTRIES_PER_PAGE = 10;
|
private static final int ENTRIES_PER_PAGE = 10;
|
||||||
|
|
||||||
public LogTrackHistory(LocaleManager locale) {
|
public LogTrackHistory(LocaleManager locale) {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.log;
|
|||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -47,7 +47,7 @@ import java.util.Map;
|
|||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class LogUserHistory extends SubCommand<Log> {
|
public class LogUserHistory extends ChildCommand<Log> {
|
||||||
private static final int ENTRIES_PER_PAGE = 10;
|
private static final int ENTRIES_PER_PAGE = 10;
|
||||||
|
|
||||||
public LogUserHistory(LocaleManager locale) {
|
public LogUserHistory(LocaleManager locale) {
|
||||||
|
@ -28,9 +28,9 @@ package me.lucko.luckperms.common.commands.migration;
|
|||||||
import com.google.common.collect.ImmutableBiMap;
|
import com.google.common.collect.ImmutableBiMap;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
import me.lucko.luckperms.common.command.abstraction.ParentCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
@ -41,13 +41,11 @@ import me.lucko.luckperms.common.util.Predicates;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class MigrationMainCommand extends MainCommand<Object, Object> {
|
public class MigrationParentCommand extends ParentCommand<Object, Void> {
|
||||||
private static final Map<String, String> PLUGINS = ImmutableBiMap.<String, String>builder()
|
private static final Map<String, String> PLUGINS = ImmutableBiMap.<String, String>builder()
|
||||||
// bukkit
|
// bukkit
|
||||||
.put("me.lucko.luckperms.bukkit.migration.MigrationGroupManager", "org.anjocaido.groupmanager.GroupManager")
|
.put("me.lucko.luckperms.bukkit.migration.MigrationGroupManager", "org.anjocaido.groupmanager.GroupManager")
|
||||||
@ -61,22 +59,22 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
|||||||
.build().inverse();
|
.build().inverse();
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private List<Command<Object, ?>> commands = null;
|
private List<Command<Object>> commands = null;
|
||||||
private boolean display = true;
|
private boolean display = true;
|
||||||
|
|
||||||
public MigrationMainCommand(LocaleManager locale) {
|
public MigrationParentCommand(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION.localize(locale), "Migration", 1, null);
|
super(CommandSpec.MIGRATION.localize(locale), "Migration", Type.NO_TARGET_ARGUMENT, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized @NonNull Optional<List<Command<Object, ?>>> getChildren() {
|
public synchronized @NonNull List<Command<Object>> getChildren() {
|
||||||
if (this.commands == null) {
|
if (this.commands == null) {
|
||||||
this.commands = getAvailableCommands(getSpec().getLocaleManager());
|
this.commands = getAvailableCommands(getSpec().getLocaleManager());
|
||||||
|
|
||||||
// Add dummy command to show in the list.
|
// Add dummy command to show in the list.
|
||||||
if (this.commands.isEmpty()) {
|
if (this.commands.isEmpty()) {
|
||||||
this.display = false;
|
this.display = false;
|
||||||
this.commands.add(new SubCommand<Object>(CommandSpec.MIGRATION_COMMAND.localize(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) {
|
this.commands.add(new ChildCommand<Object>(CommandSpec.MIGRATION_COMMAND.localize(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
@ -84,8 +82,7 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return this.commands;
|
||||||
return Optional.of(this.commands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,21 +97,21 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static List<Command<Object, ?>> getAvailableCommands(LocaleManager locale) {
|
private static List<Command<Object>> getAvailableCommands(LocaleManager locale) {
|
||||||
List<Command<Object, ?>> l = new ArrayList<>();
|
List<Command<Object>> available = new ArrayList<>();
|
||||||
|
|
||||||
for (Map.Entry<String, String> plugin : PLUGINS.entrySet()) {
|
for (Map.Entry<String, String> plugin : PLUGINS.entrySet()) {
|
||||||
try {
|
try {
|
||||||
Class.forName(plugin.getKey());
|
Class.forName(plugin.getKey());
|
||||||
l.add((SubCommand<Object>) Class.forName(plugin.getValue()).getConstructor(LocaleManager.class).newInstance(locale));
|
available.add((ChildCommand<Object>) Class.forName(plugin.getValue()).getConstructor(LocaleManager.class).newInstance(locale));
|
||||||
} catch (Throwable ignored) {}
|
} catch (Throwable ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return l;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReentrantLock getLockForTarget(Object target) {
|
protected ReentrantLock getLockForTarget(Void target) {
|
||||||
return this.lock; // share a lock between all migration commands
|
return this.lock; // share a lock between all migration commands
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,16 +119,18 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
protected List<String> getTargets(LuckPermsPlugin plugin) {
|
||||||
return Collections.emptyList(); // only used for tab complete, we're not bothered about it for this command.
|
// should never be called if we specify Type.NO_TARGET_ARGUMENT in the constructor
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
protected Void parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
return this; // can't return null, but we don't need a target
|
// should never be called if we specify Type.NO_TARGET_ARGUMENT in the constructor
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object getTarget(Object target, LuckPermsPlugin plugin, Sender sender) {
|
protected Object getTarget(Void target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
return this; // can't return null, but we don't need a target
|
return this; // can't return null, but we don't need a target
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,6 @@ import net.luckperms.api.util.Tristate;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CheckCommand extends SingleCommand {
|
public class CheckCommand extends SingleCommand {
|
||||||
public CheckCommand(LocaleManager locale) {
|
public CheckCommand(LocaleManager locale) {
|
||||||
@ -79,7 +78,7 @@ public class CheckCommand extends SingleCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
return TabCompleter.create()
|
return TabCompleter.create()
|
||||||
.at(0, CompletionSupplier.startsWith(() -> plugin.getBootstrap().getPlayerList().collect(Collectors.toList())))
|
.at(0, CompletionSupplier.startsWith(() -> plugin.getBootstrap().getPlayerList()))
|
||||||
.at(1, TabCompletions.permissions(plugin))
|
.at(1, TabCompletions.permissions(plugin))
|
||||||
.complete(args);
|
.complete(args);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
@ -47,7 +47,7 @@ import net.luckperms.api.model.data.DataMutateResult;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackAppend extends SubCommand<Track> {
|
public class TrackAppend extends ChildCommand<Track> {
|
||||||
public TrackAppend(LocaleManager locale) {
|
public TrackAppend(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_APPEND.localize(locale), "append", CommandPermission.TRACK_APPEND, Predicates.not(1));
|
super(CommandSpec.TRACK_APPEND.localize(locale), "append", CommandPermission.TRACK_APPEND, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackClear extends SubCommand<Track> {
|
public class TrackClear extends ChildCommand<Track> {
|
||||||
public TrackClear(LocaleManager locale) {
|
public TrackClear(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_CLEAR.localize(locale), "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse());
|
super(CommandSpec.TRACK_CLEAR.localize(locale), "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -43,7 +43,7 @@ import net.luckperms.api.event.cause.CreationCause;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackClone extends SubCommand<Track> {
|
public class TrackClone extends ChildCommand<Track> {
|
||||||
public TrackClone(LocaleManager locale) {
|
public TrackClone(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_CLONE.localize(locale), "clone", CommandPermission.TRACK_CLONE, Predicates.not(1));
|
super(CommandSpec.TRACK_CLONE.localize(locale), "clone", CommandPermission.TRACK_CLONE, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.track;
|
package me.lucko.luckperms.common.commands.track;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -39,7 +39,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackInfo extends SubCommand<Track> {
|
public class TrackInfo extends ChildCommand<Track> {
|
||||||
public TrackInfo(LocaleManager locale) {
|
public TrackInfo(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_INFO.localize(locale), "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse());
|
super(CommandSpec.TRACK_INFO.localize(locale), "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
@ -47,7 +47,7 @@ import net.luckperms.api.model.data.DataMutateResult;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackInsert extends SubCommand<Track> {
|
public class TrackInsert extends ChildCommand<Track> {
|
||||||
public TrackInsert(LocaleManager locale) {
|
public TrackInsert(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_INSERT.localize(locale), "insert", CommandPermission.TRACK_INSERT, Predicates.not(2));
|
super(CommandSpec.TRACK_INSERT.localize(locale), "insert", CommandPermission.TRACK_INSERT, Predicates.not(2));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
import me.lucko.luckperms.common.command.abstraction.ParentCommand;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
@ -43,7 +43,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class TrackMainCommand extends MainCommand<Track, String> {
|
public class TrackParentCommand extends ParentCommand<Track, String> {
|
||||||
|
|
||||||
// we use a lock per unique track
|
// we use a lock per unique track
|
||||||
// this helps prevent race conditions where commands are being executed concurrently
|
// this helps prevent race conditions where commands are being executed concurrently
|
||||||
@ -53,8 +53,8 @@ public class TrackMainCommand extends MainCommand<Track, String> {
|
|||||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||||
.build(key -> new ReentrantLock());
|
.build(key -> new ReentrantLock());
|
||||||
|
|
||||||
public TrackMainCommand(LocaleManager locale) {
|
public TrackParentCommand(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK.localize(locale), "Track", 2, ImmutableList.<Command<Track, ?>>builder()
|
super(CommandSpec.TRACK.localize(locale), "Track", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.<Command<Track>>builder()
|
||||||
.add(new TrackInfo(locale))
|
.add(new TrackInfo(locale))
|
||||||
.add(new TrackAppend(locale))
|
.add(new TrackAppend(locale))
|
||||||
.add(new TrackInsert(locale))
|
.add(new TrackInsert(locale))
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||||
@ -46,7 +46,7 @@ import net.luckperms.api.model.data.DataMutateResult;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackRemove extends SubCommand<Track> {
|
public class TrackRemove extends ChildCommand<Track> {
|
||||||
public TrackRemove(LocaleManager locale) {
|
public TrackRemove(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_REMOVE.localize(locale), "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1));
|
super(CommandSpec.TRACK_REMOVE.localize(locale), "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
@ -44,7 +44,7 @@ import net.luckperms.api.event.cause.DeletionCause;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TrackRename extends SubCommand<Track> {
|
public class TrackRename extends ChildCommand<Track> {
|
||||||
public TrackRename(LocaleManager locale) {
|
public TrackRename(LocaleManager locale) {
|
||||||
super(CommandSpec.TRACK_RENAME.localize(locale), "rename", CommandPermission.TRACK_RENAME, Predicates.not(1));
|
super(CommandSpec.TRACK_RENAME.localize(locale), "rename", CommandPermission.TRACK_RENAME, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.user;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||||
@ -45,7 +45,7 @@ import net.luckperms.api.model.data.DataType;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserClone extends SubCommand<User> {
|
public class UserClone extends ChildCommand<User> {
|
||||||
public UserClone(LocaleManager locale) {
|
public UserClone(LocaleManager locale) {
|
||||||
super(CommandSpec.USER_CLONE.localize(locale), "clone", CommandPermission.USER_CLONE, Predicates.not(1));
|
super(CommandSpec.USER_CLONE.localize(locale), "clone", CommandPermission.USER_CLONE, Predicates.not(1));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.common.commands.user;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -52,7 +52,7 @@ import net.luckperms.api.track.DemotionResult;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class UserDemote extends SubCommand<User> {
|
public class UserDemote extends ChildCommand<User> {
|
||||||
public UserDemote(LocaleManager locale) {
|
public UserDemote(LocaleManager locale) {
|
||||||
super(CommandSpec.USER_DEMOTE.localize(locale), "demote", CommandPermission.USER_DEMOTE, Predicates.is(0));
|
super(CommandSpec.USER_DEMOTE.localize(locale), "demote", CommandPermission.USER_DEMOTE, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import com.google.common.collect.Maps;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.cacheddata.type.MetaCache;
|
import me.lucko.luckperms.common.cacheddata.type.MetaCache;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
@ -52,7 +52,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class UserInfo extends SubCommand<User> {
|
public class UserInfo extends ChildCommand<User> {
|
||||||
public UserInfo(LocaleManager locale) {
|
public UserInfo(LocaleManager locale) {
|
||||||
super(CommandSpec.USER_INFO.localize(locale), "info", CommandPermission.USER_INFO, Predicates.alwaysFalse());
|
super(CommandSpec.USER_INFO.localize(locale), "info", CommandPermission.USER_INFO, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
import me.lucko.luckperms.common.command.abstraction.ParentCommand;
|
||||||
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.HolderClear;
|
import me.lucko.luckperms.common.commands.generic.other.HolderClear;
|
||||||
import me.lucko.luckperms.common.commands.generic.other.HolderEditor;
|
import me.lucko.luckperms.common.commands.generic.other.HolderEditor;
|
||||||
@ -40,6 +40,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.model.UserIdentifier;
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
@ -54,7 +55,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class UserMainCommand extends MainCommand<User, UserIdentifier> {
|
public class UserParentCommand extends ParentCommand<User, UserIdentifier> {
|
||||||
|
|
||||||
// we use a lock per unique user
|
// we use a lock per unique user
|
||||||
// this helps prevent race conditions where commands are being executed concurrently
|
// this helps prevent race conditions where commands are being executed concurrently
|
||||||
@ -64,17 +65,17 @@ public class UserMainCommand extends MainCommand<User, UserIdentifier> {
|
|||||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||||
.build(key -> new ReentrantLock());
|
.build(key -> new ReentrantLock());
|
||||||
|
|
||||||
public UserMainCommand(LocaleManager locale) {
|
public UserParentCommand(LocaleManager locale) {
|
||||||
super(CommandSpec.USER.localize(locale), "User", 2, ImmutableList.<Command<User, ?>>builder()
|
super(CommandSpec.USER.localize(locale), "User", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.<Command<User>>builder()
|
||||||
.add(new UserInfo(locale))
|
.add(new UserInfo(locale))
|
||||||
.add(new CommandPermission<>(locale, true))
|
.add(new CommandPermission<>(locale, HolderType.USER))
|
||||||
.add(new CommandParent<>(locale, true))
|
.add(new CommandParent<>(locale, HolderType.USER))
|
||||||
.add(new CommandMeta<>(locale, true))
|
.add(new CommandMeta<>(locale, HolderType.USER))
|
||||||
.add(new HolderEditor<>(locale, true))
|
.add(new HolderEditor<>(locale, HolderType.USER))
|
||||||
.add(new UserPromote(locale))
|
.add(new UserPromote(locale))
|
||||||
.add(new UserDemote(locale))
|
.add(new UserDemote(locale))
|
||||||
.add(new HolderShowTracks<>(locale, true))
|
.add(new HolderShowTracks<>(locale, HolderType.USER))
|
||||||
.add(new HolderClear<>(locale, true))
|
.add(new HolderClear<>(locale, HolderType.USER))
|
||||||
.add(new UserClone(locale))
|
.add(new UserClone(locale))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.common.commands.user;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
|
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||||
@ -52,7 +52,7 @@ import net.luckperms.api.track.PromotionResult;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class UserPromote extends SubCommand<User> {
|
public class UserPromote extends ChildCommand<User> {
|
||||||
public UserPromote(LocaleManager locale) {
|
public UserPromote(LocaleManager locale) {
|
||||||
super(CommandSpec.USER_PROMOTE.localize(locale), "promote", CommandPermission.USER_PROMOTE, Predicates.is(0));
|
super(CommandSpec.USER_PROMOTE.localize(locale), "promote", CommandPermission.USER_PROMOTE, Predicates.is(0));
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public abstract class ContextManager<T> {
|
|||||||
private static String getCalculatorClass(ContextCalculator<?> calculator) {
|
private static String getCalculatorClass(ContextCalculator<?> calculator) {
|
||||||
Class<?> calculatorClass;
|
Class<?> calculatorClass;
|
||||||
if (calculator instanceof ProxiedContextCalculator) {
|
if (calculator instanceof ProxiedContextCalculator) {
|
||||||
calculatorClass = ((ProxiedContextCalculator) calculator).getDelegate().getClass();
|
calculatorClass = ((ProxiedContextCalculator<?>) calculator).getDelegate().getClass();
|
||||||
} else {
|
} else {
|
||||||
calculatorClass = calculator.getClass();
|
calculatorClass = calculator.getClass();
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,12 @@
|
|||||||
package me.lucko.luckperms.common.dependencies;
|
package me.lucko.luckperms.common.dependencies;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.RelocationHelper;
|
import me.lucko.luckperms.common.dependencies.relocation.RelocationHelper;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -319,6 +313,7 @@ public enum Dependency {
|
|||||||
return s.replace("{}", ".");
|
return s.replace("{}", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
|
|
||||||
@ -346,6 +341,7 @@ public enum Dependency {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public List<URL> getUrls() {
|
public List<URL> getUrls() {
|
||||||
return this.urls;
|
return this.urls;
|
||||||
|
@ -192,7 +192,7 @@ public class DependencyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.plugin.getBootstrap().getPluginClassLoader().loadJar(source.file);
|
this.plugin.getBootstrap().getPluginClassLoader().addJarToClasspath(source.file);
|
||||||
this.loaded.put(source.dependency, source.file);
|
this.loaded.put(source.dependency, source.file);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
this.plugin.getLogger().severe("Failed to load dependency jar '" + source.file.getFileName().toString() + "'.");
|
this.plugin.getLogger().severe("Failed to load dependency jar '" + source.file.getFileName().toString() + "'.");
|
||||||
|
@ -32,6 +32,6 @@ import java.nio.file.Path;
|
|||||||
*/
|
*/
|
||||||
public interface PluginClassLoader {
|
public interface PluginClassLoader {
|
||||||
|
|
||||||
void loadJar(Path file);
|
void addJarToClasspath(Path file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class ReflectionClassLoader implements PluginClassLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadJar(Path file) {
|
public void addJarToClasspath(Path file) {
|
||||||
try {
|
try {
|
||||||
ADD_URL_METHOD.invoke(this.classLoader, file.toUri().toURL());
|
ADD_URL_METHOD.invoke(this.classLoader, file.toUri().toURL());
|
||||||
} catch (IllegalAccessException | InvocationTargetException | MalformedURLException e) {
|
} catch (IllegalAccessException | InvocationTargetException | MalformedURLException e) {
|
||||||
|
@ -137,7 +137,7 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
|||||||
* @param plugin the plugin
|
* @param plugin the plugin
|
||||||
*/
|
*/
|
||||||
protected void unregisterHandlers(P plugin) {
|
protected void unregisterHandlers(P plugin) {
|
||||||
this.bus.unregister(sub -> ((LuckPermsEventSubscription) sub).getPlugin() == plugin);
|
this.bus.unregister(sub -> ((LuckPermsEventSubscription<?>) sub).getPlugin() == plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,7 +136,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
|||||||
throw new IllegalArgumentException("class is null");
|
throw new IllegalArgumentException("class is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.plugin.getBootstrap().getPluginClassLoader().loadJar(path);
|
this.plugin.getBootstrap().getPluginClassLoader().addJarToClasspath(path);
|
||||||
|
|
||||||
Class<? extends Extension> extensionClass;
|
Class<? extends Extension> extensionClass;
|
||||||
try {
|
try {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user