mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 03:57:36 +01:00
Update internal permissions to match the new command layouts
This commit is contained in:
parent
c66a01c1a6
commit
ce3d7829d7
@ -37,6 +37,7 @@ import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
|||||||
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
import me.lucko.luckperms.common.commands.ConsecutiveExecutor;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||||
import me.lucko.luckperms.common.core.UuidCache;
|
import me.lucko.luckperms.common.core.UuidCache;
|
||||||
@ -53,7 +54,6 @@ import me.lucko.luckperms.common.utils.LogFactory;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
@ -355,30 +355,10 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
private void registerPermissions(PermissionDefault def) {
|
private void registerPermissions(PermissionDefault def) {
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
Map<String, List<String>> wildcards = new HashMap<>();
|
for (Permission p : Permission.values()) {
|
||||||
List<String> all = new ArrayList<>();
|
for (String node : p.getNodes()) {
|
||||||
for (me.lucko.luckperms.common.constants.Permission p : me.lucko.luckperms.common.constants.Permission.values()) {
|
pm.addPermission(new org.bukkit.permissions.Permission(node, def));
|
||||||
pm.addPermission(new Permission(p.getNode(), def));
|
|
||||||
if (p.getGroup() != null) {
|
|
||||||
if (!wildcards.containsKey(p.getGroup())) {
|
|
||||||
wildcards.put(p.getGroup(), new ArrayList<>());
|
|
||||||
}
|
|
||||||
wildcards.get(p.getGroup()).add(p.getTag());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
all.add(p.getNode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, List<String>> e : wildcards.entrySet()) {
|
|
||||||
pm.addPermission(new Permission(
|
|
||||||
"luckperms." + e.getKey() + ".*", def,
|
|
||||||
e.getValue().stream()
|
|
||||||
.map(tag -> "luckperms." + e.getKey() + "." + tag)
|
|
||||||
.collect(Collectors.toMap(s -> s, s -> true))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
pm.addPermission(new Permission("luckperms.*", def, all.stream().collect(Collectors.toMap(s -> s, s -> true))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,16 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands;
|
package me.lucko.luckperms.common.commands;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
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.utils.ImmutableCollectors;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class to make a thread-safe sender instance
|
* Factory class to make a thread-safe sender instance
|
||||||
@ -100,12 +99,15 @@ public abstract class SenderFactory<T> implements Runnable {
|
|||||||
this.console = this.uuid.equals(Constants.getConsoleUUID()) || this.uuid.equals(Constants.getImporterUUID());
|
this.console = this.uuid.equals(Constants.getConsoleUUID()) || this.uuid.equals(Constants.getImporterUUID());
|
||||||
|
|
||||||
if (!this.console) {
|
if (!this.console) {
|
||||||
if (toCheck == null || toCheck.isEmpty()) {
|
this.perms = ((toCheck == null || toCheck.isEmpty()) ? Arrays.stream(Permission.values()) : toCheck.stream())
|
||||||
this.perms = ImmutableMap.copyOf(Arrays.stream(Permission.values())
|
.collect(ImmutableCollectors.toImmutableMap(p -> p, p -> {
|
||||||
.collect(Collectors.toMap(p -> p, p -> factory.hasPermission(t, p.getNode()))));
|
for (String s : p.getNodes()) {
|
||||||
} else {
|
if (factory.hasPermission(t, s)) {
|
||||||
this.perms = ImmutableMap.copyOf(toCheck.stream().collect(Collectors.toMap(p -> p, p -> factory.hasPermission(t, p.getNode()))));
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaAddPrefix extends SecondarySubCommand {
|
public class MetaAddPrefix extends SecondarySubCommand {
|
||||||
public MetaAddPrefix() {
|
public MetaAddPrefix() {
|
||||||
super("addprefix", "Adds a prefix", Permission.USER_ADDPREFIX, Permission.GROUP_ADDPREFIX, Predicate.notInRange(2, 4),
|
super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX, Predicate.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"),
|
||||||
|
@ -40,7 +40,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaAddSuffix extends SecondarySubCommand {
|
public class MetaAddSuffix extends SecondarySubCommand {
|
||||||
public MetaAddSuffix() {
|
public MetaAddSuffix() {
|
||||||
super("addsuffix", "Adds a suffix", Permission.USER_ADDSUFFIX, Permission.GROUP_ADDSUFFIX, Predicate.notInRange(2, 4),
|
super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX, Predicate.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"),
|
||||||
|
@ -41,7 +41,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaAddTempPrefix extends SecondarySubCommand {
|
public class MetaAddTempPrefix extends SecondarySubCommand {
|
||||||
public MetaAddTempPrefix() {
|
public MetaAddTempPrefix() {
|
||||||
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_ADD_TEMP_PREFIX, Permission.GROUP_ADD_TEMP_PREFIX, Predicate.notInRange(3, 5),
|
super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX, Permission.GROUP_META_ADDTEMP_PREFIX, Predicate.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"),
|
||||||
|
@ -41,7 +41,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaAddTempSuffix extends SecondarySubCommand {
|
public class MetaAddTempSuffix extends SecondarySubCommand {
|
||||||
public MetaAddTempSuffix() {
|
public MetaAddTempSuffix() {
|
||||||
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_ADD_TEMP_SUFFIX, Permission.GROUP_ADD_TEMP_SUFFIX, Predicate.notInRange(3, 5),
|
super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX, Permission.GROUP_META_ADDTEMP_SUFFIX, Predicate.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"),
|
||||||
|
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaClear extends SecondarySubCommand {
|
public class MetaClear extends SecondarySubCommand {
|
||||||
public MetaClear() {
|
public MetaClear() {
|
||||||
super("clear", "Clears all chat meta", Permission.USER_CLEARMETA, Permission.GROUP_CLEARMETA, Predicate.notInRange(0, 2),
|
super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicate.notInRange(0, 2),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("server", false, "the server name to filter by"),
|
Arg.create("server", false, "the server name to filter by"),
|
||||||
Arg.create("world", false, "the world name to filter by")
|
Arg.create("world", false, "the world name to filter by")
|
||||||
|
@ -38,7 +38,7 @@ import java.util.*;
|
|||||||
|
|
||||||
public class MetaInfo extends SecondarySubCommand {
|
public class MetaInfo extends SecondarySubCommand {
|
||||||
public MetaInfo() {
|
public MetaInfo() {
|
||||||
super("info", "Shows all chat meta", Permission.USER_CHATMETA, Permission.GROUP_CHATMETA, Predicate.alwaysFalse(), null);
|
super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicate.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaRemovePrefix extends SecondarySubCommand {
|
public class MetaRemovePrefix extends SecondarySubCommand {
|
||||||
public MetaRemovePrefix() {
|
public MetaRemovePrefix() {
|
||||||
super("removeprefix", "Removes a prefix", Permission.USER_REMOVEPREFIX, Permission.GROUP_REMOVEPREFIX, Predicate.notInRange(2, 4),
|
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX, Predicate.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"),
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaRemoveSuffix extends SecondarySubCommand {
|
public class MetaRemoveSuffix extends SecondarySubCommand {
|
||||||
public MetaRemoveSuffix() {
|
public MetaRemoveSuffix() {
|
||||||
super("removesuffix", "Removes a suffix", Permission.USER_REMOVESUFFIX, Permission.GROUP_REMOVESUFFIX, Predicate.notInRange(2, 4),
|
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX, Predicate.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"),
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
public class MetaRemoveTempPrefix extends SecondarySubCommand {
|
||||||
public MetaRemoveTempPrefix() {
|
public MetaRemoveTempPrefix() {
|
||||||
super("removetempprefix", "Removes a temporary prefix", Permission.USER_REMOVE_TEMP_PREFIX, Permission.GROUP_REMOVE_TEMP_PREFIX, Predicate.notInRange(2, 4),
|
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicate.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"),
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
public class MetaRemoveTempSuffix extends SecondarySubCommand {
|
||||||
public MetaRemoveTempSuffix() {
|
public MetaRemoveTempSuffix() {
|
||||||
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_REMOVE_TEMP_SUFFIX, Permission.GROUP_REMOVE_TEMP_SUFFIX, Predicate.notInRange(2, 4),
|
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicate.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"),
|
||||||
|
@ -41,7 +41,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaSet extends SecondarySubCommand {
|
public class MetaSet extends SecondarySubCommand {
|
||||||
public MetaSet() {
|
public MetaSet() {
|
||||||
super("set", "Sets a meta value", Permission.USER_SET_META, Permission.GROUP_SET_META, Predicate.notInRange(2, 4),
|
super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicate.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("key", true, "the key to set"),
|
Arg.create("key", true, "the key to set"),
|
||||||
Arg.create("value", true, "the value to set"),
|
Arg.create("value", true, "the value to set"),
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MetaSetTemp extends SecondarySubCommand {
|
public class MetaSetTemp extends SecondarySubCommand {
|
||||||
public MetaSetTemp() {
|
public MetaSetTemp() {
|
||||||
super("settemp", "Sets a meta value temporarily", Permission.USER_SET_TEMP_META, Permission.GROUP_SET_TEMP_META, Predicate.notInRange(3, 5),
|
super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicate.notInRange(3, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("key", true, "the key to set"),
|
Arg.create("key", true, "the key to set"),
|
||||||
Arg.create("value", true, "the value to set"),
|
Arg.create("value", true, "the value to set"),
|
||||||
|
@ -40,7 +40,7 @@ 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_UNSET_META, Permission.GROUP_UNSET_META, Predicate.notInRange(1, 3),
|
super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, Predicate.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"),
|
||||||
|
@ -40,7 +40,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaUnsetTemp extends SecondarySubCommand {
|
public class MetaUnsetTemp extends SecondarySubCommand {
|
||||||
public MetaUnsetTemp() {
|
public MetaUnsetTemp() {
|
||||||
super("unset", "Unsets a temporary meta value", Permission.USER_UNSET_TEMP_META, Permission.GROUP_UNSET_TEMP_META, Predicate.notInRange(1, 3),
|
super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, Predicate.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"),
|
||||||
|
@ -43,7 +43,7 @@ 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_ADDGROUP, Permission.GROUP_SETINHERIT, Predicate.notInRange(1, 3),
|
Permission.USER_PARENT_ADD, Permission.GROUP_PARENT_ADD, Predicate.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"),
|
||||||
|
@ -44,7 +44,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
|||||||
public class ParentAddTemp extends SecondarySubCommand {
|
public class ParentAddTemp extends SecondarySubCommand {
|
||||||
public ParentAddTemp() {
|
public ParentAddTemp() {
|
||||||
super("addtemp", "Sets another group for the object to inherit permissions from temporarily",
|
super("addtemp", "Sets another group for the object to inherit permissions from temporarily",
|
||||||
Permission.USER_ADDTEMPGROUP, Permission.GROUP_SET_TEMP_INHERIT, Predicate.notInRange(2, 4),
|
Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicate.notInRange(2, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("group", true, "the group to inherit from"),
|
Arg.create("group", true, "the group to inherit from"),
|
||||||
Arg.create("duration", true, "the duration of the group membership"),
|
Arg.create("duration", true, "the duration of the group membership"),
|
||||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
|||||||
public class ParentInfo extends SecondarySubCommand {
|
public class ParentInfo extends SecondarySubCommand {
|
||||||
public ParentInfo() {
|
public ParentInfo() {
|
||||||
super("info", "Lists the groups that this object inherits from",
|
super("info", "Lists the groups that this object inherits from",
|
||||||
Permission.USER_LISTGROUPS, Permission.GROUP_LISTPARENTS, Predicate.alwaysFalse(), null);
|
Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicate.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ 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_REMOVEGROUP, Permission.GROUP_UNSETINHERIT,
|
super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE, Permission.GROUP_PARENT_REMOVE,
|
||||||
Predicate.notInRange(1, 3),
|
Predicate.notInRange(1, 3),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("group", true, "the group to remove"),
|
Arg.create("group", true, "the group to remove"),
|
||||||
|
@ -42,7 +42,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete;
|
|||||||
public class ParentRemoveTemp extends SecondarySubCommand {
|
public class ParentRemoveTemp extends SecondarySubCommand {
|
||||||
public ParentRemoveTemp() {
|
public ParentRemoveTemp() {
|
||||||
super("removetemp", "Removes a previously set temporary inheritance rule",
|
super("removetemp", "Removes a previously set temporary inheritance rule",
|
||||||
Permission.USER_REMOVETEMPGROUP, Permission.GROUP_UNSET_TEMP_INHERIT, Predicate.notInRange(1, 3),
|
Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicate.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"),
|
||||||
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PermissionInfo extends SecondarySubCommand {
|
public class PermissionInfo extends SecondarySubCommand {
|
||||||
public PermissionInfo() {
|
public PermissionInfo() {
|
||||||
super("info", "Lists the permission nodes the object has", Permission.USER_LISTNODES, Permission.GROUP_LISTNODES, Predicate.alwaysFalse(), null);
|
super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicate.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ 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_SETPERMISSION, Permission.GROUP_SETPERMISSION, Predicate.notInRange(2, 4),
|
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, Predicate.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"),
|
||||||
|
@ -42,7 +42,7 @@ 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_SET_TEMP_PERMISSION, Permission.GROUP_SET_TEMP_PERMISSION,
|
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP, Permission.GROUP_PERM_SETTEMP,
|
||||||
Predicate.notInRange(3, 5),
|
Predicate.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"),
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PermissionUnset extends SecondarySubCommand {
|
public class PermissionUnset extends SecondarySubCommand {
|
||||||
public PermissionUnset() {
|
public PermissionUnset() {
|
||||||
super("unset", "Unsets a permission for the object", Permission.USER_UNSETPERMISSION, Permission.GROUP_UNSETPERMISSION, Predicate.notInRange(1, 3),
|
super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, Predicate.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"),
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
|
|
||||||
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_UNSET_TEMP_PERMISSION, Permission.GROUP_UNSET_TEMP_PERMISSION,
|
super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP, Permission.GROUP_PERM_UNSETTEMP,
|
||||||
Predicate.notInRange(1, 3),
|
Predicate.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"),
|
||||||
|
@ -22,128 +22,153 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.constants;
|
package me.lucko.luckperms.common.constants;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
|
||||||
public enum Permission {
|
public enum Permission {
|
||||||
|
|
||||||
SYNC("sync", null),
|
SYNC(set("sync"), Type.NONE),
|
||||||
INFO("info", null),
|
INFO(set("info"), Type.NONE),
|
||||||
DEBUG("debug", null),
|
DEBUG(set("debug"), Type.NONE),
|
||||||
IMPORT("import", null),
|
IMPORT(set("import"), Type.NONE),
|
||||||
|
|
||||||
CREATE_GROUP("creategroup", null),
|
CREATE_GROUP(set("creategroup"), Type.NONE),
|
||||||
DELETE_GROUP("deletegroup", null),
|
DELETE_GROUP(set("deletegroup"), Type.NONE),
|
||||||
LIST_GROUPS("listgroups", null),
|
LIST_GROUPS(set("listgroups"), Type.NONE),
|
||||||
|
|
||||||
CREATE_TRACK("createtrack", null),
|
CREATE_TRACK(set("createtrack"), Type.NONE),
|
||||||
DELETE_TRACK("deletetrack", null),
|
DELETE_TRACK(set("deletetrack"), Type.NONE),
|
||||||
LIST_TRACKS("listtracks", null),
|
LIST_TRACKS(set("listtracks"), Type.NONE),
|
||||||
|
|
||||||
USER_INFO("info", "user"),
|
USER_INFO(set("info"), Type.USER),
|
||||||
USER_GETUUID("getuuid", "user"),
|
USER_PERM_INFO(set("permission.info", "listnodes"), Type.USER),
|
||||||
USER_LISTNODES("listnodes", "user"),
|
USER_PERM_SET(set("permission.set", "setpermission"), Type.USER),
|
||||||
USER_LISTGROUPS("listgroups", "user"),
|
USER_PERM_UNSET(set("permission.unset", "unsetpermission"), Type.USER),
|
||||||
USER_HASPERMISSION("haspermission", "user"),
|
USER_PERM_SETTEMP(set("permission.settemp", "settemppermission"), Type.USER),
|
||||||
USER_INHERITSPERMISSION("inheritspermission", "user"),
|
USER_PERM_UNSETTEMP(set("permission.unsettemp", "unsettemppermission"), Type.USER),
|
||||||
USER_SETPERMISSION("setpermission", "user"),
|
USER_PARENT_INFO(set("parent.info", "listgroups"), Type.USER),
|
||||||
USER_UNSETPERMISSION("unsetpermission", "user"),
|
USER_PARENT_ADD(set("parent.add", "addgroup"), Type.USER),
|
||||||
USER_ADDGROUP("addgroup", "user"),
|
USER_PARENT_REMOVE(set("parent.remove", "removegroup"), Type.USER),
|
||||||
USER_REMOVEGROUP("removegroup", "user"),
|
USER_PARENT_ADDTEMP(set("parent.addtemp", "addtempgroup"), Type.USER),
|
||||||
USER_SET_TEMP_PERMISSION("settemppermission", "user"),
|
USER_PARENT_REMOVETEMP(set("parent.removetemp", "removetempgroup"), Type.USER),
|
||||||
USER_UNSET_TEMP_PERMISSION("unsettemppermission", "user"),
|
USER_META_INFO(set("meta.info", "chatmeta"), Type.USER),
|
||||||
USER_ADDTEMPGROUP("addtempgroup", "user"),
|
USER_META_SET(set("meta.set", "setmeta"), Type.USER),
|
||||||
USER_REMOVETEMPGROUP("removetempgroup", "user"),
|
USER_META_UNSET(set("meta.unset", "unsetmeta"), Type.USER),
|
||||||
USER_SETPRIMARYGROUP("setprimarygroup", "user"),
|
USER_META_SETTEMP(set("meta.settemp", "settempmeta"), Type.USER),
|
||||||
USER_SHOWTRACKS("showtracks", "user"),
|
USER_META_UNSETTEMP(set("meta.unsettemp", "unsettempmeta"), Type.USER),
|
||||||
USER_PROMOTE("promote", "user"),
|
USER_META_ADDPREFIX(set("meta.addprefix", "addprefix"), Type.USER),
|
||||||
USER_DEMOTE("demote", "user"),
|
USER_META_ADDSUFFIX(set("meta.addsuffix", "addsuffix"), Type.USER),
|
||||||
USER_SHOWPOS("showpos", "user"),
|
USER_META_REMOVEPREFIX(set("meta.removeprefix", "removeprefix"), Type.USER),
|
||||||
USER_CHATMETA("chatmeta", "user"),
|
USER_META_REMOVESUFFIX(set("meta.removesuffix", "removesuffix"), Type.USER),
|
||||||
USER_ADDPREFIX("addprefix", "user"),
|
USER_META_ADDTEMP_PREFIX(set("meta.addtempprefix", "addtempprefix"), Type.USER),
|
||||||
USER_REMOVEPREFIX("removeprefix", "user"),
|
USER_META_ADDTEMP_SUFFIX(set("meta.addtempsuffix", "addtempsuffix"), Type.USER),
|
||||||
USER_ADDSUFFIX("addsuffix", "user"),
|
USER_META_REMOVETEMP_PREFIX(set("meta.removetempprefix", "removetempprefix"), Type.USER),
|
||||||
USER_REMOVESUFFIX("removesuffix", "user"),
|
USER_META_REMOVETEMP_SUFFIX(set("meta.removetempsuffix", "removetempsuffix"), Type.USER),
|
||||||
USER_ADD_TEMP_PREFIX("addtempprefix", "user"),
|
USER_META_CLEAR(set("meta.clear", "clearmeta"), Type.USER),
|
||||||
USER_REMOVE_TEMP_PREFIX("removetempprefix", "user"),
|
USER_GETUUID(set("getuuid"), Type.USER),
|
||||||
USER_ADD_TEMP_SUFFIX("addtempsuffix", "user"),
|
USER_HASPERMISSION(set("haspermission"), Type.USER),
|
||||||
USER_REMOVE_TEMP_SUFFIX("removetempsuffix", "user"),
|
USER_INHERITSPERMISSION(set("inheritspermission"), Type.USER),
|
||||||
USER_SET_META("setmeta", "user"),
|
USER_SETPRIMARYGROUP(set("setprimarygroup"), Type.USER),
|
||||||
USER_UNSET_META("unsetmeta", "user"),
|
USER_SHOWTRACKS(set("showtracks"), Type.USER),
|
||||||
USER_SET_TEMP_META("settempmeta", "user"),
|
USER_PROMOTE(set("promote"), Type.USER),
|
||||||
USER_UNSET_TEMP_META("unsettempmeta", "user"),
|
USER_DEMOTE(set("demote"), Type.USER),
|
||||||
USER_CLEARMETA("clearmeta", "user"),
|
USER_SHOWPOS(set("showpos"), Type.USER),
|
||||||
USER_BULKCHANGE("bulkchange", "user"),
|
USER_BULKCHANGE(set("bulkchange"), Type.USER),
|
||||||
USER_CLEAR("clear", "user"),
|
USER_CLEAR(set("clear"), Type.USER),
|
||||||
|
|
||||||
GROUP_INFO("info", "group"),
|
GROUP_INFO(set("info"), Type.GROUP),
|
||||||
GROUP_LISTNODES("listnodes", "group"),
|
GROUP_PERM_INFO(set("permission.info", "listnodes"), Type.GROUP),
|
||||||
GROUP_LISTPARENTS("listparents", "group"),
|
GROUP_PERM_SET(set("permission.set", "setpermission"), Type.GROUP),
|
||||||
GROUP_HASPERMISSION("haspermission", "group"),
|
GROUP_PERM_UNSET(set("permission.unset", "unsetpermission"), Type.GROUP),
|
||||||
GROUP_INHERITSPERMISSION("inheritspermission", "group"),
|
GROUP_PERM_SETTEMP(set("permission.settemp", "settemppermission"), Type.GROUP),
|
||||||
GROUP_SETPERMISSION("setpermission", "group"),
|
GROUP_PERM_UNSETTEMP(set("permission.unsettemp", "unsettemppermission"), Type.GROUP),
|
||||||
GROUP_UNSETPERMISSION("unsetpermission", "group"),
|
GROUP_PARENT_INFO(set("parent.info", "listparents"), Type.GROUP),
|
||||||
GROUP_SETINHERIT("setinherit", "group"),
|
GROUP_PARENT_ADD(set("parent.add", "setinherit"), Type.GROUP),
|
||||||
GROUP_UNSETINHERIT("unsetinherit", "group"),
|
GROUP_PARENT_REMOVE(set("parent.remove", "unsetinherit"), Type.GROUP),
|
||||||
GROUP_SET_TEMP_PERMISSION("settemppermission", "group"),
|
GROUP_PARENT_ADDTEMP(set("parent.addtemp", "settempinherit"), Type.GROUP),
|
||||||
GROUP_UNSET_TEMP_PERMISSION("unsettemppermission", "group"),
|
GROUP_PARENT_REMOVETEMP(set("parent.removetemp", "unsettempinherit"), Type.GROUP),
|
||||||
GROUP_SET_TEMP_INHERIT("settempinherit", "group"),
|
GROUP_META_INFO(set("meta.info", "chatmeta"), Type.GROUP),
|
||||||
GROUP_UNSET_TEMP_INHERIT("unsettempinherit", "group"),
|
GROUP_META_SET(set("meta.set", "setmeta"), Type.GROUP),
|
||||||
GROUP_SHOWTRACKS("showtracks", "group"),
|
GROUP_META_UNSET(set("meta.unset", "unsetmeta"), Type.GROUP),
|
||||||
GROUP_CHATMETA("chatmeta", "group"),
|
GROUP_META_SETTEMP(set("meta.settemp", "settempmeta"), Type.GROUP),
|
||||||
GROUP_ADDPREFIX("addprefix", "group"),
|
GROUP_META_UNSETTEMP(set("meta.unsettemp", "unsettempmeta"), Type.GROUP),
|
||||||
GROUP_REMOVEPREFIX("removeprefix", "group"),
|
GROUP_META_ADDPREFIX(set("meta.addprefix", "addprefix"), Type.GROUP),
|
||||||
GROUP_ADDSUFFIX("addsuffix", "group"),
|
GROUP_META_ADDSUFFIX(set("meta.addsuffix", "addsuffix"), Type.GROUP),
|
||||||
GROUP_REMOVESUFFIX("removesuffix", "group"),
|
GROUP_META_REMOVEPREFIX(set("meta.removeprefix", "removeprefix"), Type.GROUP),
|
||||||
GROUP_ADD_TEMP_PREFIX("addtempprefix", "group"),
|
GROUP_META_REMOVESUFFIX(set("meta.removesuffix", "removesuffix"), Type.GROUP),
|
||||||
GROUP_REMOVE_TEMP_PREFIX("removetempprefix", "group"),
|
GROUP_META_ADDTEMP_PREFIX(set("meta.addtempprefix", "addtempprefix"), Type.GROUP),
|
||||||
GROUP_ADD_TEMP_SUFFIX("addtempsuffix", "group"),
|
GROUP_META_ADDTEMP_SUFFIX(set("meta.addtempsuffix", "addtempsuffix"), Type.GROUP),
|
||||||
GROUP_REMOVE_TEMP_SUFFIX("removetempsuffix", "group"),
|
GROUP_META_REMOVETEMP_PREFIX(set("meta.removetempprefix", "removetempprefix"), Type.GROUP),
|
||||||
GROUP_SET_META("setmeta", "group"),
|
GROUP_META_REMOVETEMP_SUFFIX(set("meta.removetempsuffix", "removetempsuffix"), Type.GROUP),
|
||||||
GROUP_UNSET_META("unsetmeta", "group"),
|
GROUP_META_CLEAR(set("meta.clear", "clearmeta"), Type.GROUP),
|
||||||
GROUP_SET_TEMP_META("settempmeta", "group"),
|
GROUP_HASPERMISSION(set("haspermission"), Type.GROUP),
|
||||||
GROUP_UNSET_TEMP_META("unsettempmeta", "group"),
|
GROUP_INHERITSPERMISSION(set("inheritspermission"), Type.GROUP),
|
||||||
GROUP_CLEARMETA("clearmeta", "group"),
|
GROUP_SHOWTRACKS(set("showtracks"), Type.GROUP),
|
||||||
GROUP_BULKCHANGE("bulkchange", "group"),
|
GROUP_BULKCHANGE(set("bulkchange"), Type.GROUP),
|
||||||
GROUP_CLEAR("clear", "group"),
|
GROUP_CLEAR(set("clear"), Type.GROUP),
|
||||||
GROUP_RENAME("rename", "group"),
|
GROUP_RENAME(set("rename"), Type.GROUP),
|
||||||
GROUP_CLONE("clone", "group"),
|
GROUP_CLONE(set("clone"), Type.GROUP),
|
||||||
|
|
||||||
TRACK_INFO("info", "track"),
|
TRACK_INFO(set("info"), Type.TRACK),
|
||||||
TRACK_APPEND("append", "track"),
|
TRACK_APPEND(set("append"), Type.TRACK),
|
||||||
TRACK_INSERT("insert", "track"),
|
TRACK_INSERT(set("insert"), Type.TRACK),
|
||||||
TRACK_REMOVE("remove", "track"),
|
TRACK_REMOVE(set("remove"), Type.TRACK),
|
||||||
TRACK_CLEAR("clear", "track"),
|
TRACK_CLEAR(set("clear"), Type.TRACK),
|
||||||
TRACK_RENAME("rename", "track"),
|
TRACK_RENAME(set("rename"), Type.TRACK),
|
||||||
TRACK_CLONE("clone", "track"),
|
TRACK_CLONE(set("clone"), Type.TRACK),
|
||||||
|
|
||||||
LOG_RECENT("recent", "log"),
|
LOG_RECENT(set("recent"), Type.LOG),
|
||||||
LOG_USER_HISTORY("userhistory", "log"),
|
LOG_USER_HISTORY(set("userhistory"), Type.LOG),
|
||||||
LOG_GROUP_HISTORY("grouphistory", "log"),
|
LOG_GROUP_HISTORY(set("grouphistory"), Type.LOG),
|
||||||
LOG_TRACK_HISTORY("trackhistory", "log"),
|
LOG_TRACK_HISTORY(set("trackhistory"), Type.LOG),
|
||||||
LOG_SEARCH("search", "log"),
|
LOG_SEARCH(set("search"), Type.LOG),
|
||||||
LOG_NOTIFY("notify", "log"),
|
LOG_NOTIFY(set("notify"), Type.LOG),
|
||||||
LOG_EXPORT("export", "log"),
|
LOG_EXPORT(set("export"), Type.LOG),
|
||||||
|
|
||||||
MIGRATION("migration", null);
|
MIGRATION(set("migration"), Type.NONE);
|
||||||
|
|
||||||
private String tag;
|
private static final String IDENTIFIER = "luckperms.";
|
||||||
private String group;
|
|
||||||
|
|
||||||
public String getNode() {
|
private Set<String> nodes;
|
||||||
if (group != null) {
|
private Type type;
|
||||||
return "luckperms." + group + "." + tag;
|
|
||||||
|
Permission(Set<String> tags, Type type) {
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
if (type == Type.NONE) {
|
||||||
|
this.nodes = tags.stream().map(t -> IDENTIFIER + t).collect(ImmutableCollectors.toImmutableSet());
|
||||||
|
} else {
|
||||||
|
this.nodes = tags.stream().map(t -> IDENTIFIER + type.getTag() + "." + t).collect(ImmutableCollectors.toImmutableSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
return "luckperms." + tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return sender.hasPermission(this);
|
return sender.hasPermission(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Set<String> set(String... args) {
|
||||||
|
return Sets.newHashSet(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum Type {
|
||||||
|
|
||||||
|
NONE(null),
|
||||||
|
USER("user"),
|
||||||
|
GROUP("group"),
|
||||||
|
TRACK("track"),
|
||||||
|
LOG("log");
|
||||||
|
|
||||||
|
private final String tag;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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.utils;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class ImmutableCollectors {
|
||||||
|
|
||||||
|
public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) {
|
||||||
|
return Collector.of(
|
||||||
|
ImmutableMap.Builder<K, V>::new,
|
||||||
|
(r, t) -> r.put(keyMapper.apply(t), valueMapper.apply(t)),
|
||||||
|
(l, r) -> l.putAll(r.build()),
|
||||||
|
ImmutableMap.Builder::build,
|
||||||
|
Collector.Characteristics.UNORDERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() {
|
||||||
|
return Collector.of(
|
||||||
|
ImmutableSet.Builder<T>::new,
|
||||||
|
ImmutableSet.Builder<T>::add,
|
||||||
|
(l, r) -> l.addAll(r.build()),
|
||||||
|
ImmutableSet.Builder<T>::build,
|
||||||
|
Collector.Characteristics.UNORDERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toImmutableList() {
|
||||||
|
return Collector.of(
|
||||||
|
ImmutableList.Builder<T>::new,
|
||||||
|
ImmutableList.Builder<T>::add,
|
||||||
|
(l, r) -> l.addAll(r.build()),
|
||||||
|
ImmutableList.Builder<T>::build);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -200,7 +200,9 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Permission perm : Permission.values()) {
|
for (Permission perm : Permission.values()) {
|
||||||
registerPermission(p, perm.getNode());
|
for (String node : perm.getNodes()) {
|
||||||
|
registerPermission(p, node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user