diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java index ade70224..73a4f327 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java @@ -85,6 +85,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject { } } - return Tristate.UNDEFINED; + + return service.getDefaults().getPermissionValue(contexts, permission); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/GroupCollection.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/GroupCollection.java index 0d616829..615c012d 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/GroupCollection.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/GroupCollection.java @@ -26,7 +26,7 @@ import lombok.AllArgsConstructor; import lombok.NonNull; import me.lucko.luckperms.api.sponge.LuckPermsService; import me.lucko.luckperms.api.sponge.LuckPermsSubject; -import me.lucko.luckperms.api.sponge.simple.SimpleSubject; +import me.lucko.luckperms.api.sponge.simple.SimpleCollection; import me.lucko.luckperms.groups.GroupManager; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.PermissionService; @@ -42,6 +42,7 @@ import java.util.stream.Collectors; public class GroupCollection implements SubjectCollection { private final LuckPermsService service; private final GroupManager manager; + private final SimpleCollection fallback = new SimpleCollection(service, "fallback-groups"); @Override public String getIdentifier() { @@ -54,7 +55,7 @@ public class GroupCollection implements SubjectCollection { return LuckPermsSubject.wrapHolder(manager.get(id), service); } - return new SimpleSubject(id, service, this); + return fallback.get(id); } @Override @@ -84,6 +85,6 @@ public class GroupCollection implements SubjectCollection { @Override public Subject getDefaults() { - return new SimpleSubject("default", service, this); + return service.getDefaults(); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/UserCollection.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/UserCollection.java index c7677857..11091e5c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/UserCollection.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/collections/UserCollection.java @@ -27,6 +27,7 @@ import lombok.Getter; import lombok.NonNull; import me.lucko.luckperms.api.sponge.LuckPermsService; import me.lucko.luckperms.api.sponge.LuckPermsUserSubject; +import me.lucko.luckperms.api.sponge.simple.SimpleCollection; import me.lucko.luckperms.api.sponge.simple.SimpleSubject; import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.UserManager; @@ -46,6 +47,7 @@ import java.util.stream.Collectors; public class UserCollection implements SubjectCollection { private final LuckPermsService service; private final UserManager manager; + private final SimpleCollection fallback = new SimpleCollection(service, "fallback-users"); @Getter private final Map users = new ConcurrentHashMap<>(); @@ -93,7 +95,7 @@ public class UserCollection implements SubjectCollection { // What am I meant to do here? What if no user is loaded? Load it? Create it? // If I do load/create it, this method should always be called async??.... errr. - return new SimpleSubject(id, service, this); + return fallback.get(id); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/simple/SimpleCollection.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/simple/SimpleCollection.java index 2b07019b..ec8549aa 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/simple/SimpleCollection.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/simple/SimpleCollection.java @@ -47,7 +47,7 @@ public class SimpleCollection implements SubjectCollection { private final Map subjects = new ConcurrentHashMap<>(); @Override - public Subject get(@NonNull String id) { + public synchronized Subject get(@NonNull String id) { if (!subjects.containsKey(id)) { subjects.put(id, new SimpleSubject(id, service, this)); }