use of org.lanternpowered.server.service.permission.base.LanternSubjectCollection in project LanternServer by LanternPowered.
the class SubjectSettingCallback method apply.
static boolean apply(@Nullable ProxySubject ref, @Nullable PermissionService input) {
if (ref == null) {
// as a listener, and will not be tested again.
return false;
}
// if PS has just been unregistered, ignore the change.
if (input == null) {
return true;
}
final SubjectReference subject;
// we can skip some unnecessary instance creation this way.
if (input instanceof LanternPermissionService) {
final LanternPermissionService service = (LanternPermissionService) input;
final LanternSubjectCollection collection = service.get(ref.getSubjectCollectionIdentifier());
subject = collection.get(ref.getIdentifier()).asSubjectReference();
} else {
// build a new subject reference using the permission service
// this doesn't actually load the subject, so it will be lazily init'd when needed.
subject = input.newSubjectReference(ref.getSubjectCollectionIdentifier(), ref.getIdentifier());
}
ref.setInternalSubject(subject);
return true;
}
Aggregations