Actually apply default permissions on Sponge

This commit is contained in:
Luck 2016-09-15 16:53:03 +01:00
parent feb8bf4bd3
commit 831e882db0
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 10 additions and 6 deletions

View File

@ -85,6 +85,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject {
}
}
return Tristate.UNDEFINED;
return service.getDefaults().getPermissionValue(contexts, permission);
}
}

View File

@ -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();
}
}

View File

@ -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<UUID, LuckPermsUserSubject> 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

View File

@ -47,7 +47,7 @@ public class SimpleCollection implements SubjectCollection {
private final Map<String, Subject> 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));
}