mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Refactor commands
This commit is contained in:
parent
0c33b26fa9
commit
90f8dbe243
@ -26,6 +26,7 @@ import de.bananaco.bpermissions.api.*;
|
|||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -86,7 +87,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
|
|
||||||
WorldManager worldManager = WorldManager.getInstance();
|
WorldManager worldManager = WorldManager.getInstance();
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.bukkit.migration;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -53,7 +50,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
if (!plugin.isPluginLoaded("GroupManager")) {
|
if (!plugin.isPluginLoaded("GroupManager")) {
|
||||||
log.severe("GroupManager Migration: Error -> GroupManager is not loaded.");
|
log.severe("GroupManager Migration: Error -> GroupManager is not loaded.");
|
||||||
|
@ -26,10 +26,7 @@ import me.lucko.luckperms.api.Logger;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -57,7 +54,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
if (!plugin.isPluginLoaded("PermissionsEx")) {
|
if (!plugin.isPluginLoaded("PermissionsEx")) {
|
||||||
log.severe("PermissionsEx Migration: Error -> PermissionsEx is not loaded.");
|
log.severe("PermissionsEx Migration: Error -> PermissionsEx is not loaded.");
|
||||||
|
@ -30,10 +30,7 @@ import me.lucko.luckperms.api.Logger;
|
|||||||
import me.lucko.luckperms.api.data.Callback;
|
import me.lucko.luckperms.api.data.Callback;
|
||||||
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
|
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -132,7 +129,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
try {
|
try {
|
||||||
return run(plugin, args);
|
return run(plugin, args);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -25,10 +25,7 @@ package me.lucko.luckperms.bukkit.migration;
|
|||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -52,7 +49,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
if (!plugin.isPluginLoaded("zPermissions")) {
|
if (!plugin.isPluginLoaded("zPermissions")) {
|
||||||
log.severe("zPermissions Migration: Error -> zPermissions is not loaded.");
|
log.severe("zPermissions Migration: Error -> zPermissions is not loaded.");
|
||||||
|
@ -25,6 +25,7 @@ package me.lucko.luckperms.bungee.migration;
|
|||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -47,7 +48,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
|
|
||||||
BungeePerms bp = BungeePerms.getInstance();
|
BungeePerms bp = BungeePerms.getInstance();
|
||||||
|
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||||
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class to help process arguments, and throw checked exceptions if the arguments are invalid.
|
||||||
|
*/
|
||||||
|
public class ArgumentUtils {
|
||||||
|
public static final Function<String, String> WRAPPER = s -> s.contains(" ") ? "\"" + s + "\"" : s;
|
||||||
|
|
||||||
|
public static String handleNodeWithoutCheck(int index, List<String> args) {
|
||||||
|
return args.get(index).replace("{SPACE}", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleNode(int index, List<String> args) throws ArgumentException {
|
||||||
|
String node = args.get(index).replace("{SPACE}", " ");
|
||||||
|
if (ArgumentChecker.checkNode(node)) {
|
||||||
|
throw new DetailedUsageException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.toLowerCase().startsWith("group.")) {
|
||||||
|
throw new UseInheritException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleName(int index, List<String> args) throws ArgumentException {
|
||||||
|
String groupName = args.get(index).toLowerCase();
|
||||||
|
if (ArgumentChecker.checkName(groupName)) {
|
||||||
|
throw new DetailedUsageException();
|
||||||
|
}
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean handleBoolean(int index, List<String> args) throws ArgumentException {
|
||||||
|
String bool = args.get(index);
|
||||||
|
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
|
||||||
|
throw new DetailedUsageException();
|
||||||
|
}
|
||||||
|
return Boolean.parseBoolean(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleServer(int index, List<String> args) throws ArgumentException {
|
||||||
|
if (args.size() > index) {
|
||||||
|
final String server = args.get(index).toLowerCase();
|
||||||
|
if (ArgumentChecker.checkServer(server)) {
|
||||||
|
throw new InvalidServerException();
|
||||||
|
}
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long handleDuration(int index, List<String> args) throws ArgumentException {
|
||||||
|
long duration;
|
||||||
|
try {
|
||||||
|
duration = Long.parseLong(args.get(index));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
try {
|
||||||
|
duration = DateUtil.parseDateDiff(args.get(index), true);
|
||||||
|
} catch (DateUtil.IllegalDateException e1) {
|
||||||
|
throw new InvalidDateException(args.get(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DateUtil.shouldExpire(duration)) {
|
||||||
|
throw new PastDateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleWorld(int index, List<String> args) {
|
||||||
|
return args.size() > index ? args.get(index).toLowerCase() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int handlePriority(int index, List<String> args) throws ArgumentException {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(args.get(index));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidPriorityException(args.get(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class ArgumentException extends CommandException {}
|
||||||
|
public static class DetailedUsageException extends ArgumentException {}
|
||||||
|
public static class UseInheritException extends ArgumentException {}
|
||||||
|
public static class InvalidServerException extends ArgumentException {}
|
||||||
|
public static class PastDateException extends ArgumentException {}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class InvalidDateException extends ArgumentException {
|
||||||
|
private final String invalidDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class InvalidPriorityException extends ArgumentException {
|
||||||
|
private final String invalidPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to be thrown if there is an error processing a command
|
||||||
|
*/
|
||||||
|
public class CommandException extends Exception {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility used to help in commands that take arguments for different contexts
|
||||||
|
*/
|
||||||
|
public class ContextHelper {
|
||||||
|
|
||||||
|
public enum CommandContext {
|
||||||
|
NONE, SERVER, SERVER_AND_WORLD
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandContext determine(String server, String world) {
|
||||||
|
return server == null ? CommandContext.NONE : (world == null ? CommandContext.SERVER : CommandContext.SERVER_AND_WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -105,7 +105,12 @@ public abstract class MainCommand<T> {
|
|||||||
final String name = args.get(0).toLowerCase();
|
final String name = args.get(0).toLowerCase();
|
||||||
T t = getTarget(name, plugin, sender);
|
T t = getTarget(name, plugin, sender);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
CommandResult result = sub.execute(plugin, sender, t, strippedArgs, label);
|
CommandResult result;
|
||||||
|
try {
|
||||||
|
result = sub.execute(plugin, sender, t, strippedArgs, label);
|
||||||
|
} catch (CommandException e) {
|
||||||
|
result = handleException(e, sender, sub);
|
||||||
|
}
|
||||||
cleanup(t, plugin);
|
cleanup(t, plugin);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -113,6 +118,44 @@ public abstract class MainCommand<T> {
|
|||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CommandResult handleException(CommandException e, Sender sender, SubCommand command) {
|
||||||
|
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||||
|
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||||
|
command.sendDetailedUsage(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.UseInheritException) {
|
||||||
|
Message.USE_INHERIT_COMMAND.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidServerException) {
|
||||||
|
Message.SERVER_INVALID_ENTRY.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.PastDateException) {
|
||||||
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||||
|
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||||
|
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not something we can catch.
|
||||||
|
e.printStackTrace();
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the object the command is acting upon, and runs the callback if successful
|
* Gets the object the command is acting upon, and runs the callback if successful
|
||||||
* @param target the name of the object to be looked up
|
* @param target the name of the object to be looked up
|
||||||
|
@ -76,7 +76,7 @@ public abstract class SubCommand<T> {
|
|||||||
* @param args the stripped arguments given
|
* @param args the stripped arguments given
|
||||||
* @param label the command label used
|
* @param label the command label used
|
||||||
*/
|
*/
|
||||||
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label);
|
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) throws CommandException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of suggestions, which are empty by default. Sub classes that give tab complete suggestions override
|
* Returns a list of suggestions, which are empty by default. Sub classes that give tab complete suggestions override
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic;
|
package me.lucko.luckperms.common.commands.generic;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -48,7 +45,7 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List<String> args, String label) throws CommandException {
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
sendUsageDetailed(sender, user, label);
|
sendUsageDetailed(sender, user, label);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
@ -80,7 +77,51 @@ public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub.execute(plugin, sender, t, strippedArgs);
|
CommandResult result;
|
||||||
|
try {
|
||||||
|
result = sub.execute(plugin, sender, t, strippedArgs);
|
||||||
|
} catch (CommandException e) {
|
||||||
|
result = handleException(e, sender, sub);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CommandResult handleException(CommandException e, Sender sender, SecondarySubCommand command) {
|
||||||
|
if (e instanceof ArgumentUtils.ArgumentException) {
|
||||||
|
if (e instanceof ArgumentUtils.DetailedUsageException) {
|
||||||
|
command.sendDetailedUsage(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.UseInheritException) {
|
||||||
|
Message.USE_INHERIT_COMMAND.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidServerException) {
|
||||||
|
Message.SERVER_INVALID_ENTRY.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.PastDateException) {
|
||||||
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidDateException) {
|
||||||
|
Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate());
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof ArgumentUtils.InvalidPriorityException) {
|
||||||
|
Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority());
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not something we can catch.
|
||||||
|
e.printStackTrace();
|
||||||
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,7 +63,7 @@ public abstract class SecondarySubCommand {
|
|||||||
|
|
||||||
private final ImmutableList<Arg> args;
|
private final ImmutableList<Arg> args;
|
||||||
|
|
||||||
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args);
|
public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException;
|
||||||
|
|
||||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -24,23 +24,22 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddPrefix extends SecondarySubCommand {
|
public class MetaAddPrefix extends SecondarySubCommand {
|
||||||
public MetaAddPrefix() {
|
public MetaAddPrefix() {
|
||||||
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX, Predicates.notInRange(2, 4),
|
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX,
|
||||||
|
Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the prefix at"),
|
Arg.create("priority", true, "the priority to add the prefix at"),
|
||||||
Arg.create("prefix", true, "the prefix string"),
|
Arg.create("prefix", true, "the prefix string"),
|
||||||
@ -51,51 +50,37 @@ public class MetaAddPrefix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String prefix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.setPermission(node, true, server);
|
|
||||||
Message.ADDPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addprefix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.setPermission(node, true, server, world);
|
|
||||||
Message.ADDPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addprefix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, true);
|
holder.setPermission(node, true);
|
||||||
Message.ADDPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
Message.ADDPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta addprefix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.setPermission(node, true, server);
|
||||||
|
Message.ADDPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, true, server, world);
|
||||||
|
Message.ADDPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta addprefix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HAS_PREFIX.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HAS_PREFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -24,23 +24,22 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddSuffix extends SecondarySubCommand {
|
public class MetaAddSuffix extends SecondarySubCommand {
|
||||||
public MetaAddSuffix() {
|
public MetaAddSuffix() {
|
||||||
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX, Predicates.notInRange(2, 4),
|
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX,
|
||||||
|
Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the suffix at"),
|
Arg.create("priority", true, "the priority to add the suffix at"),
|
||||||
Arg.create("suffix", true, "the suffix string"),
|
Arg.create("suffix", true, "the suffix string"),
|
||||||
@ -51,51 +50,37 @@ public class MetaAddSuffix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String suffix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.setPermission(node, true, server);
|
|
||||||
Message.ADDSUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addsuffix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.setPermission(node, true, server, world);
|
|
||||||
Message.ADDSUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addsuffix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, true);
|
holder.setPermission(node, true);
|
||||||
Message.ADDSUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
Message.ADDSUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta addsuffix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.setPermission(node, true, server);
|
||||||
|
Message.ADDSUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, true, server, world);
|
||||||
|
Message.ADDSUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta addsuffix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HAS_SUFFIX.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HAS_SUFFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -24,24 +24,23 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddTempPrefix extends SecondarySubCommand {
|
public class MetaAddTempPrefix extends SecondarySubCommand {
|
||||||
public MetaAddTempPrefix() {
|
public MetaAddTempPrefix() {
|
||||||
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX, Permission.GROUP_META_ADDTEMP_PREFIX, Predicates.notInRange(3, 5),
|
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX,
|
||||||
|
Permission.GROUP_META_ADDTEMP_PREFIX, Predicates.notInRange(3, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the prefix at"),
|
Arg.create("priority", true, "the priority to add the prefix at"),
|
||||||
Arg.create("prefix", true, "the prefix string"),
|
Arg.create("prefix", true, "the prefix string"),
|
||||||
@ -53,68 +52,44 @@ public class MetaAddTempPrefix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String prefix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
} catch (NumberFormatException e) {
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
long duration;
|
|
||||||
try {
|
|
||||||
duration = Long.parseLong(args.get(2));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
|
||||||
} catch (DateUtil.IllegalDateException e1) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 4) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(3).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 4) {
|
|
||||||
holder.setPermission(node, true, server, duration);
|
|
||||||
Message.ADD_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addtempprefix " + priority + " " + args.get(1) + " " + duration + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(4).toLowerCase();
|
|
||||||
holder.setPermission(node, true, server, world, duration);
|
|
||||||
Message.ADD_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addtempprefix " + priority + " " + args.get(1) + " " + duration + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, true, duration);
|
holder.setPermission(node, true, duration);
|
||||||
Message.ADD_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, DateUtil.formatDateDiff(duration));
|
Message.ADD_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority,
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
DateUtil.formatDateDiff(duration)
|
||||||
.action("meta addtempprefix " + priority + " " + args.get(1) + " " + duration)
|
);
|
||||||
.build().submit(plugin, sender);
|
break;
|
||||||
|
case SERVER:
|
||||||
|
holder.setPermission(node, true, server, duration);
|
||||||
|
Message.ADD_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority,
|
||||||
|
server, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, true, server, world, duration);
|
||||||
|
Message.ADD_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority,
|
||||||
|
server, world, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta addtempprefix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HAS_PREFIX.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HAS_PREFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -24,24 +24,23 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaAddTempSuffix extends SecondarySubCommand {
|
public class MetaAddTempSuffix extends SecondarySubCommand {
|
||||||
public MetaAddTempSuffix() {
|
public MetaAddTempSuffix() {
|
||||||
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX, Permission.GROUP_META_ADDTEMP_SUFFIX, Predicates.notInRange(3, 5),
|
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX,
|
||||||
|
Permission.GROUP_META_ADDTEMP_SUFFIX, Predicates.notInRange(3, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the suffix at"),
|
Arg.create("priority", true, "the priority to add the suffix at"),
|
||||||
Arg.create("suffix", true, "the suffix string"),
|
Arg.create("suffix", true, "the suffix string"),
|
||||||
@ -53,68 +52,44 @@ public class MetaAddTempSuffix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String suffix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
} catch (NumberFormatException e) {
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
long duration;
|
|
||||||
try {
|
|
||||||
duration = Long.parseLong(args.get(2));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
|
||||||
} catch (DateUtil.IllegalDateException e1) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 4) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(3).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 4) {
|
|
||||||
holder.setPermission(node, true, server, duration);
|
|
||||||
Message.ADD_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addtempsuffix " + priority + " " + args.get(1) + " " + duration + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(4).toLowerCase();
|
|
||||||
holder.setPermission(node, true, server, world, duration);
|
|
||||||
Message.ADD_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta addtempsuffix " + priority + " " + args.get(1) + " " + duration + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, true, duration);
|
holder.setPermission(node, true, duration);
|
||||||
Message.ADD_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, DateUtil.formatDateDiff(duration));
|
Message.ADD_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority,
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
DateUtil.formatDateDiff(duration)
|
||||||
.action("meta addtempsuffix " + priority + " " + args.get(1) + " " + duration)
|
);
|
||||||
.build().submit(plugin, sender);
|
break;
|
||||||
|
case SERVER:
|
||||||
|
holder.setPermission(node, true, server, duration);
|
||||||
|
Message.ADD_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority,
|
||||||
|
server, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, true, server, world, duration);
|
||||||
|
Message.ADD_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority,
|
||||||
|
server, world, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta addtempsuffix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HAS_SUFFIX.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HAS_SUFFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,15 +23,12 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.meta;
|
package me.lucko.luckperms.common.commands.generic.meta;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,25 +45,22 @@ public class MetaClear extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
int before = holder.getNodes().size();
|
int before = holder.getNodes().size();
|
||||||
|
|
||||||
if (args.size() == 0) {
|
String server = ArgumentUtils.handleServer(0, args);
|
||||||
|
String world = ArgumentUtils.handleWorld(1, args);
|
||||||
|
|
||||||
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
holder.clearMeta();
|
holder.clearMeta();
|
||||||
} else {
|
break;
|
||||||
final String server = args.get(0);
|
case SERVER:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
final String world = args.get(1);
|
|
||||||
holder.clearMeta(server, world);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.clearMeta(server);
|
holder.clearMeta(server);
|
||||||
}
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.clearMeta(server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getNodes().size();
|
int changed = before - holder.getNodes().size();
|
||||||
@ -76,7 +70,10 @@ public class MetaClear extends SecondarySubCommand {
|
|||||||
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), changed);
|
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(holder).action("meta clear " + args.stream().collect(Collectors.joining(" "))).build().submit(plugin, sender);
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta clear " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
import me.lucko.luckperms.common.commands.Util;
|
||||||
@ -42,7 +43,7 @@ public class MetaInfo extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
SortedSet<Map.Entry<Integer, Node>> prefixes = new TreeSet<>(Util.getMetaComparator().reversed());
|
SortedSet<Map.Entry<Integer, Node>> prefixes = new TreeSet<>(Util.getMetaComparator().reversed());
|
||||||
SortedSet<Map.Entry<Integer, Node>> suffixes = new TreeSet<>(Util.getMetaComparator().reversed());
|
SortedSet<Map.Entry<Integer, Node>> suffixes = new TreeSet<>(Util.getMetaComparator().reversed());
|
||||||
Set<Node> meta = new HashSet<>();
|
Set<Node> meta = new HashSet<>();
|
||||||
|
@ -25,24 +25,23 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemovePrefix extends SecondarySubCommand {
|
public class MetaRemovePrefix extends SecondarySubCommand {
|
||||||
public MetaRemovePrefix() {
|
public MetaRemovePrefix() {
|
||||||
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX, Predicates.notInRange(2, 4),
|
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
||||||
|
Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the prefix at"),
|
Arg.create("priority", true, "the priority to add the prefix at"),
|
||||||
Arg.create("prefix", true, "the prefix string"),
|
Arg.create("prefix", true, "the prefix string"),
|
||||||
@ -53,32 +52,14 @@ public class MetaRemovePrefix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String prefix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Handle bulk removal
|
||||||
if (prefix.equalsIgnoreCase("null")) {
|
if (prefix.equalsIgnoreCase("null")) {
|
||||||
String server = null;
|
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Node> toRemove = new ArrayList<>();
|
List<Node> toRemove = new ArrayList<>();
|
||||||
for (Node node : holder.getNodes()) {
|
for (Node node : holder.getNodes()) {
|
||||||
if (!node.isPrefix()) continue;
|
if (!node.isPrefix()) continue;
|
||||||
@ -111,48 +92,36 @@ public class MetaRemovePrefix extends SecondarySubCommand {
|
|||||||
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.unsetPermission(node, server);
|
|
||||||
Message.REMOVEPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removeprefix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world);
|
|
||||||
Message.REMOVEPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removeprefix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node);
|
holder.unsetPermission(node);
|
||||||
Message.REMOVEPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
Message.REMOVEPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta removeprefix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server);
|
||||||
|
Message.REMOVEPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world);
|
||||||
|
Message.REMOVEPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta removeprefix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVE_PREFIX.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVE_PREFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,24 +25,23 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveSuffix extends SecondarySubCommand {
|
public class MetaRemoveSuffix extends SecondarySubCommand {
|
||||||
public MetaRemoveSuffix() {
|
public MetaRemoveSuffix() {
|
||||||
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX, Predicates.notInRange(2, 4),
|
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
||||||
|
Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the suffix at"),
|
Arg.create("priority", true, "the priority to add the suffix at"),
|
||||||
Arg.create("suffix", true, "the suffix string"),
|
Arg.create("suffix", true, "the suffix string"),
|
||||||
@ -53,32 +52,14 @@ public class MetaRemoveSuffix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String suffix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Handle bulk removal
|
||||||
if (suffix.equalsIgnoreCase("null")) {
|
if (suffix.equalsIgnoreCase("null")) {
|
||||||
String server = null;
|
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Node> toRemove = new ArrayList<>();
|
List<Node> toRemove = new ArrayList<>();
|
||||||
for (Node node : holder.getNodes()) {
|
for (Node node : holder.getNodes()) {
|
||||||
if (!node.isSuffix()) continue;
|
if (!node.isSuffix()) continue;
|
||||||
@ -111,48 +92,36 @@ public class MetaRemoveSuffix extends SecondarySubCommand {
|
|||||||
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.unsetPermission(node, server);
|
|
||||||
Message.REMOVESUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removesuffix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world);
|
|
||||||
Message.REMOVESUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removesuffix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node);
|
holder.unsetPermission(node);
|
||||||
Message.REMOVESUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
Message.REMOVESUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta removesuffix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server);
|
||||||
|
Message.REMOVESUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world);
|
||||||
|
Message.REMOVESUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta removesuffix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVE_SUFFIX.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVE_SUFFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,18 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
||||||
public MetaRemoveTempPrefix() {
|
public MetaRemoveTempPrefix() {
|
||||||
@ -53,32 +51,14 @@ public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String prefix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Handle bulk removal
|
||||||
if (prefix.equalsIgnoreCase("null")) {
|
if (prefix.equalsIgnoreCase("null")) {
|
||||||
String server = null;
|
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Node> toRemove = new ArrayList<>();
|
List<Node> toRemove = new ArrayList<>();
|
||||||
for (Node node : holder.getNodes()) {
|
for (Node node : holder.getNodes()) {
|
||||||
if (!node.isPrefix()) continue;
|
if (!node.isPrefix()) continue;
|
||||||
@ -111,48 +91,36 @@ public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
|||||||
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.unsetPermission(node, server, true);
|
|
||||||
Message.REMOVE_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removetempprefix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world, true);
|
|
||||||
Message.REMOVE_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removetempprefix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node, true);
|
holder.unsetPermission(node, true);
|
||||||
Message.REMOVE_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
Message.REMOVE_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta removetempprefix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server, true);
|
||||||
|
Message.REMOVE_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world, true);
|
||||||
|
Message.REMOVE_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta removetempprefix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVE_PREFIX.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVE_PREFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,18 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
||||||
public MetaRemoveTempSuffix() {
|
public MetaRemoveTempSuffix() {
|
||||||
@ -53,32 +51,14 @@ public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
final String suffix = args.get(1).replace("{SPACE}", " ");
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
int priority;
|
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
||||||
try {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
priority = Integer.parseInt(args.get(0));
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Message.META_INVALID_PRIORITY.send(sender, args.get(0));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Handle bulk removal
|
||||||
if (suffix.equalsIgnoreCase("null")) {
|
if (suffix.equalsIgnoreCase("null")) {
|
||||||
String server = null;
|
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Node> toRemove = new ArrayList<>();
|
List<Node> toRemove = new ArrayList<>();
|
||||||
for (Node node : holder.getNodes()) {
|
for (Node node : holder.getNodes()) {
|
||||||
if (!node.isSuffix()) continue;
|
if (!node.isSuffix()) continue;
|
||||||
@ -111,48 +91,36 @@ public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
|||||||
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.unsetPermission(node, server, true);
|
|
||||||
Message.REMOVE_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removetempsuffix " + priority + " " + args.get(1) + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world, true);
|
|
||||||
Message.REMOVE_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("meta removetempsuffix " + priority + " " + args.get(1) + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node, true);
|
holder.unsetPermission(node, true);
|
||||||
Message.REMOVE_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
Message.REMOVE_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta removetempsuffix " + priority + " " + args.get(1))
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server, true);
|
||||||
|
Message.REMOVE_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world, true);
|
||||||
|
Message.REMOVE_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("meta removetempsuffix " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVE_SUFFIX.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVE_SUFFIX.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,18 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaSet extends SecondarySubCommand {
|
public class MetaSet extends SecondarySubCommand {
|
||||||
public MetaSet() {
|
public MetaSet() {
|
||||||
@ -53,25 +51,13 @@ public class MetaSet extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||||
String value = MetaUtils.escapeCharacters(args.get(1));
|
String value = MetaUtils.escapeCharacters(args.get(1));
|
||||||
|
|
||||||
String node = "meta." + key + "." + value;
|
String node = "meta." + key + "." + value;
|
||||||
String server = null;
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = null;
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Node n = new NodeBuilder(node).setServer(server).setWorld(world).build();
|
Node n = new NodeBuilder(node).setServer(server).setWorld(world).build();
|
||||||
|
|
||||||
@ -86,24 +72,21 @@ public class MetaSet extends SecondarySubCommand {
|
|||||||
holder.setPermission(n);
|
holder.setPermission(n);
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
|
||||||
if (server == null) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
Message.SET_META_SUCCESS.send(sender, key, value, holder.getFriendlyName());
|
Message.SET_META_SUCCESS.send(sender, key, value, holder.getFriendlyName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta set " + key + " " + value)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
if (world == null) {
|
|
||||||
Message.SET_META_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server);
|
Message.SET_META_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta set " + key + " " + value + " " + server)
|
case SERVER_AND_WORLD:
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
Message.SET_META_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world);
|
Message.SET_META_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
.action("meta set " + key + " " + value + " " + server + " " + world)
|
.action("meta set " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
@ -25,21 +25,19 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MetaSetTemp extends SecondarySubCommand {
|
public class MetaSetTemp extends SecondarySubCommand {
|
||||||
public MetaSetTemp() {
|
public MetaSetTemp() {
|
||||||
@ -55,42 +53,13 @@ public class MetaSetTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
long duration;
|
|
||||||
try {
|
|
||||||
duration = Long.parseLong(args.get(2));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
|
||||||
} catch (DateUtil.IllegalDateException e1) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||||
String value = MetaUtils.escapeCharacters(args.get(1));
|
String value = MetaUtils.escapeCharacters(args.get(1));
|
||||||
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
String node = "meta." + key + "." + value;
|
String node = "meta." + key + "." + value;
|
||||||
String server = null;
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
String world = null;
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
server = args.get(2).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 3) {
|
|
||||||
world = args.get(3).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Node n = new NodeBuilder(node).setServer(server).setWorld(world).setExpiry(duration).build();
|
Node n = new NodeBuilder(node).setServer(server).setWorld(world).setExpiry(duration).build();
|
||||||
|
|
||||||
@ -105,24 +74,21 @@ public class MetaSetTemp extends SecondarySubCommand {
|
|||||||
holder.setPermission(n);
|
holder.setPermission(n);
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
|
||||||
if (server == null) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
Message.SET_META_TEMP_SUCCESS.send(sender, key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration));
|
Message.SET_META_TEMP_SUCCESS.send(sender, key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration));
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta settemp " + key + " " + value + " " + duration)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
if (world == null) {
|
|
||||||
Message.SET_META_TEMP_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, DateUtil.formatDateDiff(duration));
|
Message.SET_META_TEMP_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, DateUtil.formatDateDiff(duration));
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("meta settemp " + key + " " + value + " " + duration + " " + server)
|
case SERVER_AND_WORLD:
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
Message.SET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world, DateUtil.formatDateDiff(duration));
|
Message.SET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world, DateUtil.formatDateDiff(duration));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
.action("meta settemp " + key + " " + value + " " + duration + " " + server + " " + world)
|
.action("meta settemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
@ -24,15 +24,12 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -40,7 +37,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaUnset extends SecondarySubCommand {
|
public class MetaUnset extends SecondarySubCommand {
|
||||||
public MetaUnset() {
|
public MetaUnset() {
|
||||||
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, Predicates.notInRange(1, 3),
|
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET,
|
||||||
|
Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("key", true, "the key to unset"),
|
Arg.create("key", true, "the key to unset"),
|
||||||
Arg.create("server", false, "the server to remove the meta pair on"),
|
Arg.create("server", false, "the server to remove the meta pair on"),
|
||||||
@ -50,38 +48,27 @@ public class MetaUnset extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String server = null;
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 2) {
|
|
||||||
server = args.get(1).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 2) {
|
|
||||||
world = args.get(2).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.clearMetaKeys(key, server, world, false);
|
holder.clearMetaKeys(key, server, world, false);
|
||||||
|
|
||||||
if (server == null) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName());
|
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName());
|
||||||
} else {
|
break;
|
||||||
if (world == null) {
|
case SERVER:
|
||||||
Message.UNSET_META_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
Message.UNSET_META_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
||||||
} else {
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
Message.UNSET_META_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
Message.UNSET_META_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
.action("meta unset " + args.stream().collect(Collectors.joining(" ")))
|
.action("meta unset " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
|
@ -24,15 +24,12 @@ package me.lucko.luckperms.common.commands.generic.meta;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -40,7 +37,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaUnsetTemp extends SecondarySubCommand {
|
public class MetaUnsetTemp extends SecondarySubCommand {
|
||||||
public MetaUnsetTemp() {
|
public MetaUnsetTemp() {
|
||||||
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, Predicates.notInRange(1, 3),
|
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP,
|
||||||
|
Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("key", true, "the key to unset"),
|
Arg.create("key", true, "the key to unset"),
|
||||||
Arg.create("server", false, "the server to remove the meta pair on"),
|
Arg.create("server", false, "the server to remove the meta pair on"),
|
||||||
@ -50,38 +48,27 @@ public class MetaUnsetTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String server = null;
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
String world = null;
|
|
||||||
|
|
||||||
if (args.size() >= 2) {
|
|
||||||
server = args.get(1).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() != 2) {
|
|
||||||
world = args.get(2).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.clearMetaKeys(key, server, world, true);
|
holder.clearMetaKeys(key, server, world, true);
|
||||||
|
|
||||||
if (server == null) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName());
|
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName());
|
||||||
} else {
|
break;
|
||||||
if (world == null) {
|
case SERVER:
|
||||||
Message.UNSET_META_TEMP_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
Message.UNSET_META_TEMP_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
||||||
} else {
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
Message.UNSET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
Message.UNSET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
.action("meta unsettemp " + args.stream().collect(Collectors.joining(" ")))
|
.action("meta unsettemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.generic.other;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -44,7 +41,7 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List<String> args, String label) throws CommandException {
|
||||||
if (!plugin.getDatastore().loadAllTracks().getUnchecked()) {
|
if (!plugin.getDatastore().loadAllTracks().getUnchecked()) {
|
||||||
Message.TRACKS_LOAD_ERROR.send(sender);
|
Message.TRACKS_LOAD_ERROR.send(sender);
|
||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
|
@ -23,27 +23,25 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentAdd extends SecondarySubCommand {
|
public class ParentAdd extends SecondarySubCommand {
|
||||||
public ParentAdd() {
|
public ParentAdd() {
|
||||||
super("add", "Sets another group for the object to inherit permissions from",
|
super("add", "Sets another group for the object to inherit permissions from", Permission.USER_PARENT_ADD,
|
||||||
Permission.USER_PARENT_ADD, Permission.GROUP_PARENT_ADD, Predicates.notInRange(1, 3),
|
Permission.GROUP_PARENT_ADD, Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("group", true, "the group to inherit from"),
|
Arg.create("group", true, "the group to inherit from"),
|
||||||
Arg.create("server", false, "the server to inherit the group on"),
|
Arg.create("server", false, "the server to inherit the group on"),
|
||||||
@ -53,13 +51,10 @@ public class ParentAdd extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = ArgumentUtils.handleName(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkName(groupName)) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
||||||
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
||||||
@ -73,38 +68,28 @@ public class ParentAdd extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 2) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(1).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
holder.setInheritGroup(group, server);
|
|
||||||
Message.SET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent add " + group.getName() + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
holder.setInheritGroup(group, server, world);
|
|
||||||
Message.SET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent add " + group.getName() + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setInheritGroup(group);
|
holder.setInheritGroup(group);
|
||||||
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("parent add " + group.getName())
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.setInheritGroup(group, server);
|
||||||
|
Message.SET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setInheritGroup(group, server, world);
|
||||||
|
Message.SET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("parent add " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,21 +23,19 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
@ -55,30 +53,11 @@ public class ParentAddTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = ArgumentUtils.handleName(0, args);
|
||||||
|
long duration = ArgumentUtils.handleDuration(1, args);
|
||||||
if (ArgumentChecker.checkName(groupName)) {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
sendDetailedUsage(sender);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
long duration;
|
|
||||||
try {
|
|
||||||
duration = Long.parseLong(args.get(1));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
duration = DateUtil.parseDateDiff(args.get(1), true);
|
|
||||||
} catch (DateUtil.IllegalDateException e1) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
||||||
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
||||||
@ -92,40 +71,34 @@ public class ParentAddTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.setInheritGroup(group, server, duration);
|
|
||||||
Message.SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server,
|
|
||||||
DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent addtemp " + group.getName() + " " + duration + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.setInheritGroup(group, server, world, duration);
|
|
||||||
Message.SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server,
|
|
||||||
world, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent addtemp " + group.getName() + " " + duration + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setInheritGroup(group, duration);
|
holder.setInheritGroup(group, duration);
|
||||||
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), DateUtil.formatDateDiff(duration));
|
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(),
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
DateUtil.formatDateDiff(duration)
|
||||||
.action("parent addtemp " + group.getName() + " " + duration)
|
);
|
||||||
.build().submit(plugin, sender);
|
break;
|
||||||
|
case SERVER:
|
||||||
|
holder.setInheritGroup(group, server, duration);
|
||||||
|
Message.SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(),
|
||||||
|
server, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setInheritGroup(group, server, world, duration);
|
||||||
|
Message.SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(),
|
||||||
|
server, world, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("parent addtemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
import me.lucko.luckperms.common.commands.Util;
|
||||||
@ -41,7 +42,7 @@ public class ParentInfo extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
Message.LISTPARENTS.send(sender, holder.getFriendlyName(), Util.permGroupsToString(holder.getPermissions(false)));
|
Message.LISTPARENTS.send(sender, holder.getFriendlyName(), Util.permGroupsToString(holder.getPermissions(false)));
|
||||||
Message.LISTPARENTS_TEMP.send(sender, holder.getFriendlyName(), Util.tempGroupsToString(holder.getPermissions(false)));
|
Message.LISTPARENTS_TEMP.send(sender, holder.getFriendlyName(), Util.tempGroupsToString(holder.getPermissions(false)));
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
@ -23,27 +23,25 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.users.User;
|
import me.lucko.luckperms.common.users.User;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
public class ParentRemove extends SecondarySubCommand {
|
public class ParentRemove extends SecondarySubCommand {
|
||||||
public ParentRemove() {
|
public ParentRemove() {
|
||||||
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE, Permission.GROUP_PARENT_REMOVE,
|
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE,
|
||||||
Predicates.notInRange(1, 3),
|
Permission.GROUP_PARENT_REMOVE, Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("group", true, "the group to remove"),
|
Arg.create("group", true, "the group to remove"),
|
||||||
Arg.create("server", false, "the server to remove the group on"),
|
Arg.create("server", false, "the server to remove the group on"),
|
||||||
@ -53,56 +51,49 @@ public class ParentRemove extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = ArgumentUtils.handleName(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
if (ArgumentChecker.checkName(groupName)) {
|
ContextHelper.CommandContext context = ContextHelper.determine(server, world);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (holder instanceof User) {
|
if (holder instanceof User) {
|
||||||
User user = (User) holder;
|
User user = (User) holder;
|
||||||
if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global")))
|
|
||||||
&& user.getPrimaryGroup().equalsIgnoreCase(groupName)) {
|
boolean shouldPrevent = (context == ContextHelper.CommandContext.NONE ||
|
||||||
|
(context == ContextHelper.CommandContext.SERVER && server.equalsIgnoreCase("global"))) &&
|
||||||
|
user.getPrimaryGroup().equalsIgnoreCase(groupName);
|
||||||
|
|
||||||
|
if (shouldPrevent) {
|
||||||
Message.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender);
|
Message.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender);
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 2) {
|
switch (context) {
|
||||||
final String server = args.get(1).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
holder.unsetPermission("group." + groupName, server);
|
|
||||||
Message.UNSET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent remove " + groupName + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
holder.unsetPermission("group." + groupName, server, world);
|
|
||||||
Message.UNSET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent remove " + groupName + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission("group." + groupName);
|
holder.unsetPermission("group." + groupName);
|
||||||
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
|
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("parent remove " + groupName)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission("group." + groupName, server);
|
||||||
|
Message.UNSET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission("group." + groupName, server, world);
|
||||||
|
Message.UNSET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("parent remove " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName);
|
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName);
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,19 +23,17 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
@ -52,47 +50,34 @@ public class ParentRemoveTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = ArgumentUtils.handleName(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkName(groupName)) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 2) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(1).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
holder.unsetPermission("group." + groupName, server, true);
|
|
||||||
Message.UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent removetemp " + groupName + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
holder.unsetPermission("group." + groupName, server, world, true);
|
|
||||||
Message.UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent removetemp " + groupName + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission("group." + groupName, true);
|
holder.unsetPermission("group." + groupName, true);
|
||||||
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
|
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("parent removetemp " + groupName)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission("group." + groupName, server, true);
|
||||||
|
Message.UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission("group." + groupName, server, world, true);
|
||||||
|
Message.UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("parent removetemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName);
|
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName);
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.parent;
|
package me.lucko.luckperms.common.commands.generic.parent;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
@ -33,11 +31,11 @@ import me.lucko.luckperms.common.core.PermissionHolder;
|
|||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
import me.lucko.luckperms.common.users.User;
|
import me.lucko.luckperms.common.users.User;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
||||||
|
|
||||||
@ -54,13 +52,10 @@ public class ParentSet extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = ArgumentUtils.handleName(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
if (!plugin.getDatastore().loadGroup(groupName).getUnchecked()) {
|
||||||
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
||||||
@ -73,54 +68,50 @@ public class ParentSet extends SecondarySubCommand {
|
|||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
if (args.size() >= 2) {
|
case NONE:
|
||||||
final String server = args.get(1).toLowerCase();
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
|
|
||||||
holder.clearParents(server, null);
|
|
||||||
holder.setInheritGroup(group, server);
|
|
||||||
|
|
||||||
Message.SET_PARENT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent set " + group.getName() + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
|
|
||||||
holder.clearParents(server, world);
|
|
||||||
holder.setInheritGroup(group, server, world);
|
|
||||||
|
|
||||||
Message.SET_PARENT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("parent set " + group.getName() + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.clearParents(null, null);
|
holder.clearParents(null, null);
|
||||||
|
|
||||||
|
try {
|
||||||
holder.setInheritGroup(group);
|
holder.setInheritGroup(group);
|
||||||
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
|
||||||
if (holder instanceof User) {
|
if (holder instanceof User) {
|
||||||
((User) holder).setPrimaryGroup(group.getName());
|
((User) holder).setPrimaryGroup(group.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("parent set " + group.getName())
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.clearParents(server, null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
holder.setInheritGroup(group, server);
|
||||||
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
|
||||||
|
if (server.equalsIgnoreCase("global") && holder instanceof User) {
|
||||||
|
((User) holder).setPrimaryGroup(group.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message.SET_PARENT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.clearParents(server, world);
|
||||||
|
|
||||||
|
try {
|
||||||
|
holder.setInheritGroup(group, server, world);
|
||||||
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
|
||||||
|
Message.SET_PARENT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("parent set " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
} catch (ObjectAlreadyHasException e) {
|
|
||||||
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName());
|
|
||||||
return CommandResult.STATE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,24 +23,19 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionCheck extends SecondarySubCommand {
|
public class PermissionCheck extends SecondarySubCommand {
|
||||||
public PermissionCheck() {
|
public PermissionCheck() {
|
||||||
super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK, Permission.GROUP_PERM_CHECK,
|
super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK,
|
||||||
Predicates.notInRange(1, 3),
|
Permission.GROUP_PERM_CHECK, Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to check for"),
|
Arg.create("node", true, "the permission node to check for"),
|
||||||
Arg.create("server", false, "the server to check on"),
|
Arg.create("server", false, "the server to check on"),
|
||||||
@ -50,22 +45,23 @@ public class PermissionCheck extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
if (args.size() >= 2) {
|
String node = ArgumentUtils.handleNodeWithoutCheck(0, args);
|
||||||
if (ArgumentChecker.checkServer(args.get(1))) {
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
|
Util.sendTristate(sender, node, holder.hasPermission(new NodeBuilder(node).build()));
|
||||||
|
break;
|
||||||
|
case SERVER:
|
||||||
|
Util.sendTristate(sender, node, holder.hasPermission(new NodeBuilder(node).setServer(server).build()));
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
Util.sendTristate(sender, node, holder.hasPermission(new NodeBuilder(node).setServer(server).setWorld(world).build()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
Util.sendTristate(sender, args.get(0), holder.hasPermission(new NodeBuilder(args.get(0)).setServer(args.get(1)).build()));
|
|
||||||
} else {
|
|
||||||
Util.sendTristate(sender, args.get(0), holder.hasPermission(new NodeBuilder(args.get(0)).setServer(args.get(1)).setWorld(args.get(2)).build()));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Util.sendTristate(sender, args.get(0), holder.hasPermission(new NodeBuilder(args.get(0)).build()));
|
|
||||||
}
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,25 +23,20 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.InheritanceInfo;
|
import me.lucko.luckperms.common.core.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionCheckInherits extends SecondarySubCommand {
|
public class PermissionCheckInherits extends SecondarySubCommand {
|
||||||
public PermissionCheckInherits() {
|
public PermissionCheckInherits() {
|
||||||
super("checkinherits", "Checks to see if the object inherits a certain permission node", Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS,
|
super("checkinherits", "Checks to see if the object inherits a certain permission node",
|
||||||
Predicates.notInRange(1, 3),
|
Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS, Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to check for"),
|
Arg.create("node", true, "the permission node to check for"),
|
||||||
Arg.create("server", false, "the server to check on"),
|
Arg.create("server", false, "the server to check on"),
|
||||||
@ -51,22 +46,22 @@ public class PermissionCheckInherits extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
InheritanceInfo result;
|
String node = ArgumentUtils.handleNodeWithoutCheck(0, args);
|
||||||
if (args.size() >= 2) {
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkServer(args.get(1))) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
InheritanceInfo result = null;
|
||||||
result = holder.inheritsPermissionInfo(new NodeBuilder(args.get(0)).setServer(args.get(1)).build());
|
switch (ContextHelper.determine(server, world)) {
|
||||||
} else {
|
case NONE:
|
||||||
result = holder.inheritsPermissionInfo(new NodeBuilder(args.get(0)).setServer(args.get(1)).setWorld(args.get(2)).build());
|
result = holder.inheritsPermissionInfo(new NodeBuilder(node).build());
|
||||||
}
|
break;
|
||||||
|
case SERVER:
|
||||||
} else {
|
result = holder.inheritsPermissionInfo(new NodeBuilder(node).setServer(server).build());
|
||||||
result = holder.inheritsPermissionInfo(new NodeBuilder(args.get(0)).build());
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
result = holder.inheritsPermissionInfo(new NodeBuilder(node).setServer(server).setWorld(world).build());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String location = null;
|
String location = null;
|
||||||
@ -78,7 +73,7 @@ public class PermissionCheckInherits extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.sendPluginMessage(sender, "&b" + args.get(0) + ": " + Util.formatTristate(result.getResult()) +
|
Util.sendPluginMessage(sender, "&b" + node + ": " + Util.formatTristate(result.getResult()) +
|
||||||
(result.getLocation().isPresent() ? " &7(inherited from &a" + location + "&7)" : ""));
|
(result.getLocation().isPresent() ? " &7(inherited from &a" + location + "&7)" : ""));
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
import me.lucko.luckperms.common.commands.Util;
|
||||||
@ -40,7 +41,7 @@ public class PermissionInfo extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
Message.LISTNODES.send(sender, holder.getFriendlyName(), Util.permNodesToString(holder.getPermissions(false)));
|
Message.LISTNODES.send(sender, holder.getFriendlyName(), Util.permNodesToString(holder.getPermissions(false)));
|
||||||
Message.LISTNODES_TEMP.send(sender, holder.getFriendlyName(), Util.tempNodesToString(holder.getPermissions(false)));
|
Message.LISTNODES_TEMP.send(sender, holder.getFriendlyName(), Util.tempNodesToString(holder.getPermissions(false)));
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
@ -23,25 +23,24 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||||
|
|
||||||
public class PermissionSet extends SecondarySubCommand {
|
public class PermissionSet extends SecondarySubCommand {
|
||||||
public PermissionSet() {
|
public PermissionSet() {
|
||||||
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, Predicates.notInRange(2, 4),
|
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
||||||
|
Predicates.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to set"),
|
Arg.create("node", true, "the permission node to set"),
|
||||||
Arg.create("true|false", true, "the value of the node"),
|
Arg.create("true|false", true, "the value of the node"),
|
||||||
@ -52,60 +51,36 @@ public class PermissionSet extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String node = args.get(0).replace("{SPACE}", " ");
|
String node = ArgumentUtils.handleNode(0, args);
|
||||||
String bool = args.get(1).toLowerCase();
|
boolean b = ArgumentUtils.handleBoolean(1, args);
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(node)) {
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
sendDetailedUsage(sender);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.toLowerCase().startsWith("group.")) {
|
|
||||||
Message.USE_INHERIT_COMMAND.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
|
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean b = Boolean.parseBoolean(bool);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 3) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(2).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
holder.setPermission(node, b, server);
|
|
||||||
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, holder.getFriendlyName(), server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission set " + node + " " + b + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(3).toLowerCase();
|
|
||||||
holder.setPermission(node, b, server, world);
|
|
||||||
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, holder.getFriendlyName(), server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission set " + node + " " + b + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, b);
|
holder.setPermission(node, b);
|
||||||
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, holder.getFriendlyName());
|
Message.SETPERMISSION_SUCCESS.send(sender, node, b, holder.getFriendlyName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("permission set " + node + " " + b)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.setPermission(node, b, server);
|
||||||
|
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, b, server, world);
|
||||||
|
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("permission set " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,27 +23,25 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete;
|
||||||
|
|
||||||
public class PermissionSetTemp extends SecondarySubCommand {
|
public class PermissionSetTemp extends SecondarySubCommand {
|
||||||
public PermissionSetTemp() {
|
public PermissionSetTemp() {
|
||||||
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP, Permission.GROUP_PERM_SETTEMP,
|
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
||||||
Predicates.notInRange(3, 5),
|
Permission.GROUP_PERM_SETTEMP, Predicates.notInRange(3, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to set"),
|
Arg.create("node", true, "the permission node to set"),
|
||||||
Arg.create("true|false", true, "the value of the node"),
|
Arg.create("true|false", true, "the value of the node"),
|
||||||
@ -55,79 +53,44 @@ public class PermissionSetTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String node = args.get(0).replace("{SPACE}", " ");
|
String node = ArgumentUtils.handleNode(0, args);
|
||||||
String bool = args.get(1).toLowerCase();
|
boolean b = ArgumentUtils.handleBoolean(1, args);
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(node)) {
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.toLowerCase().startsWith("group.")) {
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
Message.USE_INHERIT_COMMAND.send(sender);
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
|
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean b = Boolean.parseBoolean(bool);
|
|
||||||
|
|
||||||
long duration;
|
|
||||||
try {
|
|
||||||
duration = Long.parseLong(args.get(2));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
|
||||||
} catch (DateUtil.IllegalDateException e1) {
|
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 4) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(3).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 4) {
|
|
||||||
holder.setPermission(node, b, server, duration);
|
|
||||||
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, holder.getFriendlyName(), server,
|
|
||||||
DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission settemp " + node + " " + b + " " + duration + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(4).toLowerCase();
|
|
||||||
holder.setPermission(node, b, server, world, duration);
|
|
||||||
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, holder.getFriendlyName(), server,
|
|
||||||
world, DateUtil.formatDateDiff(duration));
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission settemp " + node + " " + b + " " + duration + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.setPermission(node, b, duration);
|
holder.setPermission(node, b, duration);
|
||||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, holder.getFriendlyName(), DateUtil.formatDateDiff(duration));
|
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, b, holder.getFriendlyName(),
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
DateUtil.formatDateDiff(duration)
|
||||||
.action("permission settemp " + node + " " + b + " " + duration)
|
);
|
||||||
.build().submit(plugin, sender);
|
break;
|
||||||
|
case SERVER:
|
||||||
|
holder.setPermission(node, b, server, duration);
|
||||||
|
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server,
|
||||||
|
DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.setPermission(node, b, server, world, duration);
|
||||||
|
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, b, holder.getFriendlyName(),
|
||||||
|
server, world, DateUtil.formatDateDiff(duration)
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("permission settemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectAlreadyHasException e) {
|
} catch (ObjectAlreadyHasException e) {
|
||||||
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName());
|
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,23 +23,22 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PermissionUnset extends SecondarySubCommand {
|
public class PermissionUnset extends SecondarySubCommand {
|
||||||
public PermissionUnset() {
|
public PermissionUnset() {
|
||||||
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, Predicates.notInRange(1, 3),
|
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET,
|
||||||
|
Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to unset"),
|
Arg.create("node", true, "the permission node to unset"),
|
||||||
Arg.create("server", false, "the server to remove the permission node on"),
|
Arg.create("server", false, "the server to remove the permission node on"),
|
||||||
@ -49,52 +48,34 @@ public class PermissionUnset extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String node = args.get(0).replace("{SPACE}", " ");
|
String node = ArgumentUtils.handleNode(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkNode(node)) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.toLowerCase().startsWith("group.")) {
|
|
||||||
Message.USE_UNINHERIT_COMMAND.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 2) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(1).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
holder.unsetPermission(node, server);
|
|
||||||
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission unset " + node + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world);
|
|
||||||
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission unset " + node + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node);
|
holder.unsetPermission(node);
|
||||||
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
|
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("permission unset " + node)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server);
|
||||||
|
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world);
|
||||||
|
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("permission unset " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVEPERMISSION.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVEPERMISSION.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -23,24 +23,22 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.permission;
|
package me.lucko.luckperms.common.commands.generic.permission;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
import me.lucko.luckperms.common.commands.generic.SecondarySubCommand;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PermissionUnsetTemp extends SecondarySubCommand {
|
public class PermissionUnsetTemp extends SecondarySubCommand {
|
||||||
public PermissionUnsetTemp() {
|
public PermissionUnsetTemp() {
|
||||||
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP, Permission.GROUP_PERM_UNSETTEMP,
|
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP,
|
||||||
Predicates.notInRange(1, 3),
|
Permission.GROUP_PERM_UNSETTEMP, Predicates.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to unset"),
|
Arg.create("node", true, "the permission node to unset"),
|
||||||
Arg.create("server", false, "the server to remove the permission node on"),
|
Arg.create("server", false, "the server to remove the permission node on"),
|
||||||
@ -50,52 +48,34 @@ public class PermissionUnsetTemp extends SecondarySubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) throws CommandException {
|
||||||
String node = args.get(0).replace("{SPACE}", " ");
|
String node = ArgumentUtils.handleNode(0, args);
|
||||||
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
if (ArgumentChecker.checkNode(node)) {
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
sendDetailedUsage(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.toLowerCase().startsWith("group.")) {
|
|
||||||
Message.USE_UNINHERIT_COMMAND.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.size() >= 2) {
|
switch (ContextHelper.determine(server, world)) {
|
||||||
final String server = args.get(1).toLowerCase();
|
case NONE:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
holder.unsetPermission(node, server);
|
|
||||||
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission unsettemp " + node + " " + server)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
} else {
|
|
||||||
final String world = args.get(2).toLowerCase();
|
|
||||||
holder.unsetPermission(node, server, world);
|
|
||||||
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
|
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
|
||||||
.action("permission unsettemp " + node + " " + server + " " + world)
|
|
||||||
.build().submit(plugin, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
holder.unsetPermission(node, true);
|
holder.unsetPermission(node, true);
|
||||||
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
|
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
|
||||||
LogEntry.build().actor(sender).acted(holder)
|
break;
|
||||||
.action("permission unsettemp " + node)
|
case SERVER:
|
||||||
.build().submit(plugin, sender);
|
holder.unsetPermission(node, server, true);
|
||||||
|
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
|
||||||
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
holder.unsetPermission(node, server, world, true);
|
||||||
|
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogEntry.build().actor(sender).acted(holder)
|
||||||
|
.action("permission unsettemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(holder, sender, plugin);
|
save(holder, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
} catch (ObjectLacksException e) {
|
} catch (ObjectLacksException e) {
|
||||||
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName());
|
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName());
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.group.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -53,7 +50,7 @@ public class GroupBulkChange extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
||||||
String type = args.get(0).toLowerCase();
|
String type = args.get(0).toLowerCase();
|
||||||
String from = args.get(1);
|
String from = args.get(1);
|
||||||
String to = args.get(2);
|
String to = args.get(2);
|
||||||
|
@ -23,15 +23,11 @@
|
|||||||
package me.lucko.luckperms.common.commands.group.subcommands;
|
package me.lucko.luckperms.common.commands.group.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.groups.Group;
|
import me.lucko.luckperms.common.groups.Group;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,25 +44,22 @@ public class GroupClear extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
||||||
int before = group.getNodes().size();
|
int before = group.getNodes().size();
|
||||||
|
|
||||||
if (args.size() == 0) {
|
String server = ArgumentUtils.handleServer(0, args);
|
||||||
|
String world = ArgumentUtils.handleWorld(1, args);
|
||||||
|
|
||||||
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
group.clearNodes();
|
group.clearNodes();
|
||||||
} else {
|
break;
|
||||||
final String server = args.get(0);
|
case SERVER:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
final String world = args.get(1);
|
|
||||||
group.clearNodes(server, world);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
group.clearNodes(server);
|
group.clearNodes(server);
|
||||||
}
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
group.clearNodes(server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - group.getNodes().size();
|
int changed = before - group.getNodes().size();
|
||||||
@ -76,7 +69,10 @@ public class GroupClear extends SubCommand<Group> {
|
|||||||
Message.CLEAR_SUCCESS.send(sender, group.getName(), changed);
|
Message.CLEAR_SUCCESS.send(sender, group.getName(), changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(group).action("clear " + args.stream().collect(Collectors.joining(" "))).build().submit(plugin, sender);
|
LogEntry.build().actor(sender).acted(group)
|
||||||
|
.action("clear " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(group, sender, plugin);
|
save(group, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.group.subcommands;
|
package me.lucko.luckperms.common.commands.group.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -44,7 +41,7 @@ public class GroupClone extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
||||||
String newGroupName = args.get(0).toLowerCase();
|
String newGroupName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(newGroupName)) {
|
if (ArgumentChecker.checkName(newGroupName)) {
|
||||||
Message.GROUP_INVALID_ENTRY.send(sender);
|
Message.GROUP_INVALID_ENTRY.send(sender);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.group.subcommands;
|
package me.lucko.luckperms.common.commands.group.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -39,7 +40,7 @@ public class GroupInfo extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
||||||
Message.GROUP_INFO.send(sender,
|
Message.GROUP_INFO.send(sender,
|
||||||
group.getDisplayName(),
|
group.getDisplayName(),
|
||||||
group.getPermanentNodes().size(),
|
group.getPermanentNodes().size(),
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.group.subcommands;
|
package me.lucko.luckperms.common.commands.group.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -44,7 +41,7 @@ public class GroupRename extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
||||||
String newGroupName = args.get(0).toLowerCase();
|
String newGroupName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(newGroupName)) {
|
if (ArgumentChecker.checkName(newGroupName)) {
|
||||||
Message.GROUP_INVALID_ENTRY.send(sender);
|
Message.GROUP_INVALID_ENTRY.send(sender);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.log.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -48,7 +45,7 @@ public class LogExport extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
File f = new File(plugin.getMainDir(), args.get(0));
|
File f = new File(plugin.getMainDir(), args.get(0));
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
Message.LOG_EXPORT_ALREADY_EXISTS.send(sender, f.getAbsolutePath());
|
Message.LOG_EXPORT_ALREADY_EXISTS.send(sender, f.getAbsolutePath());
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.log.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -50,7 +47,7 @@ public class LogGroupHistory extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
String group = args.get(0).toLowerCase();
|
String group = args.get(0).toLowerCase();
|
||||||
int page = -999;
|
int page = -999;
|
||||||
|
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.log.subcommands;
|
package me.lucko.luckperms.common.commands.log.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -44,7 +41,7 @@ public class LogNotify extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
final Set<UUID> ignoring = plugin.getIgnoringLogs();
|
final Set<UUID> ignoring = plugin.getIgnoringLogs();
|
||||||
final UUID uuid = sender.getUuid();
|
final UUID uuid = sender.getUuid();
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
|
@ -48,7 +48,7 @@ public class LogRecent extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
// No page or user
|
// No page or user
|
||||||
return showLog(log.getRecentMaxPages(), null, sender, log);
|
return showLog(log.getRecentMaxPages(), null, sender, log);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.log.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -50,7 +47,7 @@ public class LogSearch extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
int page = -999;
|
int page = -999;
|
||||||
if (args.size() > 1) {
|
if (args.size() > 1) {
|
||||||
try {
|
try {
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.log.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.Log;
|
import me.lucko.luckperms.common.data.Log;
|
||||||
@ -50,7 +47,7 @@ public class LogTrackHistory extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
String track = args.get(0).toLowerCase();
|
String track = args.get(0).toLowerCase();
|
||||||
int page = -999;
|
int page = -999;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class LogUserHistory extends SubCommand<Log> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) throws CommandException {
|
||||||
String user = args.get(0);
|
String user = args.get(0);
|
||||||
int page = -999;
|
int page = -999;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class TrackAppend extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.track.subcommands;
|
package me.lucko.luckperms.common.commands.track.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -40,7 +41,7 @@ public class TrackClear extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
track.clearGroups();
|
track.clearGroups();
|
||||||
Message.TRACK_CLEAR.send(sender, track.getName());
|
Message.TRACK_CLEAR.send(sender, track.getName());
|
||||||
LogEntry.build().actor(sender).acted(track).action("clear").build().submit(plugin, sender);
|
LogEntry.build().actor(sender).acted(track).action("clear").build().submit(plugin, sender);
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.track.subcommands;
|
package me.lucko.luckperms.common.commands.track.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -44,7 +41,7 @@ public class TrackClone extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
String newTrackName = args.get(0).toLowerCase();
|
String newTrackName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(newTrackName)) {
|
if (ArgumentChecker.checkName(newTrackName)) {
|
||||||
Message.TRACK_INVALID_ENTRY.send(sender);
|
Message.TRACK_INVALID_ENTRY.send(sender);
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.track.subcommands;
|
package me.lucko.luckperms.common.commands.track.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
@ -40,7 +37,7 @@ public class TrackInfo extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
Message.TRACK_INFO.send(sender, track.getName(), Util.listToArrowSep(track.getGroups()));
|
Message.TRACK_INFO.send(sender, track.getName(), Util.listToArrowSep(track.getGroups()));
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class TrackInsert extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
|
@ -42,7 +42,7 @@ public class TrackRemove extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (ArgumentChecker.checkNode(groupName)) {
|
if (ArgumentChecker.checkNode(groupName)) {
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.track.subcommands;
|
package me.lucko.luckperms.common.commands.track.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -44,7 +41,7 @@ public class TrackRename extends SubCommand<Track> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
|
||||||
String newTrackName = args.get(0).toLowerCase();
|
String newTrackName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(newTrackName)) {
|
if (ArgumentChecker.checkName(newTrackName)) {
|
||||||
Message.TRACK_INVALID_ENTRY.send(sender);
|
Message.TRACK_INVALID_ENTRY.send(sender);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.user.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -53,7 +50,7 @@ public class UserBulkChange extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
String type = args.get(0).toLowerCase();
|
String type = args.get(0).toLowerCase();
|
||||||
String from = args.get(1);
|
String from = args.get(1);
|
||||||
String to = args.get(2);
|
String to = args.get(2);
|
||||||
|
@ -23,15 +23,11 @@
|
|||||||
package me.lucko.luckperms.common.commands.user.subcommands;
|
package me.lucko.luckperms.common.commands.user.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.users.User;
|
import me.lucko.luckperms.common.users.User;
|
||||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,25 +44,22 @@ public class UserClear extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
int before = user.getNodes().size();
|
int before = user.getNodes().size();
|
||||||
|
|
||||||
if (args.size() == 0) {
|
String server = ArgumentUtils.handleServer(0, args);
|
||||||
|
String world = ArgumentUtils.handleWorld(1, args);
|
||||||
|
|
||||||
|
switch (ContextHelper.determine(server, world)) {
|
||||||
|
case NONE:
|
||||||
user.clearNodes();
|
user.clearNodes();
|
||||||
} else {
|
break;
|
||||||
final String server = args.get(0);
|
case SERVER:
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size() == 2) {
|
|
||||||
final String world = args.get(1);
|
|
||||||
user.clearNodes(server, world);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
user.clearNodes(server);
|
user.clearNodes(server);
|
||||||
}
|
break;
|
||||||
|
case SERVER_AND_WORLD:
|
||||||
|
user.clearNodes(server, world);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - user.getNodes().size();
|
int changed = before - user.getNodes().size();
|
||||||
@ -76,7 +69,10 @@ public class UserClear extends SubCommand<User> {
|
|||||||
Message.CLEAR_SUCCESS.send(sender, user.getName(), changed);
|
Message.CLEAR_SUCCESS.send(sender, user.getName(), changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntry.build().actor(sender).acted(user).action("clear " + args.stream().collect(Collectors.joining(" "))).build().submit(plugin, sender);
|
LogEntry.build().actor(sender).acted(user)
|
||||||
|
.action("clear " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||||
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
final String trackName = args.get(0).toLowerCase();
|
final String trackName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(trackName)) {
|
if (ArgumentChecker.checkName(trackName)) {
|
||||||
Message.TRACK_INVALID_ENTRY.send(sender);
|
Message.TRACK_INVALID_ENTRY.send(sender);
|
||||||
@ -82,19 +82,8 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String server = null;
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = null;
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
if (args.size() > 1) {
|
|
||||||
server = args.get(1);
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
if (args.size() > 2) {
|
|
||||||
world = args.get(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load applicable groups
|
// Load applicable groups
|
||||||
Set<Node> nodes = new HashSet<>();
|
Set<Node> nodes = new HashSet<>();
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.user.subcommands;
|
package me.lucko.luckperms.common.commands.user.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -39,7 +40,7 @@ public class UserGetUUID extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
Message.USER_GETUUID.send(sender, user.getName(), user.getUuid().toString());
|
Message.USER_GETUUID.send(sender, user.getName(), user.getUuid().toString());
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.user.subcommands;
|
package me.lucko.luckperms.common.commands.user.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
@ -39,7 +40,7 @@ public class UserInfo extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
Message.USER_INFO.send(sender,
|
Message.USER_INFO.send(sender,
|
||||||
user.getName(),
|
user.getName(),
|
||||||
user.getUuid(),
|
user.getUuid(),
|
||||||
|
@ -59,7 +59,7 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
final String trackName = args.get(0).toLowerCase();
|
final String trackName = args.get(0).toLowerCase();
|
||||||
if (ArgumentChecker.checkName(trackName)) {
|
if (ArgumentChecker.checkName(trackName)) {
|
||||||
Message.TRACK_INVALID_ENTRY.send(sender);
|
Message.TRACK_INVALID_ENTRY.send(sender);
|
||||||
@ -82,19 +82,8 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String server = null;
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = null;
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
if (args.size() > 1) {
|
|
||||||
server = args.get(1);
|
|
||||||
if (ArgumentChecker.checkServer(server)) {
|
|
||||||
Message.SERVER_INVALID_ENTRY.send(sender);
|
|
||||||
return CommandResult.INVALID_ARGS;
|
|
||||||
}
|
|
||||||
if (args.size() > 2) {
|
|
||||||
world = args.get(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load applicable groups
|
// Load applicable groups
|
||||||
Set<Node> nodes = new HashSet<>();
|
Set<Node> nodes = new HashSet<>();
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.user.subcommands;
|
package me.lucko.luckperms.common.commands.user.subcommands;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -45,7 +42,7 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) throws CommandException {
|
||||||
Group group = plugin.getGroupManager().get(args.get(0).toLowerCase());
|
Group group = plugin.getGroupManager().get(args.get(0).toLowerCase());
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
Message.GROUP_DOES_NOT_EXIST.send(sender);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.usersbulkedit.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -52,7 +49,7 @@ public class BulkEditGroup extends SubCommand<Datastore> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Datastore datastore, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Datastore datastore, List<String> args, String label) throws CommandException {
|
||||||
String group = args.get(0);
|
String group = args.get(0);
|
||||||
String type = args.get(1).toLowerCase();
|
String type = args.get(1).toLowerCase();
|
||||||
String from = args.get(2);
|
String from = args.get(2);
|
||||||
|
@ -24,10 +24,7 @@ package me.lucko.luckperms.common.commands.usersbulkedit.subcommands;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -52,7 +49,7 @@ public class BulkEditPermission extends SubCommand<Datastore> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Datastore datastore, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Datastore datastore, List<String> args, String label) throws CommandException {
|
||||||
String node = args.get(0);
|
String node = args.get(0);
|
||||||
String type = args.get(1).toLowerCase();
|
String type = args.get(1).toLowerCase();
|
||||||
String from = args.get(2);
|
String from = args.get(2);
|
||||||
|
@ -77,8 +77,7 @@ public enum Message {
|
|||||||
GROUP_INVALID_ENTRY("Group names can only contain alphanumeric characters.", true),
|
GROUP_INVALID_ENTRY("Group names can only contain alphanumeric characters.", true),
|
||||||
TRACK_INVALID_ENTRY("Track names can only contain alphanumeric characters.", true),
|
TRACK_INVALID_ENTRY("Track names can only contain alphanumeric characters.", true),
|
||||||
SERVER_INVALID_ENTRY("Server names can only contain alphanumeric characters.", true),
|
SERVER_INVALID_ENTRY("Server names can only contain alphanumeric characters.", true),
|
||||||
USE_INHERIT_COMMAND("Use the 'parent add' command instead of specifying the node.", true),
|
USE_INHERIT_COMMAND("Use the 'parent add' and 'parent remove' commands instead of specifying the node.", true),
|
||||||
USE_UNINHERIT_COMMAND("Use the 'parent remove' command instead of specifying the node.", true),
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,7 +41,6 @@ track-invalid-entry: "Track names can only contain alphanumeric characters."
|
|||||||
server-invalid-entry: "Server names can only contain alphanumeric characters."
|
server-invalid-entry: "Server names can only contain alphanumeric characters."
|
||||||
|
|
||||||
use-inherit-command: "Use the 'parent add' command instead of specifying the node."
|
use-inherit-command: "Use the 'parent add' command instead of specifying the node."
|
||||||
use-uninherit-command: "Use the 'parent remove' command instead of specifying the node."
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,10 +26,7 @@ import me.lucko.luckperms.api.Logger;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.*;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
|
||||||
import me.lucko.luckperms.common.commands.Util;
|
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||||
@ -52,7 +49,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
final Logger log = plugin.getLog();
|
||||||
|
|
||||||
Optional<PluginContainer> pex = Sponge.getPluginManager().getPlugin("permissionsex");
|
Optional<PluginContainer> pex = Sponge.getPluginManager().getPlugin("permissionsex");
|
||||||
|
Loading…
Reference in New Issue
Block a user