mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Reorganise commands
This commit is contained in:
parent
1689a8abe2
commit
907d716929
@ -28,8 +28,8 @@ package me.lucko.luckperms.bukkit;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -29,7 +29,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.SchedulerTask;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -105,7 +105,7 @@ public class BukkitSchedulerAdapter implements SchedulerAdapter {
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
SafeIteration.iterate(this.tasks, SchedulerTask::cancel);
|
||||
Iterators.iterate(this.tasks, SchedulerTask::cancel);
|
||||
|
||||
// wait for executor
|
||||
this.asyncFallback.shutdown();
|
||||
|
@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.bukkit.compat.BukkitJsonMessageHandler;
|
||||
import me.lucko.luckperms.bukkit.compat.ReflectionUtil;
|
||||
import me.lucko.luckperms.bukkit.compat.SpigotJsonMessageHandler;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
|
@ -44,8 +44,7 @@ import me.lucko.luckperms.bukkit.model.server.LPPermissionMap;
|
||||
import me.lucko.luckperms.bukkit.model.server.LPSubscriptionMap;
|
||||
import me.lucko.luckperms.bukkit.vault.VaultHookManager;
|
||||
import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
@ -56,6 +55,7 @@ import me.lucko.luckperms.common.managers.user.StandardUserManager;
|
||||
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.bukkit.model.permissible.LPPermissible;
|
||||
import me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.listener.AbstractConnectionListener;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.bukkit.listeners;
|
||||
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
@ -33,20 +33,20 @@ import de.bananaco.bpermissions.api.WorldManager;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -58,7 +58,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.MIGRATION;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION;
|
||||
|
||||
public class MigrationBPermissions extends SubCommand<Object> {
|
||||
private static final Field UCONFIG_FIELD;
|
||||
@ -72,7 +72,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
public MigrationBPermissions(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse());
|
||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,14 +124,14 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
|
||||
// Migrate one world at a time.
|
||||
log.log("Starting world migration.");
|
||||
SafeIteration.iterate(worldManager.getAllWorlds(), world -> {
|
||||
Iterators.iterate(worldManager.getAllWorlds(), world -> {
|
||||
log.log("Migrating world: " + world.getName());
|
||||
|
||||
// Migrate all groups
|
||||
log.log("Starting group migration in world " + world.getName() + ".");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
|
||||
SafeIteration.iterate(world.getAll(CalculableType.GROUP), group -> {
|
||||
Iterators.iterate(world.getAll(CalculableType.GROUP), group -> {
|
||||
String groupName = MigrationUtils.standardizeName(group.getName());
|
||||
if (group.getName().equalsIgnoreCase(world.getDefaultGroup())) {
|
||||
groupName = NodeFactory.DEFAULT_GROUP_NAME;
|
||||
@ -153,7 +153,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
// Migrate all users
|
||||
log.log("Starting user migration in world " + world.getName() + ".");
|
||||
AtomicInteger userCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(world.getAll(CalculableType.USER), user -> {
|
||||
Iterators.iterate(world.getAll(CalculableType.USER), user -> {
|
||||
// There is no mention of UUIDs in the API. I assume that name = uuid. idk?
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getName());
|
||||
if (uuid == null) {
|
||||
|
@ -28,20 +28,20 @@ package me.lucko.luckperms.bukkit.migration;
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.anjocaido.groupmanager.GlobalGroups;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
@ -62,7 +62,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class MigrationGroupManager extends SubCommand<Object> {
|
||||
public MigrationGroupManager(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_GROUPMANAGER.spec(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0));
|
||||
super(CommandSpec.MIGRATION_GROUPMANAGER.localize(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +93,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
GlobalGroups gg = GroupManager.getGlobalGroups();
|
||||
|
||||
AtomicInteger globalGroupCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(gg.getGroupList(), g -> {
|
||||
Iterators.iterate(gg.getGroupList(), g -> {
|
||||
String groupName = MigrationUtils.standardizeName(g.getName());
|
||||
Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
@ -120,13 +120,13 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
|
||||
// Collect data for all users and groups.
|
||||
log.log("Collecting user and group data.");
|
||||
SafeIteration.iterate(worlds, String::toLowerCase, world -> {
|
||||
Iterators.iterate(worlds, String::toLowerCase, world -> {
|
||||
log.log("Querying world " + world);
|
||||
|
||||
WorldDataHolder wdh = wh.getWorldData(world);
|
||||
|
||||
AtomicInteger groupWorldCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(wdh.getGroupList(), group -> {
|
||||
Iterators.iterate(wdh.getGroupList(), group -> {
|
||||
String groupName = MigrationUtils.standardizeName(group.getName());
|
||||
|
||||
groups.putIfAbsent(groupName, new HashSet<>());
|
||||
@ -160,7 +160,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
log.log("Migrated " + groupWorldCount.get() + " groups in world " + world);
|
||||
|
||||
AtomicInteger userWorldCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(wdh.getUserList(), user -> {
|
||||
Iterators.iterate(wdh.getUserList(), user -> {
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getUUID());
|
||||
if (uuid == null) {
|
||||
return;
|
||||
@ -210,7 +210,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
|
||||
log.log("Starting group migration.");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(groups.entrySet(), e -> {
|
||||
Iterators.iterate(groups.entrySet(), e -> {
|
||||
Group group = plugin.getStorage().createAndLoadGroup(e.getKey(), CreationCause.INTERNAL).join();
|
||||
|
||||
for (Node node : e.getValue()) {
|
||||
@ -224,7 +224,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
|
||||
log.log("Starting user migration.");
|
||||
AtomicInteger userCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(users.entrySet(), e -> {
|
||||
Iterators.iterate(users.entrySet(), e -> {
|
||||
User user = plugin.getStorage().loadUser(e.getKey(), null).join();
|
||||
|
||||
for (Node node : e.getValue()) {
|
||||
|
@ -28,21 +28,21 @@ package me.lucko.luckperms.bukkit.migration;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -54,7 +54,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
public MigrationPermissionsBukkit(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +79,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
|
||||
ConfigurationSection groupsSection = config.getConfigurationSection("groups");
|
||||
|
||||
SafeIteration.iterate(groupsSection.getKeys(false), key -> {
|
||||
Iterators.iterate(groupsSection.getKeys(false), key -> {
|
||||
final String groupName = MigrationUtils.standardizeName(key);
|
||||
Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
@ -99,7 +99,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
|
||||
ConfigurationSection usersSection = config.getConfigurationSection("users");
|
||||
|
||||
SafeIteration.iterate(usersSection.getKeys(false), key -> {
|
||||
Iterators.iterate(usersSection.getKeys(false), key -> {
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, key);
|
||||
if (uuid == null) {
|
||||
return;
|
||||
|
@ -28,13 +28,12 @@ package me.lucko.luckperms.bukkit.migration;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
@ -42,8 +41,9 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -86,7 +86,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
public MigrationPermissionsEx(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -117,7 +117,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
log.log("Starting group migration.");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
Set<String> ladders = new HashSet<>();
|
||||
SafeIteration.iterate(manager.getGroupList(), group -> {
|
||||
Iterators.iterate(manager.getGroupList(), group -> {
|
||||
int groupWeight = maxWeight - group.getRank();
|
||||
|
||||
final String groupName = MigrationUtils.standardizeName(group.getName());
|
||||
@ -161,7 +161,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
// Increment the max weight from the group migrations. All user meta should override.
|
||||
int userWeight = maxWeight + 5;
|
||||
|
||||
SafeIteration.iterate(manager.getUsers(), user -> {
|
||||
Iterators.iterate(manager.getUsers(), user -> {
|
||||
UUID u = BukkitMigrationUtils.lookupUuid(log, user.getIdentifier());
|
||||
if (u == null) {
|
||||
return;
|
||||
|
@ -35,21 +35,21 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.StorageType;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -68,12 +68,12 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.MIGRATION;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION;
|
||||
|
||||
// Only supports the latest versions of the PP API. (it seems to change randomly almost every release)
|
||||
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
public MigrationPowerfulPerms(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_POWERFULPERMS.spec(locale), "powerfulperms", MIGRATION, Predicates.not(5));
|
||||
super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", MIGRATION, Predicates.not(5));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,7 +159,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
// Groups first.
|
||||
log.log("Starting group migration.");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(groups, g -> {
|
||||
Iterators.iterate(groups, g -> {
|
||||
maxWeight.set(Math.max(maxWeight.get(), g.getRank()));
|
||||
|
||||
String groupName = MigrationUtils.standardizeName(g.getName());
|
||||
@ -219,7 +219,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
maxWeight.addAndGet(5);
|
||||
|
||||
// Migrate all users and their groups
|
||||
SafeIteration.iterate(uuids, uuid -> {
|
||||
Iterators.iterate(uuids, uuid -> {
|
||||
|
||||
// Create a LuckPerms user for the UUID
|
||||
User user = plugin.getStorage().loadUser(uuid, null).join();
|
||||
|
@ -28,13 +28,12 @@ package me.lucko.luckperms.bukkit.migration;
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
@ -42,8 +41,9 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
|
||||
@ -64,7 +64,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MigrationZPermissions extends SubCommand<Object> {
|
||||
public MigrationZPermissions(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_COMMAND.spec(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,7 +104,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
AtomicInteger maxWeight = new AtomicInteger(0);
|
||||
SafeIteration.iterate(internalService.getEntities(true), entity -> {
|
||||
Iterators.iterate(internalService.getEntities(true), entity -> {
|
||||
String groupName = MigrationUtils.standardizeName(entity.getDisplayName());
|
||||
Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
@ -138,7 +138,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
// Migrate all tracks
|
||||
log.log("Starting track migration.");
|
||||
AtomicInteger trackCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(service.getAllTracks(), t -> {
|
||||
Iterators.iterate(service.getAllTracks(), t -> {
|
||||
String trackName = MigrationUtils.standardizeName(t);
|
||||
Track track = plugin.getStorage().createAndLoadTrack(trackName, CreationCause.INTERNAL).join();
|
||||
track.setGroups(service.getTrackGroups(t));
|
||||
@ -156,7 +156,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
Set<UUID> usersToMigrate = new HashSet<>(userParents.keySet());
|
||||
usersToMigrate.addAll(service.getAllPlayersUUID());
|
||||
|
||||
SafeIteration.iterate(usersToMigrate, u -> {
|
||||
Iterators.iterate(usersToMigrate, u -> {
|
||||
PermissionEntity entity = internalService.getEntity(null, u, false);
|
||||
|
||||
String username = null;
|
||||
|
@ -34,7 +34,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
||||
import me.lucko.luckperms.common.caching.type.MetaCache;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
@ -34,7 +34,7 @@ import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.common.caching.type.PermissionCache;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
@ -28,8 +28,8 @@ package me.lucko.luckperms.bungee;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.bungee;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.SchedulerTask;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.api.scheduler.TaskScheduler;
|
||||
@ -109,7 +109,7 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
SafeIteration.iterate(this.tasks, SchedulerTask::cancel);
|
||||
Iterators.iterate(this.tasks, SchedulerTask::cancel);
|
||||
}
|
||||
|
||||
private static final class BungeeSchedulerTask implements SchedulerTask {
|
||||
|
@ -27,9 +27,9 @@ package me.lucko.luckperms.bungee;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
|
@ -35,8 +35,7 @@ import me.lucko.luckperms.bungee.listeners.BungeeConnectionListener;
|
||||
import me.lucko.luckperms.bungee.listeners.BungeePermissionCheckListener;
|
||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
||||
import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.listener.ConnectionListener;
|
||||
@ -46,6 +45,7 @@ import me.lucko.luckperms.common.managers.user.StandardUserManager;
|
||||
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||
|
||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.bungee.listeners;
|
||||
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.listener.AbstractConnectionListener;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
@ -26,19 +26,19 @@
|
||||
package me.lucko.luckperms.bungee.migration;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.SafeIteration;
|
||||
|
||||
import net.alpenblock.bungeeperms.BungeePerms;
|
||||
import net.alpenblock.bungeeperms.Group;
|
||||
@ -52,7 +52,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
public MigrationBungeePerms(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +82,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
// Migrate all groups.
|
||||
log.log("Starting group migration.");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
SafeIteration.iterate(groups, g -> {
|
||||
Iterators.iterate(groups, g -> {
|
||||
int groupWeight = maxWeight - g.getRank();
|
||||
|
||||
// Make a LuckPerms group for the one being migrated
|
||||
@ -104,7 +104,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
// Increment the max weight from the group migrations. All user meta should override.
|
||||
int userWeight = maxWeight + 5;
|
||||
|
||||
SafeIteration.iterate(bp.getPermissionsManager().getBackEnd().loadUsers(), u -> {
|
||||
Iterators.iterate(bp.getPermissionsManager().getBackEnd().loadUsers(), u -> {
|
||||
if (u.getUUID() == null) {
|
||||
log.logError("Could not parse UUID for user: " + u.getName());
|
||||
return;
|
||||
|
@ -30,12 +30,12 @@ import com.google.common.base.Strings;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -70,8 +70,8 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
*
|
||||
* @return a new builder
|
||||
*/
|
||||
public static ExtendedLogEntryBuilder build() {
|
||||
return new ExtendedLogEntryBuilder();
|
||||
public static Builder build() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
private final long timestamp;
|
||||
@ -207,7 +207,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class ExtendedLogEntryBuilder implements LogEntry.Builder {
|
||||
public static class Builder implements LogEntry.Builder {
|
||||
|
||||
private long timestamp = 0L;
|
||||
private UUID actor = null;
|
||||
@ -219,88 +219,88 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setTimestamp(long timestamp) {
|
||||
public Builder setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setActor(@Nonnull UUID actor) {
|
||||
public Builder setActor(@Nonnull UUID actor) {
|
||||
this.actor = Objects.requireNonNull(actor, "actor");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setActorName(@Nonnull String actorName) {
|
||||
public Builder setActorName(@Nonnull String actorName) {
|
||||
this.actorName = Objects.requireNonNull(actorName, "actorName");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setType(@Nonnull Type type) {
|
||||
public Builder setType(@Nonnull Type type) {
|
||||
this.type = Objects.requireNonNull(type, "type");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setActed(UUID acted) {
|
||||
public Builder setActed(UUID acted) {
|
||||
this.acted = acted; // nullable
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setActedName(@Nonnull String actedName) {
|
||||
public Builder setActedName(@Nonnull String actedName) {
|
||||
this.actedName = Objects.requireNonNull(actedName, "actedName");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntryBuilder setAction(@Nonnull String action) {
|
||||
public Builder setAction(@Nonnull String action) {
|
||||
this.action = Objects.requireNonNull(action, "action");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder timestamp(long timestamp) {
|
||||
public Builder timestamp(long timestamp) {
|
||||
return setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder actor(UUID actor) {
|
||||
public Builder actor(UUID actor) {
|
||||
return setActor(actor);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder actorName(String actorName) {
|
||||
public Builder actorName(String actorName) {
|
||||
return setActorName(actorName);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder type(Type type) {
|
||||
public Builder type(Type type) {
|
||||
return setType(type);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder acted(UUID acted) {
|
||||
public Builder acted(UUID acted) {
|
||||
return setActed(acted);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder actedName(String actedName) {
|
||||
public Builder actedName(String actedName) {
|
||||
return setActedName(actedName);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder action(String action) {
|
||||
public Builder action(String action) {
|
||||
return setAction(action);
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder actor(Sender actor) {
|
||||
public Builder actor(Sender actor) {
|
||||
actorName(actor.getNameWithLocation());
|
||||
actor(actor.getUuid());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder acted(PermissionHolder acted) {
|
||||
public Builder acted(PermissionHolder acted) {
|
||||
if (acted.getType().isUser()) {
|
||||
actedName(((User) acted).getName().orElse("null"));
|
||||
acted(((User) acted).getUuid());
|
||||
@ -312,13 +312,13 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder acted(Track track) {
|
||||
public Builder acted(Track track) {
|
||||
actedName(track.getName());
|
||||
type(Type.TRACK);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtendedLogEntryBuilder action(Object... args) {
|
||||
public Builder action(Object... args) {
|
||||
List<String> parts = new ArrayList<>();
|
||||
|
||||
for (Object o : args) {
|
||||
@ -367,7 +367,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtendedLogEntry.ExtendedLogEntryBuilder(" +
|
||||
return "ExtendedLogEntry.Builder(" +
|
||||
"timestamp=" + this.timestamp + ", " +
|
||||
"actor=" + this.actor + ", " +
|
||||
"actorName=" + this.actorName + ", " +
|
||||
|
@ -44,7 +44,7 @@ public class Log {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public synchronized static Log empty() {
|
||||
public static synchronized Log empty() {
|
||||
if (empty == null) {
|
||||
empty = builder().build();
|
||||
}
|
||||
|
@ -27,13 +27,13 @@ package me.lucko.luckperms.common.actionlog;
|
||||
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.impl.log.LogNotify;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.log.LogNotify;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -26,9 +26,7 @@
|
||||
package me.lucko.luckperms.common.backup;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
@ -36,6 +34,7 @@ import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.references.HolderType;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.utils.Cycle;
|
||||
|
||||
@ -56,6 +55,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -181,7 +181,7 @@ public class Exporter implements Runnable {
|
||||
write(writer, "# Export users");
|
||||
|
||||
// divide into 16 pools.
|
||||
Cycle<List<UUID>> userPools = new Cycle<>(CommandUtils.nInstances(32, ArrayList::new));
|
||||
Cycle<List<UUID>> userPools = new Cycle<>(nInstances(32, ArrayList::new));
|
||||
for (UUID uuid : users) {
|
||||
userPools.next().add(uuid);
|
||||
}
|
||||
@ -265,4 +265,12 @@ public class Exporter implements Runnable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> List<T> nInstances(int count, Supplier<T> supplier) {
|
||||
List<T> ret = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret.add(supplier.get());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,11 @@ package me.lucko.luckperms.common.backup;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.DummySender;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.sender.DummySender;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Cycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -45,6 +44,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ public class Importer implements Runnable {
|
||||
}
|
||||
|
||||
// divide commands up into pools
|
||||
Cycle<List<ImportCommand>> commandPools = new Cycle<>(CommandUtils.nInstances(128, ArrayList::new));
|
||||
Cycle<List<ImportCommand>> commandPools = new Cycle<>(nInstances(128, ArrayList::new));
|
||||
|
||||
String lastTarget = null;
|
||||
for (ImportCommand cmd : this.toExecute) {
|
||||
@ -151,7 +151,7 @@ public class Importer implements Runnable {
|
||||
long endTime = System.currentTimeMillis();
|
||||
double seconds = (endTime - startTime) / 1000;
|
||||
|
||||
int errors = (int) this.toExecute.stream().filter(v -> !v.getResult().asBoolean()).count();
|
||||
int errors = (int) this.toExecute.stream().filter(v -> v.getResult().wasFailure()).count();
|
||||
|
||||
switch (errors) {
|
||||
case 0:
|
||||
@ -167,7 +167,7 @@ public class Importer implements Runnable {
|
||||
|
||||
AtomicInteger errIndex = new AtomicInteger(1);
|
||||
for (ImportCommand e : this.toExecute) {
|
||||
if (e.getResult() != null && !e.getResult().asBoolean()) {
|
||||
if (e.getResult() != null && e.getResult().wasFailure()) {
|
||||
this.notify.forEach(s -> {
|
||||
Message.IMPORT_END_ERROR_HEADER.send(s, errIndex.get(), e.getId(), e.getCommand(), e.getResult().toString());
|
||||
for (String out : e.getOutput()) {
|
||||
@ -183,7 +183,7 @@ public class Importer implements Runnable {
|
||||
|
||||
private void sendProgress(int processedCount) {
|
||||
int percent = (processedCount * 100) / this.commands.size();
|
||||
int errors = (int) this.toExecute.stream().filter(v -> v.isCompleted() && !v.getResult().asBoolean()).count();
|
||||
int errors = (int) this.toExecute.stream().filter(v -> v.isCompleted() && v.getResult().wasFailure()).count();
|
||||
|
||||
if (errors == 1) {
|
||||
this.notify.forEach(s -> Message.IMPORT_PROGRESS_SIN.send(s, percent, processedCount, this.commands.size(), errors));
|
||||
@ -315,4 +315,12 @@ public class Importer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> List<T> nInstances(int count, Supplier<T> supplier) {
|
||||
List<T> ret = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret.add(supplier.get());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,42 +23,44 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
package me.lucko.luckperms.common.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.commands.abstraction.Command;
|
||||
import me.lucko.luckperms.common.commands.impl.group.CreateGroup;
|
||||
import me.lucko.luckperms.common.commands.impl.group.DeleteGroup;
|
||||
import me.lucko.luckperms.common.commands.impl.group.GroupMainCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.group.ListGroups;
|
||||
import me.lucko.luckperms.common.commands.impl.log.LogMainCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.migration.MigrationMainCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.ApplyEditsCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.BulkUpdateCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.CheckCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.DebugCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.EditorCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.ExportCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.ImportCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.InfoCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.NetworkSyncCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.ReloadConfigCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.SearchCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.SyncCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.TreeCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.misc.VerboseCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.track.CreateTrack;
|
||||
import me.lucko.luckperms.common.commands.impl.track.DeleteTrack;
|
||||
import me.lucko.luckperms.common.commands.impl.track.ListTracks;
|
||||
import me.lucko.luckperms.common.commands.impl.track.TrackMainCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.user.UserMainCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
||||
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
||||
import me.lucko.luckperms.common.commands.group.GroupMainCommand;
|
||||
import me.lucko.luckperms.common.commands.group.ListGroups;
|
||||
import me.lucko.luckperms.common.commands.log.LogMainCommand;
|
||||
import me.lucko.luckperms.common.commands.migration.MigrationMainCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.ApplyEditsCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.BulkUpdateCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.CheckCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.DebugCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.EditorCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.ExportCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.ImportCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.InfoCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.NetworkSyncCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.ReloadConfigCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.SearchCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.SyncCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.TreeCommand;
|
||||
import me.lucko.luckperms.common.commands.misc.VerboseCommand;
|
||||
import me.lucko.luckperms.common.commands.track.CreateTrack;
|
||||
import me.lucko.luckperms.common.commands.track.DeleteTrack;
|
||||
import me.lucko.luckperms.common.commands.track.ListTracks;
|
||||
import me.lucko.luckperms.common.commands.track.TrackMainCommand;
|
||||
import me.lucko.luckperms.common.commands.user.UserMainCommand;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
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.utils.TextUtils;
|
||||
|
||||
import net.kyori.text.TextComponent;
|
||||
@ -99,7 +101,6 @@ public class CommandManager {
|
||||
|
||||
public CommandManager(LuckPermsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
LocaleManager locale = plugin.getLocaleManager();
|
||||
|
||||
this.mainCommands = ImmutableList.<Command>builder()
|
||||
@ -159,7 +160,7 @@ public class CommandManager {
|
||||
|
||||
// Handle no arguments
|
||||
if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) {
|
||||
CommandUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) {
|
||||
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
|
||||
} else {
|
||||
@ -257,7 +258,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
private void sendCommandUsage(Sender sender, String label) {
|
||||
CommandUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
this.mainCommands.stream()
|
||||
.filter(Command::shouldDisplay)
|
||||
.filter(c -> c.isAuthorized(sender))
|
||||
@ -282,29 +283,29 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
public static CommandResult handleException(CommandException e, Sender sender, String label, Command command) {
|
||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||
if (e instanceof ArgumentParser.ArgumentException) {
|
||||
if (e instanceof ArgumentParser.DetailedUsageException) {
|
||||
command.sendDetailedUsage(sender, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidServerWorldException) {
|
||||
if (e instanceof ArgumentParser.InvalidServerWorldException) {
|
||||
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.PastDateException) {
|
||||
if (e instanceof ArgumentParser.PastDateException) {
|
||||
Message.PAST_DATE_ERROR.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||
if (e instanceof ArgumentParser.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||
if (e instanceof ArgumentParser.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
}
|
@ -23,8 +23,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
package me.lucko.luckperms.common.command;
|
||||
|
||||
/**
|
||||
* Represents the result of a commands execution
|
||||
*/
|
||||
public enum CommandResult {
|
||||
SUCCESS(true),
|
||||
FAILURE(false),
|
||||
@ -34,18 +37,14 @@ public enum CommandResult {
|
||||
INVALID_ARGS(false),
|
||||
NO_PERMISSION(false);
|
||||
|
||||
public static CommandResult of(boolean b) {
|
||||
return b ? SUCCESS : FAILURE;
|
||||
private final boolean wasSuccess;
|
||||
|
||||
CommandResult(boolean wasSuccess) {
|
||||
this.wasSuccess = wasSuccess;
|
||||
}
|
||||
|
||||
private final boolean value;
|
||||
|
||||
CommandResult(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return this.value;
|
||||
public boolean wasFailure() {
|
||||
return !this.wasSuccess;
|
||||
}
|
||||
|
||||
}
|
@ -23,17 +23,16 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.abstraction;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.command.Argument;
|
||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -58,7 +57,7 @@ public abstract class Command<T, S> {
|
||||
* Contains details about usage, description, etc
|
||||
*/
|
||||
@Nonnull
|
||||
private final LocalizedSpec spec;
|
||||
private final LocalizedCommandSpec spec;
|
||||
|
||||
/**
|
||||
* The name of the command. Should be properly capitalised.
|
||||
@ -84,7 +83,7 @@ public abstract class Command<T, S> {
|
||||
@Nullable
|
||||
private final List<Command<S, ?>> children;
|
||||
|
||||
public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate<Integer> argumentCheck, @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.name = name;
|
||||
this.permission = permission;
|
||||
@ -92,11 +91,11 @@ public abstract class Command<T, S> {
|
||||
this.children = children == null ? null : ImmutableList.copyOf(children);
|
||||
}
|
||||
|
||||
public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
this(spec, name, permission, argumentCheck, null);
|
||||
}
|
||||
|
||||
public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
this(spec, name, null, argumentCheck, null);
|
||||
}
|
||||
|
||||
@ -106,7 +105,7 @@ public abstract class Command<T, S> {
|
||||
* @return the command spec
|
||||
*/
|
||||
@Nonnull
|
||||
public LocalizedSpec getSpec() {
|
||||
public LocalizedCommandSpec getSpec() {
|
||||
return this.spec;
|
||||
}
|
||||
|
||||
@ -178,7 +177,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return the commands arguments
|
||||
*/
|
||||
public Optional<List<Arg>> getArgs() {
|
||||
public Optional<List<Argument>> getArgs() {
|
||||
return Optional.ofNullable(getSpec().args());
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
/**
|
||||
* Exception to be thrown if there is an error processing a command
|
@ -23,16 +23,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.abstraction;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -50,7 +49,7 @@ public abstract class MainCommand<T, I> extends Command<Void, T> {
|
||||
// equals 2 if the command does take a mid argument, e.g. /lp user <USER> sub-command....
|
||||
private final int minArgs;
|
||||
|
||||
public MainCommand(LocalizedSpec spec, String name, int minArgs, List<Command<T, ?>> children) {
|
||||
public MainCommand(LocalizedCommandSpec spec, String name, int minArgs, List<Command<T, ?>> children) {
|
||||
super(spec, name, null, Predicates.alwaysFalse(), children);
|
||||
this.minArgs = minArgs;
|
||||
}
|
||||
@ -172,7 +171,7 @@ public abstract class MainCommand<T, I> extends Command<Void, T> {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!subs.isEmpty()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)");
|
||||
MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)");
|
||||
|
||||
for (Command s : subs) {
|
||||
s.sendUsage(sender, label);
|
@ -23,17 +23,16 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.abstraction;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -56,7 +55,7 @@ public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T>
|
||||
*/
|
||||
private final boolean user;
|
||||
|
||||
public SharedMainCommand(LocalizedSpec spec, String name, boolean user, List<SharedSubCommand> secondaryCommands) {
|
||||
public SharedMainCommand(LocalizedCommandSpec spec, String name, boolean user, List<SharedSubCommand> secondaryCommands) {
|
||||
super(spec, name, null, Predicates.alwaysFalse());
|
||||
this.secondaryCommands = secondaryCommands;
|
||||
this.user = user;
|
||||
@ -144,9 +143,9 @@ public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T>
|
||||
|
||||
if (!subs.isEmpty()) {
|
||||
if (user) {
|
||||
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user <user> " + getName().toLowerCase() + " ...)", label));
|
||||
MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user <user> " + getName().toLowerCase() + " ...)", label));
|
||||
} else {
|
||||
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
|
||||
MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
|
||||
}
|
||||
|
||||
for (SharedSubCommand s : subs) {
|
||||
@ -159,29 +158,29 @@ public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T>
|
||||
}
|
||||
|
||||
private static CommandResult handleException(CommandException e, Sender sender, SharedSubCommand command) {
|
||||
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||
if (e instanceof ArgumentParser.ArgumentException) {
|
||||
if (e instanceof ArgumentParser.DetailedUsageException) {
|
||||
command.sendDetailedUsage(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidServerWorldException) {
|
||||
if (e instanceof ArgumentParser.InvalidServerWorldException) {
|
||||
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.PastDateException) {
|
||||
if (e instanceof ArgumentParser.PastDateException) {
|
||||
Message.PAST_DATE_ERROR.send(sender);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||
if (e instanceof ArgumentParser.InvalidDateException) {
|
||||
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||
if (e instanceof ArgumentParser.InvalidPriorityException) {
|
||||
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
}
|
@ -23,19 +23,16 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.abstraction;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.command.Argument;
|
||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -47,7 +44,7 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public abstract class SharedSubCommand {
|
||||
|
||||
private final LocalizedSpec spec;
|
||||
private final LocalizedCommandSpec spec;
|
||||
|
||||
/**
|
||||
* The name of the sub command
|
||||
@ -65,7 +62,7 @@ public abstract class SharedSubCommand {
|
||||
*/
|
||||
private final Predicate<? super Integer> argumentCheck;
|
||||
|
||||
public SharedSubCommand(LocalizedSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate<? super Integer> argumentCheck) {
|
||||
public SharedSubCommand(LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate<? super Integer> argumentCheck) {
|
||||
this.spec = spec;
|
||||
this.name = name;
|
||||
this.userPermission = userPermission;
|
||||
@ -79,7 +76,7 @@ public abstract class SharedSubCommand {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public LocalizedSpec getSpec() {
|
||||
public LocalizedCommandSpec getSpec() {
|
||||
return this.spec;
|
||||
}
|
||||
|
||||
@ -103,21 +100,21 @@ public abstract class SharedSubCommand {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (getArgs() != null) {
|
||||
sb.append("&3 - &7");
|
||||
for (Arg arg : getArgs()) {
|
||||
for (Argument arg : getArgs()) {
|
||||
sb.append(arg.asPrettyString()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString());
|
||||
MessageUtils.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString());
|
||||
}
|
||||
|
||||
public void sendDetailedUsage(Sender sender) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (getArgs() != null) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Arg arg : getArgs()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
MessageUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Argument arg : getArgs()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,24 +127,8 @@ public abstract class SharedSubCommand {
|
||||
return this.spec.description();
|
||||
}
|
||||
|
||||
public List<Arg> getArgs() {
|
||||
public List<Argument> getArgs() {
|
||||
return this.spec.args();
|
||||
}
|
||||
|
||||
public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) {
|
||||
if (holder.getType().isUser()) {
|
||||
User user = ((User) holder);
|
||||
SubCommand.save(user, sender, plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.getType().isGroup()) {
|
||||
Group group = ((Group) holder);
|
||||
SubCommand.save(group, sender, plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
@ -23,16 +23,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.abstraction;
|
||||
package me.lucko.luckperms.common.command.abstraction;
|
||||
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.command.Argument;
|
||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
@ -42,7 +41,7 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public abstract class SingleCommand extends Command<Void, Void> {
|
||||
|
||||
public SingleCommand(LocalizedSpec 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);
|
||||
}
|
||||
|
||||
@ -58,22 +57,22 @@ public abstract class SingleCommand extends Command<Void, Void> {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (getArgs().isPresent()) {
|
||||
sb.append("&3 - &7");
|
||||
for (Arg arg : getArgs().get()) {
|
||||
for (Argument arg : getArgs().get()) {
|
||||
sb.append(arg.asPrettyString()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
|
||||
MessageUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (getArgs().isPresent()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Arg arg : getArgs().get()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
MessageUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Argument arg : getArgs().get()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.command.Argument;
|
||||
import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Abstract SubCommand class
|
||||
*/
|
||||
public abstract class SubCommand<T> extends Command<T, Void> {
|
||||
|
||||
public SubCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
||||
super(spec, name, permission, argumentCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the command usage to a sender
|
||||
*
|
||||
* @param sender the sender to send the usage to
|
||||
*/
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (getArgs().isPresent()) {
|
||||
sb.append("&3 - &7");
|
||||
for (Argument arg : getArgs().get()) {
|
||||
sb.append(arg.asPrettyString()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (getArgs().isPresent()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Argument arg : getArgs().get()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -23,21 +23,24 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
package me.lucko.luckperms.common.command.access;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Implements argument based permission checks for use in command implementations.
|
||||
*/
|
||||
public final class ArgumentPermissions {
|
||||
private static final String USER_MODIFY_SELF = CommandPermission.ROOT + "modify.user.self";
|
||||
private static final String USER_MODIFY_OTHERS = CommandPermission.ROOT + "modify.user.others";
|
||||
@ -52,6 +55,15 @@ public final class ArgumentPermissions {
|
||||
private static final String CONTEXT_USE_GLOBAL = CommandPermission.ROOT + "usecontext.global";
|
||||
private static final BiFunction<String, String, String> CONTEXT_USE = (k, v) -> CommandPermission.ROOT + "usecontext." + k + "." + v;
|
||||
|
||||
/**
|
||||
* Checks if the sender has permission to use the given arguments
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param sender the sender to check
|
||||
* @param base the base permission for the command
|
||||
* @param args the arguments the sender is trying to use
|
||||
* @return true if the sender should NOT be allowed to use the arguments, true if they should
|
||||
*/
|
||||
public static boolean checkArguments(LuckPermsPlugin plugin, Sender sender, CommandPermission base, String... args) {
|
||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) {
|
||||
return false;
|
||||
@ -69,6 +81,15 @@ public final class ArgumentPermissions {
|
||||
return !sender.hasPermission(permission.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the sender has permission to modify the given target
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param sender the sender to check
|
||||
* @param base the base permission for the command
|
||||
* @param target the object the sender is truing to modify
|
||||
* @return true if the sender should NOT be allowed to modify the target, true if they should
|
||||
*/
|
||||
public static boolean checkModifyPerms(LuckPermsPlugin plugin, Sender sender, CommandPermission base, Object target) {
|
||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) {
|
||||
return false;
|
||||
@ -125,6 +146,15 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the sender has permission to view the given target
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param sender the sender to check
|
||||
* @param base the base permission for the command
|
||||
* @param target the object the sender is truing to view
|
||||
* @return true if the sender should NOT be allowed to view the target, true if they should
|
||||
*/
|
||||
public static boolean checkViewPerms(LuckPermsPlugin plugin, Sender sender, CommandPermission base, Object target) {
|
||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) {
|
||||
return false;
|
||||
@ -181,6 +211,15 @@ public final class ArgumentPermissions {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the sender has permission to act within a given set of contexts
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param sender the sender to check
|
||||
* @param base the base permission for the command
|
||||
* @param contextSet the contexts the sender is trying to act within
|
||||
* @return true if the sender should NOT be allowed to act, true if they should
|
||||
*/
|
||||
public static boolean checkContext(LuckPermsPlugin plugin, Sender sender, CommandPermission base, ContextSet contextSet) {
|
||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) {
|
||||
return false;
|
@ -23,16 +23,16 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands;
|
||||
package me.lucko.luckperms.common.command.access;
|
||||
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.GROUP;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.LOG;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.NONE;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.SPONGE;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.TRACK;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.Type.USER;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.GROUP;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.LOG;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.NONE;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.SPONGE;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.TRACK;
|
||||
import static me.lucko.luckperms.common.command.access.CommandPermission.Type.USER;
|
||||
|
||||
/**
|
||||
* An enumeration of the permissions required to execute built in LuckPerms commands.
|
@ -23,12 +23,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.utils;
|
||||
package me.lucko.luckperms.common.command.utils;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
@ -41,13 +41,13 @@ import java.util.Optional;
|
||||
/**
|
||||
* Utility class to help process arguments, and throw checked exceptions if the arguments are invalid.
|
||||
*/
|
||||
public class ArgumentUtils {
|
||||
public class ArgumentParser {
|
||||
|
||||
public static String handleString(int index, List<String> args) {
|
||||
public static String parseString(int index, List<String> args) {
|
||||
return args.get(index).replace("{SPACE}", " ");
|
||||
}
|
||||
|
||||
public static String handleStringOrElse(int index, List<String> args, String other) {
|
||||
public static String parseStringOrElse(int index, List<String> args, String other) {
|
||||
if (index < 0 || index >= args.size()) {
|
||||
return other;
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class ArgumentUtils {
|
||||
return args.get(index).replace("{SPACE}", " ");
|
||||
}
|
||||
|
||||
public static int handleIntOrElse(int index, List<String> args, int other) {
|
||||
public static int parseIntOrElse(int index, List<String> args, int other) {
|
||||
if (index < 0 || index >= args.size()) {
|
||||
return other;
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class ArgumentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String handleName(int index, List<String> args) throws ArgumentException {
|
||||
public static String parseName(int index, List<String> args) throws ArgumentException {
|
||||
String groupName = args.get(index).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
throw new DetailedUsageException();
|
||||
@ -75,7 +75,7 @@ public class ArgumentUtils {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public static String handleNameWithSpace(int index, List<String> args) throws ArgumentException {
|
||||
public static String parseNameWithSpace(int index, List<String> args) throws ArgumentException {
|
||||
String groupName = args.get(index).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST_ALLOW_SPACE.test(groupName)) {
|
||||
throw new DetailedUsageException();
|
||||
@ -83,7 +83,7 @@ public class ArgumentUtils {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public static boolean handleBoolean(int index, List<String> args) {
|
||||
public static boolean parseBoolean(int index, List<String> args) {
|
||||
if (index < args.size()) {
|
||||
String bool = args.get(index);
|
||||
if (bool.equalsIgnoreCase("true") || bool.equalsIgnoreCase("false")) {
|
||||
@ -95,7 +95,7 @@ public class ArgumentUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long handleDuration(int index, List<String> args) throws ArgumentException {
|
||||
public static long parseDuration(int index, List<String> args) throws ArgumentException {
|
||||
long duration;
|
||||
try {
|
||||
duration = Long.parseLong(args.get(index));
|
||||
@ -114,7 +114,7 @@ public class ArgumentUtils {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public static Optional<TemporaryModifier> handleTemporaryModifier(int index, List<String> args) {
|
||||
public static Optional<TemporaryModifier> parseTemporaryModifier(int index, List<String> args) {
|
||||
if (index < 0 || index >= args.size()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -129,7 +129,7 @@ public class ArgumentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static MutableContextSet handleContext(int fromIndex, List<String> args, LuckPermsPlugin plugin) throws CommandException {
|
||||
public static MutableContextSet parseContext(int fromIndex, List<String> args, LuckPermsPlugin plugin) throws CommandException {
|
||||
if (args.size() > fromIndex) {
|
||||
MutableContextSet set = MutableContextSet.create();
|
||||
|
||||
@ -169,7 +169,7 @@ public class ArgumentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static MutableContextSet sanitizeContexts(MutableContextSet set) throws ArgumentException {
|
||||
private static MutableContextSet sanitizeContexts(MutableContextSet set) throws ArgumentException {
|
||||
// remove any potential "global" context mappings
|
||||
set.remove(Contexts.SERVER_KEY, "global");
|
||||
set.remove(Contexts.WORLD_KEY, "global");
|
||||
@ -213,7 +213,7 @@ public class ArgumentUtils {
|
||||
return set;
|
||||
}
|
||||
|
||||
public static int handlePriority(int index, List<String> args) throws ArgumentException {
|
||||
public static int parsePriority(int index, List<String> args) throws ArgumentException {
|
||||
try {
|
||||
return Integer.parseInt(args.get(index));
|
||||
} catch (NumberFormatException e) {
|
||||
@ -221,7 +221,7 @@ public class ArgumentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutableContextSet handleContextSponge(int fromIndex, List<String> args) {
|
||||
public static ImmutableContextSet parseContextSponge(int fromIndex, List<String> args) {
|
||||
if (args.size() <= fromIndex) {
|
||||
return ImmutableContextSet.empty();
|
||||
}
|
||||
@ -248,7 +248,7 @@ public class ArgumentUtils {
|
||||
return contextSet.makeImmutable();
|
||||
}
|
||||
|
||||
public static abstract 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 {}
|
@ -23,24 +23,21 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.utils;
|
||||
package me.lucko.luckperms.common.command.utils;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class CommandUtils {
|
||||
public final class MessageUtils {
|
||||
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
||||
|
||||
/**
|
||||
@ -86,27 +83,6 @@ public final class CommandUtils {
|
||||
return s == null ? null : STRIP_COLOR_PATTERN.matcher(s).replaceAll("");
|
||||
}
|
||||
|
||||
public static <T> List<T> nInstances(int count, Supplier<T> supplier) {
|
||||
List<T> ret = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret.add(supplier.get());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> divideList(Iterable<T> source, int size) {
|
||||
List<List<T>> lists = new ArrayList<>();
|
||||
Iterator<T> it = source.iterator();
|
||||
while (it.hasNext()) {
|
||||
List<T> subList = new ArrayList<>();
|
||||
for (int i = 0; it.hasNext() && i < size; i++) {
|
||||
subList.add(it.next());
|
||||
}
|
||||
lists.add(subList);
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
public static String toCommaSep(Collection<String> strings) {
|
||||
if (strings.isEmpty()) {
|
||||
return "&bNone";
|
||||
@ -231,6 +207,6 @@ public final class CommandUtils {
|
||||
return sb.delete(sb.length() - Message.CONTEXT_PAIR_SEP.asString(null).length(), sb.length()).toString();
|
||||
}
|
||||
|
||||
private CommandUtils() {}
|
||||
private MessageUtils() {}
|
||||
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.utils;
|
||||
package me.lucko.luckperms.common.command.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.utils;
|
||||
package me.lucko.luckperms.common.command.utils;
|
||||
|
||||
public enum SortType {
|
||||
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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 me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utility methods for saving users, groups and tracks.
|
||||
*/
|
||||
public final class StorageAssistant {
|
||||
|
||||
public static void save(User user, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveUser(user).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
user.getRefreshBuffer().request();
|
||||
} else {
|
||||
user.getRefreshBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().pushUserUpdate(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveGroup(group).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
} else {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Track track, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveTrack(track).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.TRACK_SAVE_ERROR.send(sender, track.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
} else {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) {
|
||||
if (holder.getType().isUser()) {
|
||||
User user = ((User) holder);
|
||||
save(user, sender, plugin);
|
||||
} else if (holder.getType().isGroup()) {
|
||||
Group group = ((Group) holder);
|
||||
save(group, sender, plugin);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private StorageAssistant() {}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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.Splitter;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.treeview.PermissionVault;
|
||||
import me.lucko.luckperms.common.treeview.TreeNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Utility methods for handling tab completion.
|
||||
*/
|
||||
public final class TabCompletions {
|
||||
|
||||
public static List<String> getGroupTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
public static List<String> getTrackTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
public static List<String> getBoolTabComplete(List<String> args) {
|
||||
if (args.size() == 2) {
|
||||
return Arrays.asList("true", "false");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getPermissionTabComplete(List<String> args, PermissionVault cache) {
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equals("")) {
|
||||
return cache.getRootNode().getChildren()
|
||||
.map(Map::keySet)
|
||||
.map(s -> (List<String>) new ArrayList<>(s))
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
String start = args.get(0).toLowerCase();
|
||||
List<String> parts = new ArrayList<>(Splitter.on('.').splitToList(start));
|
||||
TreeNode root = cache.getRootNode();
|
||||
|
||||
if (parts.size() <= 1) {
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(start)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
String incomplete = parts.remove(parts.size() - 1);
|
||||
|
||||
for (String s : parts) {
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
TreeNode n = root.getChildren().get().get(s);
|
||||
if (n == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
root = n;
|
||||
}
|
||||
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return root.getChildren().get().keySet().stream()
|
||||
.filter(s -> s.startsWith(incomplete))
|
||||
.map(s -> parts.stream().collect(Collectors.joining(".")) + "." + s)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static List<String> getTabComplete(List<String> options, List<String> args) {
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||
return options;
|
||||
}
|
||||
|
||||
return options.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private TabCompletions() {}
|
||||
}
|
@ -1,240 +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.commands.abstraction;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.LocalizedSpec;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.treeview.PermissionVault;
|
||||
import me.lucko.luckperms.common.treeview.TreeNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Abstract SubCommand class
|
||||
*/
|
||||
public abstract class SubCommand<T> extends Command<T, Void> {
|
||||
|
||||
public SubCommand(LocalizedSpec spec, String name, CommandPermission permission, Predicate<Integer> argumentCheck) {
|
||||
super(spec, name, permission, argumentCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the command usage to a sender
|
||||
*
|
||||
* @param sender the sender to send the usage to
|
||||
*/
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (getArgs().isPresent()) {
|
||||
sb.append("&3 - &7");
|
||||
for (Arg arg : getArgs().get()) {
|
||||
sb.append(arg.asPrettyString()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
|
||||
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
|
||||
if (getArgs().isPresent()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
|
||||
for (Arg arg : getArgs().get()) {
|
||||
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Utility methods used by #tabComplete and #execute implementations in sub classes */
|
||||
|
||||
public static List<String> getGroupTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
public static List<String> getTrackTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
public static List<String> getBoolTabComplete(List<String> args) {
|
||||
if (args.size() == 2) {
|
||||
return Arrays.asList("true", "false");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getPermissionTabComplete(List<String> args, PermissionVault cache) {
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equals("")) {
|
||||
return cache.getRootNode().getChildren()
|
||||
.map(Map::keySet)
|
||||
.map(s -> (List<String>) new ArrayList<>(s))
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
String start = args.get(0).toLowerCase();
|
||||
List<String> parts = new ArrayList<>(Splitter.on('.').splitToList(start));
|
||||
TreeNode root = cache.getRootNode();
|
||||
|
||||
if (parts.size() <= 1) {
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(start)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
String incomplete = parts.remove(parts.size() - 1);
|
||||
|
||||
for (String s : parts) {
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
TreeNode n = root.getChildren().get().get(s);
|
||||
if (n == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
root = n;
|
||||
}
|
||||
|
||||
if (!root.getChildren().isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return root.getChildren().get().keySet().stream()
|
||||
.filter(s -> s.startsWith(incomplete))
|
||||
.map(s -> parts.stream().collect(Collectors.joining(".")) + "." + s)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static List<String> getTabComplete(List<String> options, List<String> args) {
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||
return options;
|
||||
}
|
||||
|
||||
return options.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static void save(User user, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveUser(user).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
user.getRefreshBuffer().request();
|
||||
} else {
|
||||
user.getRefreshBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().pushUserUpdate(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveGroup(group).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
} else {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Track track, Sender sender, LuckPermsPlugin plugin) {
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveTrack(track).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.TRACK_SAVE_ERROR.send(sender, track.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
} else {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
}
|
||||
|
||||
if (!sender.isImport()) {
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,20 +23,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
||||
public class CommandMeta<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandMeta(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.META.spec(locale), "Meta", user, ImmutableList.<SharedSubCommand>builder()
|
||||
super(CommandSpec.META.localize(locale), "Meta", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new MetaInfo(locale))
|
||||
.add(new MetaSet(locale))
|
||||
.add(new MetaUnset(locale))
|
@ -23,27 +23,28 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -57,7 +58,7 @@ public class MetaAddChatMeta extends SharedSubCommand {
|
||||
|
||||
public MetaAddChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||
super(
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_ADDPREFIX.spec(locale) : CommandSpec.META_ADDSUFFIX.spec(locale),
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_ADDPREFIX.localize(locale) : CommandSpec.META_ADDSUFFIX.localize(locale),
|
||||
"add" + type.name().toLowerCase(),
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.USER_META_ADD_PREFIX : CommandPermission.USER_META_ADD_SUFFIX,
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_ADD_PREFIX : CommandPermission.GROUP_META_ADD_SUFFIX,
|
||||
@ -73,9 +74,9 @@ public class MetaAddChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String meta = ArgumentUtils.handleString(1, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
int priority = ArgumentParser.parsePriority(0, args);
|
||||
String meta = ArgumentParser.parseString(1, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -84,7 +85,7 @@ public class MetaAddChatMeta extends SharedSubCommand {
|
||||
|
||||
DataMutateResult result = holder.setPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).withExtraContext(context).build());
|
||||
if (result.asBoolean()) {
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
"¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta,
|
||||
'¥'
|
||||
@ -96,10 +97,10 @@ public class MetaAddChatMeta extends SharedSubCommand {
|
||||
.action("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,30 +23,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
@ -62,7 +63,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
|
||||
public MetaAddTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||
super(
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_ADDTEMP_PREFIX.spec(locale) : CommandSpec.META_ADDTEMP_SUFFIX.spec(locale),
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_ADDTEMP_PREFIX.localize(locale) : CommandSpec.META_ADDTEMP_SUFFIX.localize(locale),
|
||||
"addtemp" + type.name().toLowerCase(),
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.USER_META_ADD_TEMP_PREFIX : CommandPermission.USER_META_ADD_TEMP_SUFFIX,
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_ADD_TEMP_PREFIX : CommandPermission.GROUP_META_ADD_TEMP_SUFFIX,
|
||||
@ -78,11 +79,11 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String meta = ArgumentUtils.handleString(1, args);
|
||||
long duration = ArgumentUtils.handleDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin);
|
||||
int priority = ArgumentParser.parsePriority(0, args);
|
||||
String meta = ArgumentParser.parseString(1, args);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -94,7 +95,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
if (ret.getKey().asBoolean()) {
|
||||
duration = ret.getValue().getExpiryUnixTime();
|
||||
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
"¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta,
|
||||
'¥'
|
||||
@ -106,10 +107,10 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
.action("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,32 +23,33 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.MetaType;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetaClear extends SharedSubCommand {
|
||||
public MetaClear(LocaleManager locale) {
|
||||
super(CommandSpec.META_CLEAR.spec(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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +89,7 @@ public class MetaClear extends SharedSubCommand {
|
||||
|
||||
int before = holder.getEnduringNodes().size();
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -103,16 +104,16 @@ public class MetaClear extends SharedSubCommand {
|
||||
|
||||
int changed = before - holder.getEnduringNodes().size();
|
||||
if (changed == 1) {
|
||||
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed);
|
||||
} else {
|
||||
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed);
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta", "clear", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,27 +23,27 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.LocalizedNode;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.MetaComparator;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -52,6 +52,7 @@ import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.ClickEvent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -66,7 +67,7 @@ public class MetaInfo extends SharedSubCommand {
|
||||
}
|
||||
|
||||
public MetaInfo(LocaleManager locale) {
|
||||
super(CommandSpec.META_INFO.spec(locale), "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse());
|
||||
super(CommandSpec.META_INFO.localize(locale), "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,7 +124,7 @@ public class MetaInfo extends SharedSubCommand {
|
||||
for (LocalizedNode m : meta) {
|
||||
String location = processLocation(m, holder);
|
||||
if (m.hasSpecificContext()) {
|
||||
String context = CommandUtils.getAppendableNodeContextString(m);
|
||||
String context = MessageUtils.getAppendableNodeContextString(m);
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context), CommandManager.SECTION_CHAR).toBuilder();
|
||||
builder.applyDeep(makeFancy(holder, label, m));
|
||||
sender.sendMessage(builder.build());
|
||||
@ -139,7 +140,7 @@ public class MetaInfo extends SharedSubCommand {
|
||||
for (Map.Entry<Integer, LocalizedNode> e : meta) {
|
||||
String location = processLocation(e.getValue(), holder);
|
||||
if (e.getValue().hasSpecificContext()) {
|
||||
String context = CommandUtils.getAppendableNodeContextString(e.getValue());
|
||||
String context = MessageUtils.getAppendableNodeContextString(e.getValue());
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.CHAT_META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context), CommandManager.SECTION_CHAR).toBuilder();
|
||||
builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
|
||||
sender.sendMessage(builder.build());
|
||||
@ -198,4 +199,17 @@ public class MetaInfo extends SharedSubCommand {
|
||||
component.clickEvent(clickEvent);
|
||||
};
|
||||
}
|
||||
|
||||
private static final class MetaComparator implements Comparator<Map.Entry<Integer, LocalizedNode>> {
|
||||
public static final MetaComparator INSTANCE = new MetaComparator();
|
||||
|
||||
@Override
|
||||
public int compare(Map.Entry<Integer, LocalizedNode> o1, Map.Entry<Integer, LocalizedNode> o2) {
|
||||
int result = Integer.compare(o1.getKey(), o2.getKey());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return NodeWithContextComparator.normal().compare(o1.getValue(), o2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
@ -23,27 +23,28 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -57,7 +58,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
|
||||
public MetaRemoveChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||
super(
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVEPREFIX.spec(locale) : CommandSpec.META_REMOVESUFFIX.spec(locale),
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVEPREFIX.localize(locale) : CommandSpec.META_REMOVESUFFIX.localize(locale),
|
||||
"remove" + type.name().toLowerCase(),
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.USER_META_REMOVE_PREFIX : CommandPermission.USER_META_REMOVE_SUFFIX,
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_REMOVE_PREFIX : CommandPermission.GROUP_META_REMOVE_SUFFIX,
|
||||
@ -73,9 +74,9 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String meta = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
int priority = ArgumentParser.parsePriority(0, args);
|
||||
String meta = ArgumentParser.parseStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -90,20 +91,20 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
!n.isTemporary() &&
|
||||
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
|
||||
);
|
||||
Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context));
|
||||
Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
"¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta,
|
||||
'¥'
|
||||
@ -115,10 +116,10 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
.action("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,27 +23,28 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -57,7 +58,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
|
||||
public MetaRemoveTempChatMeta(LocaleManager locale, ChatMetaType type) {
|
||||
super(
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVETEMP_PREFIX.spec(locale) : CommandSpec.META_REMOVETEMP_SUFFIX.spec(locale),
|
||||
type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVETEMP_PREFIX.localize(locale) : CommandSpec.META_REMOVETEMP_SUFFIX.localize(locale),
|
||||
"removetemp" + type.name().toLowerCase(),
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.USER_META_REMOVE_TEMP_PREFIX : CommandPermission.USER_META_REMOVE_TEMP_SUFFIX,
|
||||
type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_REMOVE_TEMP_PREFIX : CommandPermission.GROUP_META_REMOVE_TEMP_SUFFIX,
|
||||
@ -73,9 +74,9 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String meta = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
int priority = ArgumentParser.parsePriority(0, args);
|
||||
String meta = ArgumentParser.parseStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -90,20 +91,20 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
!n.isPermanent() &&
|
||||
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
|
||||
);
|
||||
Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context));
|
||||
Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).setExpiry(10L).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
"¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta,
|
||||
'¥'
|
||||
@ -115,10 +116,10 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
.action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,25 +23,26 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -52,7 +53,7 @@ import java.util.List;
|
||||
|
||||
public class MetaSet extends SharedSubCommand {
|
||||
public MetaSet(LocaleManager locale) {
|
||||
super(CommandSpec.META_SET.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +65,7 @@ public class MetaSet extends SharedSubCommand {
|
||||
|
||||
String key = args.get(0);
|
||||
String value = args.get(1);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -79,14 +80,14 @@ public class MetaSet extends SharedSubCommand {
|
||||
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).build();
|
||||
|
||||
if (holder.hasPermission(n).asBoolean()) {
|
||||
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
holder.clearMetaKeys(key, context, false);
|
||||
holder.setPermission(n);
|
||||
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context))).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), MessageUtils.contextSetToString(context))).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
||||
'¥'
|
||||
@ -98,7 +99,7 @@ public class MetaSet extends SharedSubCommand {
|
||||
.action("meta", "set", key, value, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,28 +23,29 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
@ -56,7 +57,7 @@ import java.util.List;
|
||||
|
||||
public class MetaSetTemp extends SharedSubCommand {
|
||||
public MetaSetTemp(LocaleManager locale) {
|
||||
super(CommandSpec.META_SETTEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,9 +69,9 @@ public class MetaSetTemp extends SharedSubCommand {
|
||||
|
||||
String key = args.get(0);
|
||||
String value = args.get(1);
|
||||
long duration = ArgumentUtils.handleDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -85,14 +86,14 @@ public class MetaSetTemp extends SharedSubCommand {
|
||||
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).setExpiry(duration).build();
|
||||
|
||||
if (holder.hasPermission(n).asBoolean()) {
|
||||
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
holder.clearMetaKeys(key, context, true);
|
||||
duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime();
|
||||
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
|
||||
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
||||
'¥'
|
||||
@ -104,7 +105,7 @@ public class MetaSetTemp extends SharedSubCommand {
|
||||
.action("meta", "settemp", key, value, duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,30 +23,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetaUnset extends SharedSubCommand {
|
||||
public MetaUnset(LocaleManager locale) {
|
||||
super(CommandSpec.META_UNSET.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +58,7 @@ public class MetaUnset extends SharedSubCommand {
|
||||
}
|
||||
|
||||
String key = args.get(0);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -70,16 +71,16 @@ public class MetaUnset extends SharedSubCommand {
|
||||
}
|
||||
|
||||
if (holder.clearMetaKeys(key, context, false)) {
|
||||
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta", "unset", key, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context));
|
||||
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,30 +23,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.meta;
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetaUnsetTemp extends SharedSubCommand {
|
||||
public MetaUnsetTemp(LocaleManager locale) {
|
||||
super(CommandSpec.META_UNSETTEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +58,7 @@ public class MetaUnsetTemp extends SharedSubCommand {
|
||||
}
|
||||
|
||||
String key = args.get(0);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -70,16 +71,16 @@ public class MetaUnsetTemp extends SharedSubCommand {
|
||||
}
|
||||
|
||||
if (holder.clearMetaKeys(key, context, true)) {
|
||||
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta", "unsettemp", key, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context));
|
||||
Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,31 +23,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.other;
|
||||
package me.lucko.luckperms.common.commands.generic.other;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
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.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
||||
public HolderClear(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.HOLDER_CLEAR.spec(locale), "clear", user ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse());
|
||||
super(CommandSpec.HOLDER_CLEAR.localize(locale), "clear", user ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +59,7 @@ public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
||||
|
||||
int before = holder.getEnduringNodes().size();
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, getPermission().get(), context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -74,16 +74,16 @@ public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
||||
|
||||
int changed = before - holder.getEnduringNodes().size();
|
||||
if (changed == 1) {
|
||||
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||
} else {
|
||||
Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("clear", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
SharedSubCommand.save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,24 +23,24 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.other;
|
||||
package me.lucko.luckperms.common.commands.generic.other;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.web.StandardPastebin;
|
||||
import me.lucko.luckperms.common.webeditor.WebEditor;
|
||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||
import me.lucko.luckperms.common.web.WebEditor;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
@ -53,7 +53,7 @@ import java.util.List;
|
||||
|
||||
public class HolderEditor<T extends PermissionHolder> extends SubCommand<T> {
|
||||
public HolderEditor(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.HOLDER_EDITOR.spec(locale), "editor", user ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse());
|
||||
super(CommandSpec.HOLDER_EDITOR.localize(locale), "editor", user ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
@ -23,24 +23,24 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.other;
|
||||
package me.lucko.luckperms.common.commands.generic.other;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -51,7 +51,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T> {
|
||||
public HolderShowTracks(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.HOLDER_SHOWTRACKS.spec(locale), "showtracks", user ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse());
|
||||
super(CommandSpec.HOLDER_SHOWTRACKS.localize(locale), "showtracks", user ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +86,7 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Track t : tracks) {
|
||||
lines.add(Maps.immutableEntry(t, CommandUtils.listToArrowSep(t.getGroups(), groupName) + CommandUtils.getAppendableNodeContextString(node)));
|
||||
lines.add(Maps.immutableEntry(t, MessageUtils.listToArrowSep(t.getGroups(), groupName) + MessageUtils.getAppendableNodeContextString(node)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -97,7 +97,7 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Track t : tracks) {
|
||||
lines.add(Maps.immutableEntry(t, CommandUtils.listToArrowSep(t.getGroups(), groupName)));
|
||||
lines.add(Maps.immutableEntry(t, MessageUtils.listToArrowSep(t.getGroups(), groupName)));
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,21 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class CommandParent<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandParent(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.PARENT.spec(locale), "Parent", user, ImmutableList.<SharedSubCommand>builder()
|
||||
super(CommandSpec.PARENT.localize(locale), "Parent", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new ParentInfo(locale))
|
||||
.add(new ParentSet(locale))
|
||||
.add(new ParentAdd(locale))
|
@ -23,35 +23,36 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class ParentAdd extends SharedSubCommand {
|
||||
public ParentAdd(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_ADD.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,8 +62,8 @@ public class ParentAdd extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String groupName = ArgumentParser.parseName(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
@ -83,16 +84,16 @@ public class ParentAdd extends SharedSubCommand {
|
||||
DataMutateResult result = holder.setPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "add", group.getName(), context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,40 +23,41 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class ParentAddTemp extends SharedSubCommand {
|
||||
public ParentAddTemp(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_ADD_TEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,10 +67,10 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
long duration = ArgumentUtils.handleDuration(1, args);
|
||||
TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
String groupName = ArgumentParser.parseName(0, args);
|
||||
long duration = ArgumentParser.parseDuration(1, args);
|
||||
TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
@ -88,7 +89,7 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
}
|
||||
|
||||
if (group.getName().equalsIgnoreCase(holder.getObjectName())) {
|
||||
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
@ -96,16 +97,16 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
|
||||
if (ret.getKey().asBoolean()) {
|
||||
duration = ret.getValue().getExpiryUnixTime();
|
||||
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context));
|
||||
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "addtemp", group.getName(), duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,30 +23,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParentClear extends SharedSubCommand {
|
||||
public ParentClear(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_CLEAR.spec(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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +59,7 @@ public class ParentClear extends SharedSubCommand {
|
||||
|
||||
int before = holder.getEnduringNodes().size();
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -73,16 +74,16 @@ public class ParentClear extends SharedSubCommand {
|
||||
|
||||
int changed = before - holder.getEnduringNodes().size();
|
||||
if (changed == 1) {
|
||||
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||
} else {
|
||||
Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "clear", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,35 +23,36 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getTrackTabComplete;
|
||||
|
||||
public class ParentClearTrack extends SharedSubCommand {
|
||||
public ParentClearTrack(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_CLEAR_TRACK.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +81,7 @@ public class ParentClearTrack extends SharedSubCommand {
|
||||
|
||||
int before = holder.getEnduringNodes().size();
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -105,16 +106,16 @@ public class ParentClearTrack extends SharedSubCommand {
|
||||
int changed = before - holder.getEnduringNodes().size();
|
||||
|
||||
if (changed == 1) {
|
||||
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed);
|
||||
} else {
|
||||
Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed);
|
||||
Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed);
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "cleartrack", track.getName(), context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,29 +23,30 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.LocalizedNode;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.SortMode;
|
||||
import me.lucko.luckperms.common.commands.utils.SortType;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.SortMode;
|
||||
import me.lucko.luckperms.common.command.utils.SortType;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -62,7 +63,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class ParentInfo extends SharedSubCommand {
|
||||
public ParentInfo(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_INFO.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,7 +73,7 @@ public class ParentInfo extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int page = ArgumentUtils.handleIntOrElse(0, args, 1);
|
||||
int page = ArgumentParser.parseIntOrElse(0, args, 1);
|
||||
SortMode sortMode = SortMode.determine(args);
|
||||
|
||||
// get the holders nodes
|
||||
@ -98,7 +99,7 @@ public class ParentInfo extends SharedSubCommand {
|
||||
}
|
||||
|
||||
int pageIndex = page - 1;
|
||||
List<List<LocalizedNode>> pages = CommandUtils.divideList(nodes, 19);
|
||||
List<List<LocalizedNode>> pages = Iterators.divideIterable(nodes, 19);
|
||||
|
||||
if (pageIndex < 0 || pageIndex >= pages.size()) {
|
||||
page = 1;
|
||||
@ -112,7 +113,7 @@ public class ParentInfo extends SharedSubCommand {
|
||||
|
||||
// send content
|
||||
for (LocalizedNode node : content) {
|
||||
String s = "&3> &a" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node);
|
||||
String s = "&3> &a" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node);
|
||||
if (node.isTemporary()) {
|
||||
s += "\n&2 expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime());
|
||||
}
|
@ -23,36 +23,37 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class ParentRemove extends SharedSubCommand {
|
||||
public ParentRemove(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_REMOVE.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,8 +63,8 @@ public class ParentRemove extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = ArgumentUtils.handleNameWithSpace(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String groupName = ArgumentParser.parseNameWithSpace(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -91,7 +92,7 @@ public class ParentRemove extends SharedSubCommand {
|
||||
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.buildGroupNode(groupName).withExtraContext(context).build());
|
||||
if (result.asBoolean()) {
|
||||
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
|
||||
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "remove", groupName, context)
|
||||
@ -101,10 +102,10 @@ public class ParentRemove extends SharedSubCommand {
|
||||
plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false);
|
||||
}
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,34 +23,35 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class ParentRemoveTemp extends SharedSubCommand {
|
||||
public ParentRemoveTemp(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_REMOVE_TEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +61,8 @@ public class ParentRemoveTemp extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = ArgumentUtils.handleNameWithSpace(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String groupName = ArgumentParser.parseNameWithSpace(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -76,16 +77,16 @@ public class ParentRemoveTemp extends SharedSubCommand {
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.buildGroupNode(groupName).setExpiry(10L).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
|
||||
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "removetemp", groupName, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,35 +23,36 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class ParentSet extends SharedSubCommand {
|
||||
public ParentSet(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_SET.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,8 +62,8 @@ public class ParentSet extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String groupName = ArgumentParser.parseName(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
@ -86,13 +87,13 @@ public class ParentSet extends SharedSubCommand {
|
||||
((User) holder).getPrimaryGroup().setStoredValue(group.getName());
|
||||
}
|
||||
|
||||
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "set", group.getName(), context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,37 +23,38 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getTrackTabComplete;
|
||||
|
||||
public class ParentSetTrack extends SharedSubCommand {
|
||||
public ParentSetTrack(LocaleManager locale) {
|
||||
super(CommandSpec.PARENT_SET_TRACK.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +81,7 @@ public class ParentSetTrack extends SharedSubCommand {
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
int index = ArgumentUtils.handleIntOrElse(1, args, -1);
|
||||
int index = ArgumentParser.parseIntOrElse(1, args, -1);
|
||||
String groupName;
|
||||
if (index > 0) {
|
||||
List<String> trackGroups = track.getGroups();
|
||||
@ -90,14 +91,14 @@ public class ParentSetTrack extends SharedSubCommand {
|
||||
}
|
||||
groupName = track.getGroups().get(index - 1);
|
||||
} else {
|
||||
groupName = ArgumentUtils.handleName(1, args);
|
||||
groupName = ArgumentParser.parseName(1, args);
|
||||
if (!track.containsGroup(groupName)) {
|
||||
Message.TRACK_DOES_NOT_CONTAIN.send(sender, track.getName(), groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
}
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
@ -118,13 +119,13 @@ public class ParentSetTrack extends SharedSubCommand {
|
||||
holder.removeIf(node -> node.isGroupNode() && node.getFullContexts().equals(context) && track.containsGroup(node.getGroupName()));
|
||||
holder.setPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(context).build());
|
||||
|
||||
Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("parent", "settrack", track.getName(), groupName, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,32 +23,33 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.parent;
|
||||
package me.lucko.luckperms.common.commands.generic.parent;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete;
|
||||
|
||||
public class UserSwitchPrimaryGroup extends SharedSubCommand {
|
||||
public UserSwitchPrimaryGroup(LocaleManager locale) {
|
||||
super(CommandSpec.USER_SWITCHPRIMARYGROUP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -91,7 +92,7 @@ public class UserSwitchPrimaryGroup extends SharedSubCommand {
|
||||
.action("parent", "switchprimarygroup", group.getName())
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(user, sender, plugin);
|
||||
StorageAssistant.save(user, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedMainCommand;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
||||
public class CommandPermission<T extends PermissionHolder> extends SharedMainCommand<T> {
|
||||
public CommandPermission(LocaleManager locale, boolean user) {
|
||||
super(CommandSpec.PERMISSION.spec(locale), "Permission", user, ImmutableList.<SharedSubCommand>builder()
|
||||
super(CommandSpec.PERMISSION.localize(locale), "Permission", user, ImmutableList.<SharedSubCommand>builder()
|
||||
.add(new PermissionInfo(locale))
|
||||
.add(new PermissionSet(locale))
|
||||
.add(new PermissionUnset(locale))
|
@ -23,34 +23,34 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionCheck extends SharedSubCommand {
|
||||
public PermissionCheck(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_CHECK.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,13 +60,13 @@ public class PermissionCheck extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
Tristate result = holder.hasPermission(NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||
String s = CommandUtils.formatTristate(result);
|
||||
String s = MessageUtils.formatTristate(result);
|
||||
|
||||
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context));
|
||||
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,34 +23,34 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.InheritanceInfo;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionCheckInherits extends SharedSubCommand {
|
||||
public PermissionCheckInherits(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_CHECK_INHERITS.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +60,8 @@ public class PermissionCheckInherits extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
InheritanceInfo result = holder.searchForInheritedMatch(NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||
|
||||
@ -70,8 +70,8 @@ public class PermissionCheckInherits extends SharedSubCommand {
|
||||
location = "self";
|
||||
}
|
||||
|
||||
String s = CommandUtils.formatTristate(result.getResult());
|
||||
Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context), String.valueOf(location));
|
||||
String s = MessageUtils.formatTristate(result.getResult());
|
||||
Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context), String.valueOf(location));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -23,29 +23,30 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.LocalizedNode;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.SortMode;
|
||||
import me.lucko.luckperms.common.commands.utils.SortType;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.SortMode;
|
||||
import me.lucko.luckperms.common.command.utils.SortType;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -62,7 +63,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class PermissionInfo extends SharedSubCommand {
|
||||
public PermissionInfo(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_INFO.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,7 +73,7 @@ public class PermissionInfo extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int page = ArgumentUtils.handleIntOrElse(0, args, 1);
|
||||
int page = ArgumentParser.parseIntOrElse(0, args, 1);
|
||||
SortMode sortMode = SortMode.determine(args);
|
||||
|
||||
// get the holders nodes
|
||||
@ -103,7 +104,7 @@ public class PermissionInfo extends SharedSubCommand {
|
||||
}
|
||||
|
||||
int pageIndex = page - 1;
|
||||
List<List<LocalizedNode>> pages = CommandUtils.divideList(nodes, 19);
|
||||
List<List<LocalizedNode>> pages = Iterators.divideIterable(nodes, 19);
|
||||
|
||||
if (pageIndex < 0 || pageIndex >= pages.size()) {
|
||||
page = 1;
|
||||
@ -117,7 +118,7 @@ public class PermissionInfo extends SharedSubCommand {
|
||||
|
||||
// send content
|
||||
for (LocalizedNode node : content) {
|
||||
String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValuePrimitive() + "&7)" : "") + CommandUtils.getAppendableNodeContextString(node);
|
||||
String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValuePrimitive() + "&7)" : "") + MessageUtils.getAppendableNodeContextString(node);
|
||||
if (node.isTemporary()) {
|
||||
s += "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime());
|
||||
}
|
@ -23,35 +23,36 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolTabComplete;
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getBoolTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionSet extends SharedSubCommand {
|
||||
public PermissionSet(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_SET.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,9 +62,9 @@ public class PermissionSet extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
boolean value = ArgumentUtils.handleBoolean(1, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
boolean value = ArgumentParser.parseBoolean(1, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -78,16 +79,16 @@ public class PermissionSet extends SharedSubCommand {
|
||||
DataMutateResult result = holder.setPermission(NodeFactory.builder(node).setValue(value).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("permission", "set", node, value, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,40 +23,41 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolTabComplete;
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getBoolTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionSetTemp extends SharedSubCommand {
|
||||
public PermissionSetTemp(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_SETTEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,11 +67,11 @@ public class PermissionSetTemp extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
boolean value = ArgumentUtils.handleBoolean(1, args);
|
||||
long duration = ArgumentUtils.handleDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
boolean value = ArgumentParser.parseBoolean(1, args);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -86,16 +87,16 @@ public class PermissionSetTemp extends SharedSubCommand {
|
||||
|
||||
if (result.getKey().asBoolean()) {
|
||||
duration = result.getValue().getExpiryUnixTime();
|
||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context));
|
||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("permission", "settemp", node, value, duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
|
||||
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,34 +23,35 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionUnset extends SharedSubCommand {
|
||||
public PermissionUnset(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_UNSET.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +61,8 @@ public class PermissionUnset extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -76,16 +77,16 @@ public class PermissionUnset extends SharedSubCommand {
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("permission", "unset", node, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,34 +23,35 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.generic.permission;
|
||||
package me.lucko.luckperms.common.commands.generic.permission;
|
||||
|
||||
import me.lucko.luckperms.api.DataMutateResult;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete;
|
||||
import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete;
|
||||
|
||||
public class PermissionUnsetTemp extends SharedSubCommand {
|
||||
public PermissionUnsetTemp(LocaleManager locale) {
|
||||
super(CommandSpec.PERMISSION_UNSETTEMP.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +61,8 @@ public class PermissionUnsetTemp extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String node = ArgumentUtils.handleString(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
@ -76,16 +77,16 @@ public class PermissionUnsetTemp extends SharedSubCommand {
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).setExpiry(10L).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
|
||||
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), MessageUtils.contextSetToString(context));
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||
.action("permission", "unsettemp", node, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
|
||||
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context));
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
@ -43,7 +43,7 @@ import java.util.List;
|
||||
|
||||
public class CreateGroup extends SingleCommand {
|
||||
public CreateGroup(LocaleManager locale) {
|
||||
super(CommandSpec.CREATE_GROUP.spec(locale), "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1));
|
||||
super(CommandSpec.CREATE_GROUP.localize(locale), "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
@ -23,29 +23,29 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.TabCompletions;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteGroup extends SingleCommand {
|
||||
public DeleteGroup(LocaleManager locale) {
|
||||
super(CommandSpec.DELETE_GROUP.spec(locale), "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1));
|
||||
super(CommandSpec.DELETE_GROUP.localize(locale), "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,6 +88,6 @@ public class DeleteGroup extends SingleCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return SubCommand.getGroupTabComplete(args, plugin);
|
||||
return TabCompletions.getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -23,20 +23,21 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
@ -44,7 +45,7 @@ import java.util.List;
|
||||
|
||||
public class GroupClone extends SubCommand<Group> {
|
||||
public GroupClone(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_CLONE.spec(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1));
|
||||
super(CommandSpec.GROUP_CLONE.localize(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +80,7 @@ public class GroupClone extends SubCommand<Group> {
|
||||
.action("clone", group.getName())
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(newGroup, sender, plugin);
|
||||
StorageAssistant.save(newGroup, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,20 +23,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class GroupInfo extends SubCommand<Group> {
|
||||
public GroupInfo(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_INFO.spec(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse());
|
||||
super(CommandSpec.GROUP_INFO.localize(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,14 +75,14 @@ public class GroupInfo extends SubCommand<Group> {
|
||||
if (!parents.isEmpty()) {
|
||||
Message.INFO_PARENT_HEADER.send(sender);
|
||||
for (Node node : parents) {
|
||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
|
||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node));
|
||||
}
|
||||
}
|
||||
|
||||
if (!tempParents.isEmpty()) {
|
||||
Message.INFO_TEMP_PARENT_HEADER.send(sender);
|
||||
for (Node node : tempParents) {
|
||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
|
||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node));
|
||||
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
@ -31,22 +31,23 @@ import com.google.common.collect.Maps;
|
||||
|
||||
import me.lucko.luckperms.api.HeldPermission;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.references.HolderType;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Iterators;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -65,7 +66,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class GroupListMembers extends SubCommand<Group> {
|
||||
public GroupListMembers(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_LISTMEMBERS.spec(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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,7 +77,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
||||
}
|
||||
|
||||
String query = NodeFactory.groupNode(group.getName());
|
||||
int page = ArgumentUtils.handleIntOrElse(0, args, 1);
|
||||
int page = ArgumentParser.parseIntOrElse(0, args, 1);
|
||||
|
||||
Message.SEARCH_SEARCHING_MEMBERS.send(sender, group.getName());
|
||||
|
||||
@ -121,7 +122,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
||||
});
|
||||
|
||||
int pageIndex = page - 1;
|
||||
List<List<HeldPermission<T>>> pages = CommandUtils.divideList(results, 15);
|
||||
List<List<HeldPermission<T>>> pages = Iterators.divideIterable(results, 15);
|
||||
|
||||
if (pageIndex < 0 || pageIndex >= pages.size()) {
|
||||
page = 1;
|
||||
@ -138,7 +139,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
||||
headerMessage.send(sender, page, pages.size(), results.size());
|
||||
|
||||
for (Map.Entry<String, HeldPermission<T>> ent : mappedContent) {
|
||||
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + CommandUtils.getAppendableNodeContextString(ent.getValue().asNode());
|
||||
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(ent.getValue().asNode());
|
||||
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue())).build();
|
||||
sender.sendMessage(message);
|
||||
}
|
@ -23,26 +23,26 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.commands.abstraction.Command;
|
||||
import me.lucko.luckperms.common.commands.abstraction.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.meta.CommandMeta;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.other.HolderClear;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.other.HolderEditor;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
||||
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.HolderEditor;
|
||||
import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks;
|
||||
import me.lucko.luckperms.common.commands.generic.parent.CommandParent;
|
||||
import me.lucko.luckperms.common.commands.generic.permission.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -60,7 +60,7 @@ public class GroupMainCommand extends MainCommand<Group, String> {
|
||||
.build(key -> new ReentrantLock());
|
||||
|
||||
public GroupMainCommand(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP.spec(locale), "Group", 2, ImmutableList.<Command<Group, ?>>builder()
|
||||
super(CommandSpec.GROUP.localize(locale), "Group", 2, ImmutableList.<Command<Group, ?>>builder()
|
||||
.add(new GroupInfo(locale))
|
||||
.add(new CommandPermission<>(locale, false))
|
||||
.add(new CommandParent<>(locale, false))
|
@ -23,20 +23,21 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
@ -44,7 +45,7 @@ import java.util.List;
|
||||
|
||||
public class GroupRename extends SubCommand<Group> {
|
||||
public GroupRename(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_RENAME.spec(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1));
|
||||
super(CommandSpec.GROUP_RENAME.localize(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,7 +86,7 @@ public class GroupRename extends SubCommand<Group> {
|
||||
.action("rename", newGroup.getName())
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(newGroup, sender, plugin);
|
||||
StorageAssistant.save(newGroup, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,28 +23,29 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroupSetDisplayName extends SubCommand<Group> {
|
||||
public GroupSetDisplayName(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_SET_DISPLAY_NAME.spec(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.not(1));
|
||||
super(CommandSpec.GROUP_SET_DISPLAY_NAME.localize(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,7 +55,7 @@ public class GroupSetDisplayName extends SubCommand<Group> {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String name = ArgumentUtils.handleString(0, args);
|
||||
String name = ArgumentParser.parseString(0, args);
|
||||
String previousName = group.getDisplayName().orElse(null);
|
||||
|
||||
if (previousName == null && name.equals(group.getName())) {
|
||||
@ -82,7 +83,7 @@ public class GroupSetDisplayName extends SubCommand<Group> {
|
||||
.action("setdisplayname", name)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(group, sender, plugin);
|
||||
StorageAssistant.save(group, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ public class GroupSetDisplayName extends SubCommand<Group> {
|
||||
.action("setdisplayname", name)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(group, sender, plugin);
|
||||
StorageAssistant.save(group, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,29 +23,30 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
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.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroupSetWeight extends SubCommand<Group> {
|
||||
public GroupSetWeight(LocaleManager locale) {
|
||||
super(CommandSpec.GROUP_SETWEIGHT.spec(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1));
|
||||
super(CommandSpec.GROUP_SETWEIGHT.localize(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,7 +56,7 @@ public class GroupSetWeight extends SubCommand<Group> {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
int weight = ArgumentUtils.handlePriority(0, args);
|
||||
int weight = ArgumentParser.parsePriority(0, args);
|
||||
|
||||
group.removeIf(n -> NodeFactory.parseWeightNode(n.getPermission()) != null);
|
||||
group.setPermission(NodeFactory.buildWeightNode(weight).build());
|
||||
@ -66,7 +67,7 @@ public class GroupSetWeight extends SubCommand<Group> {
|
||||
.action("setweight", weight)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(group, sender, plugin);
|
||||
StorageAssistant.save(group, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.group;
|
||||
package me.lucko.luckperms.common.commands.group;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
@ -49,7 +49,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ListGroups extends SingleCommand {
|
||||
public ListGroups(LocaleManager locale) {
|
||||
super(CommandSpec.LIST_GROUPS.spec(locale), "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse());
|
||||
super(CommandSpec.LIST_GROUPS.localize(locale), "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +82,7 @@ public class ListGroups extends SingleCommand {
|
||||
component = TextUtils.fromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(),
|
||||
group.getFriendlyName(),
|
||||
group.getWeight().orElse(0),
|
||||
CommandUtils.toCommaSep(tracks)
|
||||
MessageUtils.toCommaSep(tracks)
|
||||
), CommandManager.SECTION_CHAR);
|
||||
}
|
||||
|
@ -23,18 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.TabCompletions;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
@ -47,7 +48,7 @@ public class LogGroupHistory extends SubCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public LogGroupHistory(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_GROUP_HISTORY.spec(locale), "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2));
|
||||
super(CommandSpec.LOG_GROUP_HISTORY.localize(locale), "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +108,6 @@ public class LogGroupHistory extends SubCommand<Log> {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
return TabCompletions.getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -23,18 +23,18 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.abstraction.Command;
|
||||
import me.lucko.luckperms.common.commands.abstraction.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -46,7 +46,7 @@ public class LogMainCommand extends MainCommand<Log, Object> {
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
public LogMainCommand(LocaleManager locale) {
|
||||
super(CommandSpec.LOG.spec(locale), "Log", 1, ImmutableList.<Command<Log, ?>>builder()
|
||||
super(CommandSpec.LOG.localize(locale), "Log", 1, ImmutableList.<Command<Log, ?>>builder()
|
||||
.add(new LogRecent(locale))
|
||||
.add(new LogSearch(locale))
|
||||
.add(new LogNotify(locale))
|
@ -23,20 +23,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
@ -45,7 +45,7 @@ import java.util.UUID;
|
||||
|
||||
public class LogNotify extends SubCommand<Log> {
|
||||
public LogNotify(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_NOTIFY.spec(locale), "notify", CommandPermission.LOG_NOTIFY, Predicates.notInRange(0, 1));
|
||||
super(CommandSpec.LOG_NOTIFY.localize(locale), "notify", CommandPermission.LOG_NOTIFY, Predicates.notInRange(0, 1));
|
||||
}
|
||||
|
||||
public static boolean isIgnoring(LuckPermsPlugin plugin, UUID uuid) {
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
@ -50,7 +50,7 @@ public class LogRecent extends SubCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public LogRecent(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_RECENT.spec(locale), "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2));
|
||||
super(CommandSpec.LOG_RECENT.localize(locale), "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2));
|
||||
}
|
||||
|
||||
@Override
|
@ -23,18 +23,18 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
@ -47,7 +47,7 @@ public class LogSearch extends SubCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public LogSearch(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_SEARCH.spec(locale), "search", CommandPermission.LOG_SEARCH, Predicates.is(0));
|
||||
super(CommandSpec.LOG_SEARCH.localize(locale), "search", CommandPermission.LOG_SEARCH, Predicates.is(0));
|
||||
}
|
||||
|
||||
@Override
|
@ -23,18 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.TabCompletions;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
@ -47,7 +48,7 @@ public class LogTrackHistory extends SubCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public LogTrackHistory(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_TRACK_HISTORY.spec(locale), "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2));
|
||||
super(CommandSpec.LOG_TRACK_HISTORY.localize(locale), "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +108,6 @@ public class LogTrackHistory extends SubCommand<Log> {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getTrackTabComplete(args, plugin);
|
||||
return TabCompletions.getTrackTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.log;
|
||||
package me.lucko.luckperms.common.commands.log;
|
||||
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
@ -50,7 +50,7 @@ public class LogUserHistory extends SubCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public LogUserHistory(LocaleManager locale) {
|
||||
super(CommandSpec.LOG_USER_HISTORY.spec(locale), "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2));
|
||||
super(CommandSpec.LOG_USER_HISTORY.localize(locale), "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2));
|
||||
}
|
||||
|
||||
@Override
|
@ -23,19 +23,19 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.migration;
|
||||
package me.lucko.luckperms.common.commands.migration;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.Command;
|
||||
import me.lucko.luckperms.common.commands.abstraction.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||
import me.lucko.luckperms.common.command.abstraction.MainCommand;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -65,7 +65,7 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
||||
private boolean display = true;
|
||||
|
||||
public MigrationMainCommand(LocaleManager locale) {
|
||||
super(CommandSpec.MIGRATION.spec(locale), "Migration", 1, null);
|
||||
super(CommandSpec.MIGRATION.localize(locale), "Migration", 1, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -77,7 +77,7 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
||||
// Add dummy command to show in the list.
|
||||
if (this.commands.isEmpty()) {
|
||||
this.display = false;
|
||||
this.commands.add(new SubCommand<Object>(CommandSpec.MIGRATION_COMMAND.spec(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) {
|
||||
this.commands.add(new SubCommand<Object>(CommandSpec.MIGRATION_COMMAND.localize(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||
return CommandResult.SUCCESS;
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.migration;
|
||||
package me.lucko.luckperms.common.commands.migration;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.model.Group;
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.misc;
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonArray;
|
||||
@ -32,22 +32,22 @@ import com.google.gson.JsonObject;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.node.NodeModel;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.webeditor.WebEditor;
|
||||
import me.lucko.luckperms.common.web.WebEditor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -57,7 +57,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ApplyEditsCommand extends SingleCommand {
|
||||
public ApplyEditsCommand(LocaleManager locale) {
|
||||
super(CommandSpec.APPLY_EDITS.spec(locale), "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2));
|
||||
super(CommandSpec.APPLY_EDITS.localize(locale), "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,12 +135,12 @@ public class ApplyEditsCommand extends SingleCommand {
|
||||
for (Node n : diff.getValue()) {
|
||||
Message.APPLY_EDITS_DIFF_REMOVED.send(sender, formatNode(n));
|
||||
}
|
||||
SharedSubCommand.save(holder, sender, plugin);
|
||||
StorageAssistant.save(holder, sender, plugin);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String formatNode(Node n) {
|
||||
return n.getPermission() + " &7(" + (n.getValuePrimitive() ? "&a" : "&c") + n.getValuePrimitive() + "&7)" + CommandUtils.getAppendableNodeContextString(n) +
|
||||
return n.getPermission() + " &7(" + (n.getValuePrimitive() ? "&a" : "&c") + n.getValuePrimitive() + "&7)" + MessageUtils.getAppendableNodeContextString(n) +
|
||||
(n.isTemporary() ? " &7(" + DateUtil.formatDateDiffShort(n.getExpiryUnixTime()) + ")" : "");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.misc;
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
@ -37,16 +37,16 @@ import me.lucko.luckperms.common.bulkupdate.comparisons.Comparison;
|
||||
import me.lucko.luckperms.common.bulkupdate.comparisons.StandardComparison;
|
||||
import me.lucko.luckperms.common.bulkupdate.constraint.Constraint;
|
||||
import me.lucko.luckperms.common.bulkupdate.constraint.QueryField;
|
||||
import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
@ -57,7 +57,7 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
private final Cache<String, BulkUpdate> pendingOperations = Caffeine.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build();
|
||||
|
||||
public BulkUpdateCommand(LocaleManager locale) {
|
||||
super(CommandSpec.BULK_UPDATE.spec(locale), "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse());
|
||||
super(CommandSpec.BULK_UPDATE.localize(locale), "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +86,7 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
if (args.size() < 2) {
|
||||
throw new ArgumentUtils.DetailedUsageException();
|
||||
throw new ArgumentParser.DetailedUsageException();
|
||||
}
|
||||
|
||||
BulkUpdateBuilder bulkUpdateBuilder = BulkUpdateBuilder.create();
|
||||
@ -105,20 +105,20 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
break;
|
||||
case "update":
|
||||
if (args.size() < 2) {
|
||||
throw new ArgumentUtils.DetailedUsageException();
|
||||
throw new ArgumentParser.DetailedUsageException();
|
||||
}
|
||||
|
||||
String field = args.remove(0);
|
||||
QueryField queryField = QueryField.of(field);
|
||||
if (queryField == null) {
|
||||
throw new ArgumentUtils.DetailedUsageException();
|
||||
throw new ArgumentParser.DetailedUsageException();
|
||||
}
|
||||
String value = args.remove(0);
|
||||
|
||||
bulkUpdateBuilder.action(UpdateAction.of(queryField, value));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentUtils.DetailedUsageException();
|
||||
throw new ArgumentParser.DetailedUsageException();
|
||||
}
|
||||
|
||||
for (String constraint : args) {
|
@ -23,20 +23,20 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.misc;
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.TabCompletions;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.Uuids;
|
||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
||||
@ -47,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class CheckCommand extends SingleCommand {
|
||||
public CheckCommand(LocaleManager locale) {
|
||||
super(CommandSpec.CHECK.spec(locale), "Check", CommandPermission.CHECK, Predicates.not(2));
|
||||
super(CommandSpec.CHECK.localize(locale), "Check", CommandPermission.CHECK, Predicates.not(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +69,7 @@ public class CheckCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
Tristate tristate = user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts())).getPermissionValue(permission, CheckOrigin.INTERNAL);
|
||||
Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, CommandUtils.formatTristate(tristate));
|
||||
Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, MessageUtils.formatTristate(tristate));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -84,6 +84,6 @@ public class CheckCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
args.remove(0);
|
||||
return SubCommand.getPermissionTabComplete(args, plugin.getPermissionVault());
|
||||
return TabCompletions.getPermissionTabComplete(args, plugin.getPermissionVault());
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.misc;
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@ -37,23 +37,23 @@ import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackElement;
|
||||
import me.lucko.luckperms.common.caching.type.MetaCache;
|
||||
import me.lucko.luckperms.common.caching.type.PermissionCache;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.contexts.ContextSetJsonSerializer;
|
||||
import me.lucko.luckperms.common.contexts.ProxiedContextCalculator;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.gson.JArray;
|
||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||
import me.lucko.luckperms.common.utils.web.Pastebin;
|
||||
import me.lucko.luckperms.common.utils.web.StandardPastebin;
|
||||
import me.lucko.luckperms.common.web.Pastebin;
|
||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
@ -73,7 +73,7 @@ public class DebugCommand extends SingleCommand {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public DebugCommand(LocaleManager locale) {
|
||||
super(CommandSpec.DEBUG.spec(locale), "Debug", CommandPermission.DEBUG, Predicates.alwaysFalse());
|
||||
super(CommandSpec.DEBUG.localize(locale), "Debug", CommandPermission.DEBUG, Predicates.alwaysFalse());
|
||||
}
|
||||
|
||||
@Override
|
@ -23,25 +23,25 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.commands.impl.misc;
|
||||
package me.lucko.luckperms.common.commands.misc;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.lucko.luckperms.common.commands.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
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.utils.Predicates;
|
||||
import me.lucko.luckperms.common.utils.web.StandardPastebin;
|
||||
import me.lucko.luckperms.common.webeditor.WebEditor;
|
||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||
import me.lucko.luckperms.common.web.WebEditor;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
@ -54,7 +54,7 @@ import java.util.List;
|
||||
|
||||
public class EditorCommand extends SingleCommand {
|
||||
public EditorCommand(LocaleManager locale) {
|
||||
super(CommandSpec.EDITOR.spec(locale), "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 1));
|
||||
super(CommandSpec.EDITOR.localize(locale), "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public class EditorCommand extends SingleCommand {
|
||||
Type type = Type.ALL;
|
||||
|
||||
// parse type
|
||||
String typeString = ArgumentUtils.handleStringOrElse(0, args, null);
|
||||
String typeString = ArgumentParser.parseStringOrElse(0, args, null);
|
||||
if (typeString != null) {
|
||||
try {
|
||||
type = Type.valueOf(typeString.toUpperCase());
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user