Implement default assignment system (#25)

This commit is contained in:
Luck
2016-10-16 13:58:57 +01:00
Unverified
parent 02a75fc32a
commit 13fbc7dd39
12 changed files with 578 additions and 54 deletions
@@ -34,6 +34,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -97,9 +98,33 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
return getNode(path).getBoolean(def);
}
@Override
protected List<String> getList(String path, List<String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getList(Object::toString);
}
@Override
protected List<String> getObjectList(String path, List<String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getChildrenList().stream().map(n -> (String) n.getKey()).collect(Collectors.toList());
}
@Override
protected Map<String, String> getMap(String path, Map<String, String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getChildrenList().stream().collect(Collectors.toMap(n -> (String) n.getKey(), ConfigurationNode::getString));
}
}
+107 -22
View File
@@ -5,6 +5,10 @@
# +------------------------------------------------------------------------+ #
##############################################################################
# +------------------------------------------------------------------------+ #
# | General | #
# +------------------------------------------------------------------------+ #
# The name of the server, used for server specific permissions. Set to 'global' to disable.
server="global"
@@ -24,17 +28,42 @@ apply-global-world-groups=true
# If this server is in offline or online mode.
# This setting allows a player to have the same UUID across a network of offline mode/mixed servers.
#
# You should generally reflect the setting in server.properties here. Except when...
# 1. You have Spigot servers connected to a BungeeCord proxy, with online-mode set to false, but 'bungeecord' set to
# true in the spigot.yml AND 'ip-forward' set to true in the BungeeCord config.yml
#
# 1. You have Sponge servers connected to a BungeeCord proxy, with online-mode set to false, but 'bungeecord ip-forwarding'
# set to true in the sponge/global.conf AND 'ip-forward' set to true in the BungeeCord config.yml
# In this case, set online-mode in LuckPerms to true, despite the server being in offline mode.
#
# 2. You are only running one server instance using LuckPerms, (not a network) In this case, set online-mode to true no
# matter what is set in server.properties. (we can just fallback to the servers uuid cache)
online-mode=true
# If the plugin should send log notifications to users whenever permissions are modified.
log-notify=true
# If LuckPerms should print to console every time a plugin checks if a player has a permission
debug-permission-checks=false
# Mirrors world names. Whenever LuckPerms checks what world a user is in, if the world name is in this list, the value assigned
# will be sent forward for permission calculation instead.
world-rewrite {
# world_nether="world"
# world_the_end="world"
}
# Rewrites group names. The underlying name of the group does not change, just the output in commands / placeholders / Vault.
group-name-rewrite {
# default="Member"
}
# +------------------------------------------------------------------------+ #
# | Permission Calculation | #
# +------------------------------------------------------------------------+ #
# If the plugin should apply wildcard permissions.
# If set to true, LuckPerms will detect wildcard permissions, and resolve & apply all registered permissions matching
# the wildcard.
@@ -49,23 +78,12 @@ apply-regex=true
# If set to true, LuckPerms will detect and expand shorthand node patterns.
apply-shorthand=true
# If LuckPerms should print to console every time a plugin checks if a player has a permission
debug-permission-checks=false
# If the plugin should send log notifications to users whenever permissions are modified.
log-notify=true
# Mirrors world names. Whenever LuckPerms checks what world a user is in, if the world name is in this list, the value assigned
# will be sent forward for permission calculation instead.
world-rewrite: {
#world_nether="world"
#world_the_end="world"
}
# Rewrites group names. The underlying name of the group does not change, just the output in commands / placeholders / Vault.
group-name-rewrite: {
#default: "Member"
}
# +------------------------------------------------------------------------+ #
# | Storage | #
# +------------------------------------------------------------------------+ #
# Which storage method the plugin should use.
# Currently supported: mysql, sqlite, h2, json, yaml, mongodb
@@ -73,9 +91,9 @@ group-name-rewrite: {
storage-method="h2"
# This block enables support for split datastores.
split-storage: {
split-storage {
enabled=false
methods: {
methods {
user="h2"
group="h2"
track="h2"
@@ -84,7 +102,7 @@ split-storage: {
}
}
data: {
data {
address="localhost:3306"
database="minecraft"
username="root"
@@ -94,3 +112,70 @@ data: {
# e.g. if you're using sqlite or flatfile, this can be set to -1 to save resources.
sync-minutes=3
}
# +------------------------------------------------------------------------+ #
# | Default Assignments | #
# +------------------------------------------------------------------------+ #
# This section allows you to define defaults to give users whenever they connect to the server.
# The default assignments are highly configurable and conditional.
#
# There is one default assignment built into LuckPerms, which will add all users to the "default" group if they
# are not a member of any other group. This setting cannot be disabled. However, you can use this section to add more of
# your own.
#
# IMPORTANT:
# In order to save storage space, LuckPerms does not store users who have no permissions defined, and are only a member
# of the default group. Adding default assignments to this section will negate this effect. It is HIGHLY RECCOMENDED
# that instead of assigning defaults here, you add permissions to the "default" group, or set the "default" group to inherit
# other groups, and then use the group-name-rewrite rule above.
#
# It is also important to note that these rules are considered every time a player logs into the server, and are applied
# directly to the user's data. Simply removing a rule here will not reserse the effect of that rule on any users who have
# already had it applied to them.
#
# The "has" and "lacks" conditions below support standard boolean logic, using the 'and' & 'or' characters used in Java.
# e.g. "(some.other.permission | some.permission.other) & some.thing.else" == a user has 'some.other.permission', or
# 'some.permission.other', and they also have 'some.thing.else'
#
# Groups are represented by the permission node: group.<group name>
# Per server and per world nodes are represented by: "server-world/permission" or "server/permission"
#
# Within conditions, permission nodes MUST be escaped using "<" and ">". See the example below.
#
# Explaination of the examples below: (they're just to demonstrate the features & use cases)
#
# rule1:
# If a user is either in the vip or vip+ group, and they have the "titles.titlecollector" permission set to true, and the
# "some.random.permission" set to false... if they're not in the group "prison_titlepack" on the "prison" server, then
# give add them to the "prison_titlepack" group on the "prison" server, and remove "some.random.permission".
#
# rule2:
# If the user isn't in any of the following groups on the skyblock server: sb_level1, sb_level2, sb_level3, then add
# them to sb_level1 on the skyblock server.
default-assignments {
# rule1 {
# if {
# has-true="(<group.vip> | <group.vip+>) & <titles.tilecollector>"
# has-false="<some.random.permission>"
# lacks="<prison/group.prison_titlepack>"
# }
# give = [
# "prison/group.prison_titlepack"
# ]
# take = [
# "some.random.permission"
# ]
# }
# rule2 {
# if {
# lacks="<skyblock/group.sb_level1> & <skyblock/group.sb_level2> & <skyblock/group.sb_level3>"
# }
# give = [
# "skyblock/group.sb_level1"
# ]
# }
}