Implement meta / Sponge option commands & fix meta caching system. Fully resolves #23
This commit is contained in:
parent
73f10cad66
commit
e4810302e1
@ -36,7 +36,6 @@ import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||
import me.lucko.luckperms.common.core.UuidCache;
|
||||
|
@ -29,7 +29,6 @@ import me.lucko.luckperms.common.caching.MetaData;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
import me.lucko.luckperms.common.groups.Group;
|
||||
import me.lucko.luckperms.common.users.User;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
@ -39,8 +38,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.utils.ArgumentChecker.escapeCharacters;
|
||||
import static me.lucko.luckperms.common.utils.ArgumentChecker.unescapeCharacters;
|
||||
import static me.lucko.luckperms.api.MetaUtils.escapeCharacters;
|
||||
import static me.lucko.luckperms.api.MetaUtils.unescapeCharacters;
|
||||
|
||||
/**
|
||||
* Provides the Vault Chat service through the use of normal permission nodes.
|
||||
@ -56,7 +55,7 @@ import static me.lucko.luckperms.common.utils.ArgumentChecker.unescapeCharacters
|
||||
* Permission Nodes = meta.node.value
|
||||
*
|
||||
* Node that special characters used within LuckPerms are escaped:
|
||||
* See {@link ArgumentChecker#escapeCharacters(String)}
|
||||
* See {@link me.lucko.luckperms.api.MetaUtils#unescapeCharacters(String)}
|
||||
*/
|
||||
public class VaultChatHook extends Chat {
|
||||
private final VaultPermissionHook perms;
|
||||
|
@ -34,7 +34,6 @@ import me.lucko.luckperms.common.commands.CommandManager;
|
||||
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||
|
@ -62,7 +62,7 @@ public class MetaData {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!n.isMeta() || !n.isPrefix() || n.isSuffix()) {
|
||||
if (!n.isMeta() && !n.isPrefix() && n.isSuffix()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
import me.lucko.luckperms.common.groups.Group;
|
||||
|
@ -30,16 +30,20 @@ import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
public class CommandMeta<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public CommandMeta(boolean user) {
|
||||
super("Meta", "Edit metadata values", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
.add(new MetaInfo())
|
||||
.add(new MetaAddPrefix())
|
||||
.add(new MetaAddSuffix())
|
||||
.add(new MetaRemovePrefix())
|
||||
.add(new MetaRemoveSuffix())
|
||||
.add(new MetaAddTempPrefix())
|
||||
.add(new MetaAddTempSuffix())
|
||||
.add(new MetaRemoveTempPrefix())
|
||||
.add(new MetaRemoveTempSuffix())
|
||||
.add(new MetaClear())
|
||||
.build());
|
||||
.add(new MetaInfo())
|
||||
.add(new MetaSet())
|
||||
.add(new MetaUnset())
|
||||
.add(new MetaSetTemp())
|
||||
.add(new MetaUnsetTemp())
|
||||
.add(new MetaAddPrefix())
|
||||
.add(new MetaAddSuffix())
|
||||
.add(new MetaRemovePrefix())
|
||||
.add(new MetaRemoveSuffix())
|
||||
.add(new MetaAddTempPrefix())
|
||||
.add(new MetaAddTempSuffix())
|
||||
.add(new MetaRemoveTempPrefix())
|
||||
.add(new MetaRemoveTempSuffix())
|
||||
.add(new MetaClear())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
@ -60,7 +61,7 @@ public class MetaAddPrefix extends SecondarySubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final String node = "prefix." + priority + "." + ArgumentChecker.escapeCharacters(prefix);
|
||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
@ -60,7 +61,7 @@ public class MetaAddSuffix extends SecondarySubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final String node = "suffix." + priority + "." + ArgumentChecker.escapeCharacters(suffix);
|
||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
@ -79,7 +80,7 @@ public class MetaAddTempPrefix extends SecondarySubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final String node = "prefix." + priority + "." + ArgumentChecker.escapeCharacters(prefix);
|
||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 4) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
@ -79,7 +80,7 @@ public class MetaAddTempSuffix extends SecondarySubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
final String node = "suffix." + priority + "." + ArgumentChecker.escapeCharacters(suffix);
|
||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 4) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
@ -113,7 +114,7 @@ public class MetaRemovePrefix extends SecondarySubCommand {
|
||||
|
||||
} else {
|
||||
|
||||
final String node = "prefix." + priority + "." + ArgumentChecker.escapeCharacters(prefix);
|
||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
@ -113,7 +114,7 @@ public class MetaRemoveSuffix extends SecondarySubCommand {
|
||||
|
||||
} else {
|
||||
|
||||
final String node = "suffix." + priority + "." + ArgumentChecker.escapeCharacters(suffix);
|
||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
@ -113,7 +114,7 @@ public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
||||
|
||||
} else {
|
||||
|
||||
final String node = "prefix." + priority + "." + ArgumentChecker.escapeCharacters(prefix);
|
||||
final String node = "prefix." + priority + "." + MetaUtils.escapeCharacters(prefix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.commands.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
@ -113,7 +114,7 @@ public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
||||
|
||||
} else {
|
||||
|
||||
final String node = "suffix." + priority + "." + ArgumentChecker.escapeCharacters(suffix);
|
||||
final String node = "suffix." + priority + "." + MetaUtils.escapeCharacters(suffix);
|
||||
|
||||
try {
|
||||
if (args.size() >= 3) {
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
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.core.Node;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetaSet extends SecondarySubCommand {
|
||||
public MetaSet() {
|
||||
super("set", "Sets a meta value", Permission.USER_SET_META, Permission.GROUP_SET_META, Predicate.notInRange(2, 4),
|
||||
Arg.list(
|
||||
Arg.create("key", true, "the key to set"),
|
||||
Arg.create("value", true, "the value to set"),
|
||||
Arg.create("server", false, "the server to add the meta pair on"),
|
||||
Arg.create("world", false, "the world to add the meta pair on")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||
String value = MetaUtils.escapeCharacters(args.get(1));
|
||||
|
||||
String node = "meta." + key + "." + value;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
me.lucko.luckperms.api.Node n = new Node.Builder(node).setServer(server).setWorld(world).build();
|
||||
|
||||
if (holder.hasPermission(n).asBoolean()) {
|
||||
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName());
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
holder.clearMetaKeys(key, server, world, false);
|
||||
|
||||
try {
|
||||
holder.setPermission(n);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
|
||||
if (server == null) {
|
||||
Message.SET_META_SUCCESS.send(sender, key, value, holder.getFriendlyName());
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta set " + key + " " + value)
|
||||
.build().submit(plugin, sender);
|
||||
} else {
|
||||
if (world == null) {
|
||||
Message.SET_META_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server);
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta set " + key + " " + value + " " + server)
|
||||
.build().submit(plugin, sender);
|
||||
} else {
|
||||
Message.SET_META_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world);
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta set " + key + " " + value + " " + server + " " + world)
|
||||
.build().submit(plugin, sender);
|
||||
}
|
||||
}
|
||||
|
||||
save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
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.core.Node;
|
||||
import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
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.exceptions.ObjectAlreadyHasException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetaSetTemp extends SecondarySubCommand {
|
||||
public MetaSetTemp() {
|
||||
super("settemp", "Sets a meta value temporarily", Permission.USER_SET_TEMP_META, Permission.GROUP_SET_TEMP_META, Predicate.notInRange(3, 5),
|
||||
Arg.list(
|
||||
Arg.create("key", true, "the key to set"),
|
||||
Arg.create("value", true, "the value to set"),
|
||||
Arg.create("duration", true, "the duration until the meta value expires"),
|
||||
Arg.create("server", false, "the server to add the meta pair on"),
|
||||
Arg.create("world", false, "the world to add the meta pair on")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> 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;
|
||||
}
|
||||
|
||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||
String value = MetaUtils.escapeCharacters(args.get(1));
|
||||
|
||||
String node = "meta." + key + "." + value;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
me.lucko.luckperms.api.Node n = new Node.Builder(node).setServer(server).setWorld(world).setExpiry(duration).build();
|
||||
|
||||
if (holder.hasPermission(n).asBoolean()) {
|
||||
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName());
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
holder.clearMetaKeys(key, server, world, true);
|
||||
|
||||
try {
|
||||
holder.setPermission(n);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
|
||||
if (server == null) {
|
||||
Message.SET_META_TEMP_SUCCESS.send(sender, key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration));
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta settemp " + key + " " + value + " " + duration)
|
||||
.build().submit(plugin, sender);
|
||||
} else {
|
||||
if (world == null) {
|
||||
Message.SET_META_TEMP_SERVER_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, DateUtil.formatDateDiff(duration));
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta settemp " + key + " " + value + " " + duration + " " + server)
|
||||
.build().submit(plugin, sender);
|
||||
} else {
|
||||
Message.SET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, value, holder.getFriendlyName(), server, world, DateUtil.formatDateDiff(duration));
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta settemp " + key + " " + value + " " + duration + " " + server + " " + world)
|
||||
.build().submit(plugin, sender);
|
||||
}
|
||||
}
|
||||
|
||||
save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
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.core.PermissionHolder;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaUnset extends SecondarySubCommand {
|
||||
public MetaUnset() {
|
||||
super("unset", "Unsets a meta value", Permission.USER_UNSET_META, Permission.GROUP_UNSET_META, Predicate.notInRange(1, 3),
|
||||
Arg.list(
|
||||
Arg.create("key", true, "the key to unset"),
|
||||
Arg.create("server", false, "the server to remove the meta pair on"),
|
||||
Arg.create("world", false, "the world to remove the meta pair on")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||
|
||||
String server = null;
|
||||
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);
|
||||
|
||||
if (server == null) {
|
||||
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName());
|
||||
} else {
|
||||
if (world == null) {
|
||||
Message.UNSET_META_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
||||
} else {
|
||||
Message.UNSET_META_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
||||
}
|
||||
}
|
||||
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta unset " + args.stream().collect(Collectors.joining(" ")))
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.generic.meta;
|
||||
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.Arg;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
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.core.PermissionHolder;
|
||||
import me.lucko.luckperms.common.data.LogEntry;
|
||||
import me.lucko.luckperms.common.utils.ArgumentChecker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaUnsetTemp extends SecondarySubCommand {
|
||||
public MetaUnsetTemp() {
|
||||
super("unset", "Unsets a temporary meta value", Permission.USER_UNSET_TEMP_META, Permission.GROUP_UNSET_TEMP_META, Predicate.notInRange(1, 3),
|
||||
Arg.list(
|
||||
Arg.create("key", true, "the key to unset"),
|
||||
Arg.create("server", false, "the server to remove the meta pair on"),
|
||||
Arg.create("world", false, "the world to remove the meta pair on")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String key = MetaUtils.escapeCharacters(args.get(0));
|
||||
|
||||
String server = null;
|
||||
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);
|
||||
|
||||
if (server == null) {
|
||||
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName());
|
||||
} else {
|
||||
if (world == null) {
|
||||
Message.UNSET_META_TEMP_SERVER_SUCCESS.send(sender, key, holder.getFriendlyName(), server);
|
||||
} else {
|
||||
Message.UNSET_META_TEMP_SERVER_WORLD_SUCCESS.send(sender, key, holder.getFriendlyName(), server, world);
|
||||
}
|
||||
}
|
||||
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta unsettemp " + args.stream().collect(Collectors.joining(" ")))
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(holder, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -30,11 +30,11 @@ import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
public class CommandParent<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public CommandParent(boolean user) {
|
||||
super("Parent", "Edit inheritances", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
.add(new ParentInfo())
|
||||
.add(new ParentAdd())
|
||||
.add(new ParentRemove())
|
||||
.add(new ParentAddTemp())
|
||||
.add(new ParentRemoveTemp())
|
||||
.build());
|
||||
.add(new ParentInfo())
|
||||
.add(new ParentAdd())
|
||||
.add(new ParentRemove())
|
||||
.add(new ParentAddTemp())
|
||||
.add(new ParentRemoveTemp())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ import me.lucko.luckperms.common.core.PermissionHolder;
|
||||
public class CommandPermission<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public CommandPermission(boolean user) {
|
||||
super("Permission", "Edit permissions", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
.add(new PermissionInfo())
|
||||
.add(new PermissionSet())
|
||||
.add(new PermissionUnset())
|
||||
.add(new PermissionSetTemp())
|
||||
.add(new PermissionUnsetTemp())
|
||||
.build());
|
||||
.add(new PermissionInfo())
|
||||
.add(new PermissionSet())
|
||||
.add(new PermissionUnset())
|
||||
.add(new PermissionSetTemp())
|
||||
.add(new PermissionUnsetTemp())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.MainCommand;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.commands.SubCommand;
|
||||
import me.lucko.luckperms.common.commands.generic.meta.CommandMeta;
|
||||
import me.lucko.luckperms.common.commands.generic.parent.CommandParent;
|
||||
import me.lucko.luckperms.common.commands.generic.permission.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.group.subcommands.*;
|
||||
import me.lucko.luckperms.common.commands.generic.meta.CommandMeta;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.groups.Group;
|
||||
|
||||
|
@ -24,6 +24,7 @@ package me.lucko.luckperms.common.commands.migration.subcommands;
|
||||
|
||||
import de.bananaco.bpermissions.api.*;
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
@ -222,7 +223,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
// Migrate existing meta
|
||||
for (Map.Entry<String, String> meta : c.getMeta().entrySet()) {
|
||||
if (meta.getKey().equalsIgnoreCase("prefix") || meta.getKey().equalsIgnoreCase("suffix")) {
|
||||
String chatMeta = ArgumentChecker.escapeCharacters(meta.getValue());
|
||||
String chatMeta = MetaUtils.escapeCharacters(meta.getValue());
|
||||
try {
|
||||
holder.setPermission(meta.getKey().toLowerCase() + "." + c.getPriority() + "." + chatMeta, true);
|
||||
LogEntry.build()
|
||||
|
@ -23,6 +23,7 @@
|
||||
package me.lucko.luckperms.common.commands.migration.subcommands;
|
||||
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.Predicate;
|
||||
@ -144,7 +145,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
String suffix = g.getSuffix();
|
||||
|
||||
if (prefix != null && !prefix.equals("")) {
|
||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||
prefix = MetaUtils.escapeCharacters(prefix);
|
||||
try {
|
||||
group.setPermission("prefix.50." + prefix, true);
|
||||
LogEntry.build()
|
||||
@ -159,7 +160,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
if (suffix != null && !suffix.equals("")) {
|
||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||
suffix = MetaUtils.escapeCharacters(suffix);
|
||||
try {
|
||||
group.setPermission("suffix.50." + suffix, true);
|
||||
LogEntry.build()
|
||||
@ -259,7 +260,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
String suffix = u.getSuffix();
|
||||
|
||||
if (prefix != null && !prefix.equals("")) {
|
||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||
prefix = MetaUtils.escapeCharacters(prefix);
|
||||
try {
|
||||
user.setPermission("prefix.100." + prefix, true);
|
||||
LogEntry.build()
|
||||
@ -274,7 +275,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
if (suffix != null && !suffix.equals("")) {
|
||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||
suffix = MetaUtils.escapeCharacters(suffix);
|
||||
try {
|
||||
user.setPermission("suffix.100." + suffix, true);
|
||||
LogEntry.build()
|
||||
|
@ -23,6 +23,7 @@
|
||||
package me.lucko.luckperms.common.commands.migration.subcommands;
|
||||
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.api.PlatformType;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
@ -197,7 +198,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
String suffix = group.getOwnSuffix();
|
||||
|
||||
if (prefix != null && !prefix.equals("")) {
|
||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||
prefix = MetaUtils.escapeCharacters(prefix);
|
||||
try {
|
||||
lpGroup.setPermission("prefix." + groupWeight + "." + prefix, true);
|
||||
LogEntry.build()
|
||||
@ -212,7 +213,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
if (suffix != null && !suffix.equals("")) {
|
||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||
suffix = MetaUtils.escapeCharacters(suffix);
|
||||
try {
|
||||
lpGroup.setPermission("suffix." + groupWeight + "." + suffix, true);
|
||||
LogEntry.build()
|
||||
@ -341,7 +342,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
String suffix = user.getOwnSuffix();
|
||||
|
||||
if (prefix != null && !prefix.equals("")) {
|
||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||
prefix = MetaUtils.escapeCharacters(prefix);
|
||||
try {
|
||||
lpUser.setPermission("prefix." + maxGroupWeight + "." + prefix, true);
|
||||
LogEntry.build()
|
||||
@ -356,7 +357,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
if (suffix != null && !suffix.equals("")) {
|
||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||
suffix = MetaUtils.escapeCharacters(suffix);
|
||||
try {
|
||||
lpUser.setPermission("suffix." + maxGroupWeight + "." + suffix, true);
|
||||
LogEntry.build()
|
||||
|
@ -23,6 +23,7 @@
|
||||
package me.lucko.luckperms.common.commands.migration.subcommands;
|
||||
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.MetaUtils;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.commands.*;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
@ -213,7 +214,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
String suffix = service.getPlayerSuffix(u);
|
||||
|
||||
if (prefix != null && !prefix.equals("")) {
|
||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||
prefix = MetaUtils.escapeCharacters(prefix);
|
||||
try {
|
||||
user.setPermission("prefix.100." + prefix, true);
|
||||
LogEntry.build()
|
||||
@ -228,7 +229,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
if (suffix != null && !suffix.equals("")) {
|
||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||
suffix = MetaUtils.escapeCharacters(suffix);
|
||||
try {
|
||||
user.setPermission("suffix.100." + suffix, true);
|
||||
LogEntry.build()
|
||||
|
@ -223,6 +223,22 @@ public enum Message {
|
||||
REMOVE_TEMP_SUFFIX_SERVER_SUCCESS("&b{0}&a had temporary suffix &f\"{1}&f\"&a at priority &b{2}&a removed on server &b{3}&a.", true),
|
||||
REMOVE_TEMP_SUFFIX_SERVER_WORLD_SUCCESS("&b{0}&a had temporary suffix &f\"{1}&f\"&a at priority &b{2}&a removed on server &b{3}&a, world &b{4}&a.", true),
|
||||
|
||||
ALREADY_HAS_META("{0} already has that meta key value pair set.", true),
|
||||
|
||||
SET_META_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a.", true),
|
||||
SET_META_SERVER_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a on server &b{3}&a.", true),
|
||||
SET_META_SERVER_WORLD_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a on server &b{3}&a, world &b{4}&a.", true),
|
||||
SET_META_TEMP_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a for a duration of &b{3}&a.", true),
|
||||
SET_META_TEMP_SERVER_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a on server &b{3}&a for a duration of &b{4}&a.", true),
|
||||
SET_META_TEMP_SERVER_WORLD_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a on server &b{3}&a, world &b{4}&a, for a duration of &b{5}&a.", true),
|
||||
|
||||
UNSET_META_SUCCESS("&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a.", true),
|
||||
UNSET_META_SERVER_SUCCESS("&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a on server &b{2}&a.", true),
|
||||
UNSET_META_SERVER_WORLD_SUCCESS("&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a on server &b{2}&a, world &b{3}&a.", true),
|
||||
UNSET_META_TEMP_SUCCESS("&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a.", true),
|
||||
UNSET_META_TEMP_SERVER_SUCCESS("&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a on server &b{2}&a.", true),
|
||||
UNSET_META_TEMP_SERVER_WORLD_SUCCESS("&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a on server &b{2}&a, world &b{3}&a.", true),
|
||||
|
||||
BULK_CHANGE_TYPE_ERROR("Invalid type. Was expecting 'server' or 'world'.", true),
|
||||
BULK_CHANGE_SUCCESS("&aApplied bulk change successfully. {0} records were changed.", true),
|
||||
|
||||
|
@ -72,6 +72,10 @@ public enum Permission {
|
||||
USER_REMOVE_TEMP_PREFIX("removetempprefix", "user"),
|
||||
USER_ADD_TEMP_SUFFIX("addtempsuffix", "user"),
|
||||
USER_REMOVE_TEMP_SUFFIX("removetempsuffix", "user"),
|
||||
USER_SET_META("setmeta", "user"),
|
||||
USER_UNSET_META("unsetmeta", "user"),
|
||||
USER_SET_TEMP_META("settempmeta", "user"),
|
||||
USER_UNSET_TEMP_META("unsettempmeta", "user"),
|
||||
USER_CLEARMETA("clearmeta", "user"),
|
||||
USER_BULKCHANGE("bulkchange", "user"),
|
||||
USER_CLEAR("clear", "user"),
|
||||
@ -99,6 +103,10 @@ public enum Permission {
|
||||
GROUP_REMOVE_TEMP_PREFIX("removetempprefix", "group"),
|
||||
GROUP_ADD_TEMP_SUFFIX("addtempsuffix", "group"),
|
||||
GROUP_REMOVE_TEMP_SUFFIX("removetempsuffix", "group"),
|
||||
GROUP_SET_META("setmeta", "group"),
|
||||
GROUP_UNSET_META("unsetmeta", "group"),
|
||||
GROUP_SET_TEMP_META("settempmeta", "group"),
|
||||
GROUP_UNSET_TEMP_META("unsettempmeta", "group"),
|
||||
GROUP_CLEARMETA("clearmeta", "group"),
|
||||
GROUP_BULKCHANGE("bulkchange", "group"),
|
||||
GROUP_CLEAR("clear", "group"),
|
||||
|
@ -232,6 +232,47 @@ public abstract class PermissionHolder {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMetaKeys(String key, boolean temp) {
|
||||
synchronized (nodes) {
|
||||
nodes.removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key));
|
||||
invalidateCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMetaKeys(String key, String server, boolean temp) {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
String finalServer = server;
|
||||
|
||||
synchronized (nodes) {
|
||||
nodes.removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key) &&
|
||||
n.getServer().orElse("global").equalsIgnoreCase(finalServer)
|
||||
);
|
||||
invalidateCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMetaKeys(String key, String server, String world, boolean temp) {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
String finalServer = server;
|
||||
|
||||
if (world == null) {
|
||||
world = "null";
|
||||
}
|
||||
String finalWorld = world;
|
||||
|
||||
synchronized (nodes) {
|
||||
nodes.removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key) &&
|
||||
n.getServer().orElse("global").equalsIgnoreCase(finalServer) &&
|
||||
n.getWorld().orElse("null").equalsIgnoreCase(finalWorld)
|
||||
);
|
||||
invalidateCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearTransientNodes() {
|
||||
synchronized (transientNodes) {
|
||||
transientNodes.clear();
|
||||
|
@ -90,7 +90,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
||||
*/
|
||||
public void setupData(boolean op) {
|
||||
if (userData != null) {
|
||||
throw new IllegalStateException("Data already setup");
|
||||
return;
|
||||
}
|
||||
|
||||
userData = new UserData(this, getPlugin().getCalculatorFactory());
|
||||
|
@ -48,20 +48,4 @@ public class ArgumentChecker {
|
||||
return DateUtil.shouldExpire(l);
|
||||
}
|
||||
|
||||
public static String escapeCharacters(String s) {
|
||||
s = s.replace(".", "{SEP}");
|
||||
s = s.replace("/", "{FSEP}");
|
||||
s = s.replace("$", "{DSEP}");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String unescapeCharacters(String s) {
|
||||
s = s.replace("{SEP}", ".");
|
||||
s = s.replace("{FSEP}", "/");
|
||||
s = s.replace("{DSEP}", "$");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
||||
import me.lucko.luckperms.common.commands.Sender;
|
||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||
|
@ -43,7 +43,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.utils.ArgumentChecker.unescapeCharacters;
|
||||
import static me.lucko.luckperms.api.MetaUtils.unescapeCharacters;
|
||||
|
||||
@EqualsAndHashCode(of = "group")
|
||||
public class LuckPermsGroupSubject implements Subject {
|
||||
|
@ -41,7 +41,7 @@ import org.spongepowered.api.util.Tristate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.utils.ArgumentChecker.escapeCharacters;
|
||||
import static me.lucko.luckperms.api.MetaUtils.escapeCharacters;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class LuckPermsSubjectData implements SubjectData {
|
||||
|
@ -34,7 +34,6 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.service.context.Context;
|
||||
import org.spongepowered.api.service.permission.Subject;
|
||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||
import org.spongepowered.api.service.permission.SubjectData;
|
||||
import org.spongepowered.api.util.Tristate;
|
||||
|
||||
import java.util.*;
|
||||
|
Loading…
Reference in New Issue
Block a user