Process 'give default if needed' when saving instead of after each change made in the API (#2775)

This commit is contained in:
Luck 2020-12-18 19:17:01 +00:00
parent 8ef871f6db
commit c28b1949a9
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 7 additions and 6 deletions

View File

@ -222,7 +222,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
@Override @Override
public void clear() { public void clear() {
if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, true)) { if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, false)) {
onNodeChange(); onNodeChange();
} }
} }
@ -230,7 +230,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
@Override @Override
public void clear(@NonNull Predicate<? super Node> test) { public void clear(@NonNull Predicate<? super Node> test) {
Objects.requireNonNull(test, "test"); Objects.requireNonNull(test, "test");
if (ApiPermissionHolder.this.handle.removeIf(this.dataType, null, test, true)) { if (ApiPermissionHolder.this.handle.removeIf(this.dataType, null, test, false)) {
onNodeChange(); onNodeChange();
} }
} }
@ -239,7 +239,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
@Override @Override
public void clear(@NonNull ContextSet contextSet) { public void clear(@NonNull ContextSet contextSet) {
Objects.requireNonNull(contextSet, "contextSet"); Objects.requireNonNull(contextSet, "contextSet");
if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, contextSet, true)) { if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, contextSet, false)) {
onNodeChange(); onNodeChange();
} }
} }
@ -248,7 +248,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
public void clear(@NonNull ContextSet contextSet, @NonNull Predicate<? super Node> test) { public void clear(@NonNull ContextSet contextSet, @NonNull Predicate<? super Node> test) {
Objects.requireNonNull(contextSet, "contextSet"); Objects.requireNonNull(contextSet, "contextSet");
Objects.requireNonNull(test, "test"); Objects.requireNonNull(test, "test");
if (ApiPermissionHolder.this.handle.removeIf(this.dataType, contextSet, test, true)) { if (ApiPermissionHolder.this.handle.removeIf(this.dataType, contextSet, test, false)) {
onNodeChange(); onNodeChange();
} }
} }

View File

@ -90,8 +90,9 @@ public class ApiUserManager extends ApiAbstractManager<User, net.luckperms.api.m
@Override @Override
public @NonNull CompletableFuture<Void> saveUser(net.luckperms.api.model.user.@NonNull User user) { public @NonNull CompletableFuture<Void> saveUser(net.luckperms.api.model.user.@NonNull User user) {
Objects.requireNonNull(user, "user"); User internal = ApiUser.cast(Objects.requireNonNull(user, "user"));
return this.plugin.getStorage().saveUser(ApiUser.cast(user)); this.plugin.getUserManager().giveDefaultIfNeeded(internal);
return this.plugin.getStorage().saveUser(internal);
} }
@Override @Override