Separate PermissionProcessor into own class
This commit is contained in:
parent
6ffa6720be
commit
cff1b8a411
@ -28,6 +28,7 @@ import lombok.NonNull;
|
|||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
import me.lucko.luckperms.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.utils.PermissionCalculator;
|
import me.lucko.luckperms.utils.PermissionCalculator;
|
||||||
|
import me.lucko.luckperms.utils.PermissionProcessor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.*;
|
import org.bukkit.permissions.*;
|
||||||
@ -58,7 +59,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
super(sender);
|
super(sender);
|
||||||
this.parent = sender;
|
this.parent = sender;
|
||||||
|
|
||||||
List<PermissionCalculator.PermissionProcessor> processors = new ArrayList<>(4);
|
List<PermissionProcessor> processors = new ArrayList<>(4);
|
||||||
processors.add(new PermissionCalculator.MapProcessor(luckPermsPermissions));
|
processors.add(new PermissionCalculator.MapProcessor(luckPermsPermissions));
|
||||||
processors.add(new AttachmentProcessor(attachmentPermissions));
|
processors.add(new AttachmentProcessor(attachmentPermissions));
|
||||||
processors.add(new PermissionCalculator.WildcardProcessor(luckPermsPermissions));
|
processors.add(new PermissionCalculator.WildcardProcessor(luckPermsPermissions));
|
||||||
@ -264,7 +265,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private static class AttachmentProcessor implements PermissionCalculator.PermissionProcessor {
|
private static class AttachmentProcessor implements PermissionProcessor {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, PermissionAttachmentInfo> map;
|
private final Map<String, PermissionAttachmentInfo> map;
|
||||||
@ -281,7 +282,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private static class BukkitDefaultsProcessor implements PermissionCalculator.PermissionProcessor {
|
private static class BukkitDefaultsProcessor implements PermissionProcessor {
|
||||||
private final Supplier<Boolean> isOp;
|
private final Supplier<Boolean> isOp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,6 +24,7 @@ package me.lucko.luckperms;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lucko.luckperms.utils.PermissionCalculator;
|
import me.lucko.luckperms.utils.PermissionCalculator;
|
||||||
|
import me.lucko.luckperms.utils.PermissionProcessor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -38,7 +39,7 @@ public class BungeePlayerCache {
|
|||||||
private final Map<String, Boolean> permissions = new ConcurrentHashMap<>();
|
private final Map<String, Boolean> permissions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public BungeePlayerCache(LuckPermsPlugin plugin, String name) {
|
public BungeePlayerCache(LuckPermsPlugin plugin, String name) {
|
||||||
List<PermissionCalculator.PermissionProcessor> processors = new ArrayList<>(2);
|
List<PermissionProcessor> processors = new ArrayList<>(2);
|
||||||
processors.add(new PermissionCalculator.MapProcessor(permissions));
|
processors.add(new PermissionCalculator.MapProcessor(permissions));
|
||||||
processors.add(new PermissionCalculator.WildcardProcessor(permissions));
|
processors.add(new PermissionCalculator.WildcardProcessor(permissions));
|
||||||
|
|
||||||
|
@ -135,9 +135,4 @@ public class PermissionCalculator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PermissionProcessor {
|
|
||||||
Tristate hasPermission(String permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.utils;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Tristate;
|
||||||
|
|
||||||
|
public interface PermissionProcessor {
|
||||||
|
|
||||||
|
Tristate hasPermission(String permission);
|
||||||
|
|
||||||
|
}
|
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.sponge;
|
package me.lucko.luckperms.api.sponge;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
import me.lucko.luckperms.utils.PermissionCalculator;
|
import me.lucko.luckperms.utils.PermissionCalculator;
|
||||||
|
import me.lucko.luckperms.utils.PermissionProcessor;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
@ -54,7 +54,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject {
|
|||||||
super(user, service);
|
super(user, service);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
List<PermissionCalculator.PermissionProcessor> processors = new ArrayList<>(4);
|
List<PermissionProcessor> processors = new ArrayList<>(4);
|
||||||
processors.add(new PermissionCalculator.MapProcessor(permissionCache));
|
processors.add(new PermissionCalculator.MapProcessor(permissionCache));
|
||||||
processors.add(new SpongeWildcardProcessor(permissionCache));
|
processors.add(new SpongeWildcardProcessor(permissionCache));
|
||||||
processors.add(new PermissionCalculator.WildcardProcessor(permissionCache));
|
processors.add(new PermissionCalculator.WildcardProcessor(permissionCache));
|
||||||
@ -95,9 +95,8 @@ public class LuckPermsUserSubject extends LuckPermsSubject {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO proper implementation.
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class SpongeWildcardProcessor implements PermissionCalculator.PermissionProcessor {
|
private static class SpongeWildcardProcessor implements PermissionProcessor {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, Boolean> map;
|
private final Map<String, Boolean> map;
|
||||||
@ -148,7 +147,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private static class SpongeDefaultsProcessor implements PermissionCalculator.PermissionProcessor {
|
private static class SpongeDefaultsProcessor implements PermissionProcessor {
|
||||||
private final LuckPermsService service;
|
private final LuckPermsService service;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user