Abstract out the process of traversing the inheritance tree, add configurable option to choose which algorithm to use (#719)

This commit is contained in:
Luck
2018-02-16 17:46:17 +00:00
Unverified
parent f1047df98e
commit 0adf85746d
22 changed files with 808 additions and 295 deletions
@@ -51,6 +51,7 @@ import me.lucko.luckperms.common.dependencies.DependencyRegistry;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
import me.lucko.luckperms.common.event.EventFactory;
import me.lucko.luckperms.common.inheritance.InheritanceHandler;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.locale.NoopLocaleManager;
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
@@ -179,6 +180,7 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin {
private LocaleManager localeManager;
private PluginClassLoader pluginClassLoader;
private DependencyManager dependencyManager;
private InheritanceHandler inheritanceHandler;
private CachedStateManager cachedStateManager;
private ContextManager<Subject> contextManager;
private CalculatorFactory calculatorFactory;
@@ -242,6 +244,7 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin {
// load internal managers
getLog().info("Loading internal permission managers...");
this.inheritanceHandler = new InheritanceHandler(this);
this.userManager = new SpongeUserManager(this);
this.groupManager = new SpongeGroupManager(this);
this.trackManager = new StandardTrackManager(this);
@@ -609,6 +612,11 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin {
return this.contextManager;
}
@Override
public InheritanceHandler getInheritanceHandler() {
return this.inheritanceHandler;
}
@Override
public CalculatorFactory getCalculatorFactory() {
return this.calculatorFactory;
@@ -376,7 +376,7 @@ public class LuckPermsSubjectData implements LPSubjectData {
toRemove.forEach(makeUnsetConsumer(this.enduring));
MetaAccumulator metaAccumulator = this.holder.accumulateMeta(null, null, this.service.getPlugin().getContextManager().formContexts(contexts));
MetaAccumulator metaAccumulator = this.holder.accumulateMeta(null, this.service.getPlugin().getContextManager().formContexts(contexts));
int priority = metaAccumulator.getChatMeta(type).keySet().stream().mapToInt(e -> e).max().orElse(0);
priority += 10;
+12
View File
@@ -128,6 +128,18 @@ apply-sponge-implicit-wildcards=true
# false, LuckPerms will ignore this data when considering if a player has a permission.
apply-sponge-default-subjects=true
# The algorithm LuckPerms should use when traversing the "inheritance tree".
#
# The valid options are:
# - breadth-first
# - depth-first-pre-order
# - depth-first-post-order
#
# See here for information about the differences between each algorithm.
# - https://en.wikipedia.org/wiki/Breadth-first_search
# - https://en.wikipedia.org/wiki/Depth-first_search
inheritance-traversal-algorithm="depth-first-pre-order"
# Define special group weights for this server.
# Default is just 0.
group-weight {