Implement accumulation of static contexts from a file
This commit is contained in:
@@ -39,7 +39,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||
import me.lucko.luckperms.common.contexts.StaticCalculator;
|
||||
import me.lucko.luckperms.common.core.UuidCache;
|
||||
import me.lucko.luckperms.common.core.model.User;
|
||||
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
||||
@@ -265,7 +265,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
cachedStateManager = new CachedStateManager(this);
|
||||
|
||||
contextManager = new ContextManager<>();
|
||||
contextManager.registerCalculator(new ServerCalculator<>(configuration));
|
||||
contextManager.registerCalculator(new StaticCalculator<>(configuration));
|
||||
contextManager.registerCalculator(new WorldCalculator());
|
||||
|
||||
// register the PermissionService with Sponge
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.spongepowered.api.service.context.Context;
|
||||
import org.spongepowered.api.service.permission.Subject;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@AllArgsConstructor
|
||||
@@ -47,10 +46,4 @@ public class SpongeCalculatorLink implements ContextCalculator<Subject> {
|
||||
accumulator.addAll(Util.convertContexts(contexts));
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContextApplicable(Subject subject, Map.Entry<String, String> context) {
|
||||
Context c = new Context(context.getKey(), context.getValue());
|
||||
return calculator.matches(c, subject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.service.context.Context;
|
||||
import org.spongepowered.api.service.permission.Subject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class WorldCalculator implements ContextCalculator<Subject> {
|
||||
|
||||
@@ -49,15 +47,4 @@ public class WorldCalculator implements ContextCalculator<Subject> {
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContextApplicable(Subject subject, Map.Entry<String, String> context) {
|
||||
CommandSource source = subject.getCommandSource().orElse(null);
|
||||
if (source == null || !(source instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p = ((Player) source);
|
||||
return context.getKey().equals(Context.WORLD_KEY) && p.getWorld().getName().equals(context.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user