Reduce the number of config lookups required when calculating contexts
This commit is contained in:
+5
-4
@@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.common.api.delegates.misc;
|
||||
|
||||
import me.lucko.luckperms.api.LPConfiguration;
|
||||
import me.lucko.luckperms.api.LookupSetting;
|
||||
import me.lucko.luckperms.common.config.ConfigKey;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||
@@ -52,22 +53,22 @@ public class ApiConfiguration implements LPConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean getIncludeGlobalPerms() {
|
||||
return this.handle.get(ConfigKeys.INCLUDING_GLOBAL_PERMS);
|
||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIncludeGlobalWorldPerms() {
|
||||
return this.handle.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS);
|
||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getApplyGlobalGroups() {
|
||||
return this.handle.get(ConfigKeys.APPLYING_GLOBAL_GROUPS);
|
||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getApplyGlobalWorldGroups() {
|
||||
return this.handle.get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS);
|
||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -28,6 +28,9 @@ package me.lucko.luckperms.common.config;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.LookupSetting;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
import me.lucko.luckperms.common.assignments.AssignmentRule;
|
||||
import me.lucko.luckperms.common.config.keys.AbstractKey;
|
||||
@@ -53,6 +56,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -89,24 +93,19 @@ public class ConfigKeys {
|
||||
}));
|
||||
|
||||
/**
|
||||
* If permissions without a server context should be included.
|
||||
* The lookup settings for contexts (care should be taken to not mutate this method)
|
||||
*/
|
||||
public static final ConfigKey<Boolean> INCLUDING_GLOBAL_PERMS = BooleanKey.of("include-global", true);
|
||||
|
||||
/**
|
||||
* If permissions without a world context should be included.
|
||||
*/
|
||||
public static final ConfigKey<Boolean> INCLUDING_GLOBAL_WORLD_PERMS = BooleanKey.of("include-global-world", true);
|
||||
|
||||
/**
|
||||
* If groups without a server context should be included.
|
||||
*/
|
||||
public static final ConfigKey<Boolean> APPLYING_GLOBAL_GROUPS = BooleanKey.of("apply-global-groups", true);
|
||||
|
||||
/**
|
||||
* If groups without a world context should be included.
|
||||
*/
|
||||
public static final ConfigKey<Boolean> APPLYING_GLOBAL_WORLD_GROUPS = BooleanKey.of("apply-global-world-groups", true);
|
||||
public static final ConfigKey<EnumSet<LookupSetting>> LOOKUP_SETTINGS = AbstractKey.of(c -> {
|
||||
return EnumSet.copyOf(Contexts.of(
|
||||
ContextSet.empty(),
|
||||
c.getBoolean("include-global", true),
|
||||
c.getBoolean("include-global-world", true),
|
||||
true,
|
||||
c.getBoolean("apply-global-groups", true),
|
||||
c.getBoolean("apply-global-world-groups", true),
|
||||
false
|
||||
).getSettings());
|
||||
});
|
||||
|
||||
/**
|
||||
* # If the servers own UUID cache/lookup facility should be used when there is no record for a player in the LuckPerms cache.
|
||||
|
||||
@@ -140,15 +140,7 @@ public abstract class AbstractContextManager<T> implements ContextManager<T> {
|
||||
|
||||
@Override
|
||||
public Contexts formContexts(ImmutableContextSet contextSet) {
|
||||
return Contexts.of(
|
||||
contextSet,
|
||||
this.plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||
this.plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||
true,
|
||||
this.plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||
this.plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||
false
|
||||
);
|
||||
return Contexts.of(contextSet, this.plugin.getConfiguration().get(ConfigKeys.LOOKUP_SETTINGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user