Add config option to disable built-in contexts

This commit is contained in:
Luck 2021-03-01 11:18:21 +00:00
parent bf0ac1a867
commit e7f2a8d713
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
17 changed files with 197 additions and 59 deletions

View File

@ -190,7 +190,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new BukkitContextManager(this);
BukkitPlayerCalculator playerCalculator = new BukkitPlayerCalculator(this);
BukkitPlayerCalculator playerCalculator = new BukkitPlayerCalculator(this, getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS));
this.bootstrap.getServer().getPluginManager().registerEvents(playerCalculator, this.bootstrap.getLoader());
this.contextManager.registerCalculator(playerCalculator);
}

View File

@ -51,6 +51,8 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
public class BukkitPlayerCalculator implements ContextCalculator<Player>, Listener {
private static final EnumNamer<GameMode> GAMEMODE_NAMER = new EnumNamer<>(
GameMode.class,
@ -69,41 +71,58 @@ public class BukkitPlayerCalculator implements ContextCalculator<Player>, Listen
private final LPBukkitPlugin plugin;
public BukkitPlayerCalculator(LPBukkitPlugin plugin) {
private final boolean gamemode;
private final boolean world;
private final boolean dimensionType;
public BukkitPlayerCalculator(LPBukkitPlugin plugin, Set<String> disabled) {
this.plugin = plugin;
this.gamemode = !disabled.contains(DefaultContextKeys.GAMEMODE_KEY);
this.world = !disabled.contains(DefaultContextKeys.WORLD_KEY);
this.dimensionType = !disabled.contains(DefaultContextKeys.DIMENSION_TYPE_KEY);
}
@SuppressWarnings("ConstantConditions") // bukkit lies
@Override
public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) {
GameMode mode = subject.getGameMode();
if (mode != null) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
if (this.gamemode) {
GameMode mode = subject.getGameMode();
if (mode != null) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
}
}
World world = subject.getWorld();
if (world != null) {
Environment environment = world.getEnvironment();
if (environment != null) {
if (this.dimensionType && environment != null) {
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, DIMENSION_TYPE_NAMER.name(environment));
}
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(world.getName(), consumer);
if (this.world) {
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(world.getName(), consumer);
}
}
}
@Override
public ContextSet estimatePotentialContexts() {
ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
for (GameMode mode : GameMode.values()) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
if (this.gamemode) {
for (GameMode mode : GameMode.values()) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
}
}
for (Environment env : Environment.values()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, DIMENSION_TYPE_NAMER.name(env));
if (this.dimensionType) {
for (Environment env : Environment.values()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, DIMENSION_TYPE_NAMER.name(env));
}
}
for (World world : this.plugin.getBootstrap().getServer().getWorlds()) {
String worldName = world.getName();
if (Context.isValidValue(worldName)) {
builder.add(DefaultContextKeys.WORLD_KEY, worldName);
if (this.world) {
for (World world : this.plugin.getBootstrap().getServer().getWorlds()) {
String worldName = world.getName();
if (Context.isValidValue(worldName)) {
builder.add(DefaultContextKeys.WORLD_KEY, worldName);
}
}
}
return builder.build();
@ -111,16 +130,22 @@ public class BukkitPlayerCalculator implements ContextCalculator<Player>, Listen
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldChange(PlayerChangedWorldEvent e) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
if (this.world || this.dimensionType) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoinWorld(PlayerJoinEvent e) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
if (this.world || this.dimensionType) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGameModeChange(PlayerGameModeChangeEvent e) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
if (this.gamemode) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
}
}
}

View File

@ -435,6 +435,11 @@ post-traversal-inheritance-sort: false
# entries in A are also in B.
context-satisfy-mode: at-least-one-value-per-key
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts:
# - "world"
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #

View File

@ -35,6 +35,7 @@ import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
@ -50,6 +51,7 @@ import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.context.DefaultContextKeys;
import net.luckperms.api.query.QueryOptions;
import net.md_5.bungee.api.plugin.Plugin;
@ -141,11 +143,14 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new BungeeContextManager(this);
BungeePlayerCalculator playerCalculator = new BungeePlayerCalculator(this);
this.bootstrap.getProxy().getPluginManager().registerListener(this.bootstrap.getLoader(), playerCalculator);
this.contextManager.registerCalculator(playerCalculator);
Set<String> disabledContexts = getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS);
if (!disabledContexts.contains(DefaultContextKeys.WORLD_KEY)) {
BungeePlayerCalculator playerCalculator = new BungeePlayerCalculator(this);
this.bootstrap.getProxy().getPluginManager().registerListener(this.bootstrap.getLoader(), playerCalculator);
this.contextManager.registerCalculator(playerCalculator);
}
if (this.bootstrap.getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
if (!disabledContexts.contains("proxy") && this.bootstrap.getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
this.contextManager.registerCalculator(new RedisBungeeCalculator());
}
}

View File

@ -443,6 +443,11 @@ post-traversal-inheritance-sort: false
# entries in A are also in B.
context-satisfy-mode: at-least-one-value-per-key
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts:
# - "world"
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #

View File

@ -130,6 +130,16 @@ public final class ConfigKeys {
return ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY;
});
/**
* A set of disabled contexts
*/
public static final ConfigKey<Set<String>> DISABLED_CONTEXTS = notReloadable(key(c -> {
return c.getStringList("disabled-contexts", ImmutableList.of())
.stream()
.map(String::toLowerCase)
.collect(ImmutableCollectors.toSet());
}));
/**
* # If the servers own UUID cache/lookup facility should be used when there is no record for a player in the LuckPerms cache.
*/

View File

@ -27,6 +27,7 @@ package me.lucko.luckperms.fabric;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
@ -141,7 +142,7 @@ public class LPFabricPlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new FabricContextManager(this);
FabricPlayerCalculator playerCalculator = new FabricPlayerCalculator(this);
FabricPlayerCalculator playerCalculator = new FabricPlayerCalculator(this, getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS));
playerCalculator.registerListeners();
this.contextManager.registerCalculator(playerCalculator);
}

View File

@ -46,6 +46,7 @@ import net.minecraft.world.GameMode;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
import java.util.Set;
public class FabricPlayerCalculator implements ContextCalculator<ServerPlayerEntity> {
private static final EnumNamer<GameMode> GAMEMODE_NAMER = new EnumNamer<>(
@ -55,8 +56,15 @@ public class FabricPlayerCalculator implements ContextCalculator<ServerPlayerEnt
private final LPFabricPlugin plugin;
public FabricPlayerCalculator(LPFabricPlugin plugin) {
private final boolean gamemode;
private final boolean world;
//private final boolean dimensionType;
public FabricPlayerCalculator(LPFabricPlugin plugin, Set<String> disabled) {
this.plugin = plugin;
this.gamemode = !disabled.contains(DefaultContextKeys.GAMEMODE_KEY);
this.world = !disabled.contains(DefaultContextKeys.WORLD_KEY);
//this.dimensionType = !disabled.contains(DefaultContextKeys.DIMENSION_TYPE_KEY);
}
public void registerListeners() {
@ -66,27 +74,31 @@ public class FabricPlayerCalculator implements ContextCalculator<ServerPlayerEnt
@Override
public void calculate(@NonNull ServerPlayerEntity target, @NonNull ContextConsumer consumer) {
GameMode mode = target.interactionManager.getGameMode();
if (mode != null && mode != GameMode.NOT_SET) {
if (this.gamemode && mode != null && mode != GameMode.NOT_SET) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
}
// TODO: figure out dimension type context too
ServerWorld world = target.getServerWorld();
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(getContextKey(world.getRegistryKey().getValue()), consumer);
if (this.world) {
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(getContextKey(world.getRegistryKey().getValue()), consumer);
}
}
@Override
public ContextSet estimatePotentialContexts() {
ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
for (GameMode mode : GameMode.values()) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
if (this.gamemode) {
for (GameMode mode : GameMode.values()) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
}
}
// TODO: dimension type
Optional<MinecraftServer> server = this.plugin.getBootstrap().getServer();
if (server.isPresent()) {
if (this.world && server.isPresent()) {
Iterable<ServerWorld> worlds = server.get().getWorlds();
for (ServerWorld world : worlds) {
String worldName = getContextKey(world.getRegistryKey().getValue());
@ -107,7 +119,9 @@ public class FabricPlayerCalculator implements ContextCalculator<ServerPlayerEnt
}
private void onWorldChange(ServerWorld origin, ServerWorld destination, ServerPlayerEntity player) {
this.plugin.getContextManager().invalidateCache(player);
if (this.world) {
this.plugin.getContextManager().invalidateCache(player);
}
}
}

View File

@ -446,6 +446,12 @@ post-traversal-inheritance-sort = false
# entries in A are also in B.
context-satisfy-mode = "at-least-one-value-per-key"
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts = [
# "world"
]
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #

View File

@ -148,7 +148,7 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new NukkitContextManager(this);
NukkitPlayerCalculator playerCalculator = new NukkitPlayerCalculator(this);
NukkitPlayerCalculator playerCalculator = new NukkitPlayerCalculator(this, getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS));
this.bootstrap.getServer().getPluginManager().registerEvents(playerCalculator, this.bootstrap.getLoader());
this.contextManager.registerCalculator(playerCalculator);
}

View File

@ -47,37 +47,59 @@ import cn.nukkit.event.entity.EntityLevelChangeEvent;
import cn.nukkit.event.player.PlayerGameModeChangeEvent;
import cn.nukkit.level.Level;
import java.util.Set;
public class NukkitPlayerCalculator implements ContextCalculator<Player>, Listener {
private static final int[] KNOWN_GAMEMODES = {Player.SURVIVAL, Player.CREATIVE, Player.ADVENTURE, Player.SPECTATOR};
private static final int[] KNOWN_DIMENSION_TYPES = {Level.DIMENSION_OVERWORLD, Level.DIMENSION_NETHER};
private final LPNukkitPlugin plugin;
public NukkitPlayerCalculator(LPNukkitPlugin plugin) {
private final boolean gamemode;
private final boolean world;
private final boolean dimensionType;
public NukkitPlayerCalculator(LPNukkitPlugin plugin, Set<String> disabled) {
this.plugin = plugin;
this.gamemode = !disabled.contains(DefaultContextKeys.GAMEMODE_KEY);
this.world = !disabled.contains(DefaultContextKeys.WORLD_KEY);
this.dimensionType = !disabled.contains(DefaultContextKeys.DIMENSION_TYPE_KEY);
}
@Override
public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) {
if (this.gamemode) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, getGamemodeName(subject.getGamemode()));
}
Level level = subject.getLevel();
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, getGamemodeName(subject.getGamemode()));
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getDimensionName(level.getDimension()));
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(level.getName(), consumer);
if (this.dimensionType) {
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getDimensionName(level.getDimension()));
}
if (this.world) {
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(level.getName(), consumer);
}
}
@Override
public ContextSet estimatePotentialContexts() {
ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
for (int mode : KNOWN_GAMEMODES) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, getGamemodeName(mode));
if (this.gamemode) {
for (int mode : KNOWN_GAMEMODES) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, getGamemodeName(mode));
}
}
for (int dim : KNOWN_DIMENSION_TYPES) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getDimensionName(dim));
if (this.dimensionType) {
for (int dim : KNOWN_DIMENSION_TYPES) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getDimensionName(dim));
}
}
for (Level world : this.plugin.getBootstrap().getServer().getLevels().values()) {
String worldName = world.getName();
if (Context.isValidValue(worldName)) {
builder.add(DefaultContextKeys.WORLD_KEY, worldName);
if (this.world) {
for (Level world : this.plugin.getBootstrap().getServer().getLevels().values()) {
String worldName = world.getName();
if (Context.isValidValue(worldName)) {
builder.add(DefaultContextKeys.WORLD_KEY, worldName);
}
}
}
return builder.build();
@ -104,7 +126,7 @@ public class NukkitPlayerCalculator implements ContextCalculator<Player>, Listen
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldChange(EntityLevelChangeEvent e) {
if (e.getEntity() instanceof Player) {
if ((this.world || this.dimensionType) && e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
this.plugin.getContextManager().signalContextUpdate(player);
}
@ -112,6 +134,8 @@ public class NukkitPlayerCalculator implements ContextCalculator<Player>, Listen
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGameModeChange(PlayerGameModeChangeEvent e) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
if (this.gamemode) {
this.plugin.getContextManager().signalContextUpdate(e.getPlayer());
}
}
}

View File

@ -430,6 +430,11 @@ post-traversal-inheritance-sort: false
# entries in A are also in B.
context-satisfy-mode: at-least-one-value-per-key
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts:
# - "world"
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #

View File

@ -29,6 +29,7 @@ import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.command.abstraction.Command;
import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
@ -155,7 +156,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new SpongeContextManager(this);
SpongePlayerCalculator playerCalculator = new SpongePlayerCalculator(this);
SpongePlayerCalculator playerCalculator = new SpongePlayerCalculator(this, getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS));
this.bootstrap.getGame().getEventManager().registerListeners(this.bootstrap, playerCalculator);
this.contextManager.registerCalculator(playerCalculator);
}

View File

@ -55,11 +55,20 @@ import org.spongepowered.api.world.DimensionType;
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.World;
import java.util.Set;
public class SpongePlayerCalculator implements ContextCalculator<Subject> {
private final LPSpongePlugin plugin;
public SpongePlayerCalculator(LPSpongePlugin plugin) {
private final boolean gamemode;
private final boolean world;
private final boolean dimensionType;
public SpongePlayerCalculator(LPSpongePlugin plugin, Set<String> disabled) {
this.plugin = plugin;
this.gamemode = !disabled.contains(DefaultContextKeys.GAMEMODE_KEY);
this.world = !disabled.contains(DefaultContextKeys.WORLD_KEY);
this.dimensionType = !disabled.contains(DefaultContextKeys.DIMENSION_TYPE_KEY);
}
@Override
@ -71,11 +80,15 @@ public class SpongePlayerCalculator implements ContextCalculator<Subject> {
if (source instanceof Locatable) {
World world = ((Locatable) source).getWorld();
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getCatalogTypeName(world.getDimension().getType()));
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(world.getName(), consumer);
if (this.dimensionType) {
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getCatalogTypeName(world.getDimension().getType()));
}
if (this.world) {
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(world.getName(), consumer);
}
}
if (source instanceof ValueContainer<?>) {
if (this.gamemode && source instanceof ValueContainer<?>) {
ValueContainer<?> valueContainer = (ValueContainer<?>) source;
valueContainer.get(Keys.GAME_MODE).ifPresent(mode -> consumer.accept(DefaultContextKeys.GAMEMODE_KEY, getCatalogTypeName(mode)));
}
@ -86,13 +99,17 @@ public class SpongePlayerCalculator implements ContextCalculator<Subject> {
ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
Game game = this.plugin.getBootstrap().getGame();
for (GameMode mode : game.getRegistry().getAllOf(CatalogTypes.GAME_MODE)) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, getCatalogTypeName(mode));
if (this.gamemode) {
for (GameMode mode : game.getRegistry().getAllOf(CatalogTypes.GAME_MODE)) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, getCatalogTypeName(mode));
}
}
for (DimensionType dim : game.getRegistry().getAllOf(CatalogTypes.DIMENSION_TYPE)) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getCatalogTypeName(dim));
if (this.dimensionType) {
for (DimensionType dim : game.getRegistry().getAllOf(CatalogTypes.DIMENSION_TYPE)) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getCatalogTypeName(dim));
}
}
if (game.isServerAvailable()) {
if (this.world && game.isServerAvailable()) {
for (World world : game.getServer().getWorlds()) {
String worldName = world.getName();
if (Context.isValidValue(worldName)) {
@ -114,6 +131,10 @@ public class SpongePlayerCalculator implements ContextCalculator<Subject> {
@Listener(order = Order.LAST)
public void onWorldChange(MoveEntityEvent.Teleport e) {
if (!(this.world || this.dimensionType)) {
return;
}
Entity targetEntity = e.getTargetEntity();
if (!(targetEntity instanceof Subject)) {
return;
@ -129,7 +150,7 @@ public class SpongePlayerCalculator implements ContextCalculator<Subject> {
@Listener(order = Order.LAST)
public void onGameModeChange(ChangeGameModeEvent e) {
Humanoid targetEntity = e.getTargetEntity();
if (targetEntity instanceof Subject) {
if (this.gamemode && targetEntity instanceof Subject) {
this.plugin.getContextManager().signalContextUpdate((Subject) targetEntity);
}
}

View File

@ -446,6 +446,12 @@ post-traversal-inheritance-sort = false
# entries in A are also in B.
context-satisfy-mode = "at-least-one-value-per-key"
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts = [
# "world"
]
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #

View File

@ -28,6 +28,7 @@ package me.lucko.luckperms.velocity;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
@ -49,6 +50,7 @@ import me.lucko.luckperms.velocity.listeners.VelocityConnectionListener;
import me.lucko.luckperms.velocity.messaging.VelocityMessagingFactory;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.context.DefaultContextKeys;
import net.luckperms.api.query.QueryOptions;
import java.util.Optional;
@ -133,9 +135,12 @@ public class LPVelocityPlugin extends AbstractLuckPermsPlugin {
protected void setupContextManager() {
this.contextManager = new VelocityContextManager(this);
VelocityPlayerCalculator playerCalculator = new VelocityPlayerCalculator(this);
this.bootstrap.getProxy().getEventManager().register(this.bootstrap, playerCalculator);
this.contextManager.registerCalculator(playerCalculator);
Set<String> disabledContexts = getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS);
if (!disabledContexts.contains(DefaultContextKeys.WORLD_KEY)) {
VelocityPlayerCalculator playerCalculator = new VelocityPlayerCalculator(this);
this.bootstrap.getProxy().getEventManager().register(this.bootstrap, playerCalculator);
this.contextManager.registerCalculator(playerCalculator);
}
}
@Override

View File

@ -434,6 +434,11 @@ post-traversal-inheritance-sort: false
# entries in A are also in B.
context-satisfy-mode: at-least-one-value-per-key
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts:
# - "world"
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #