From c28b1949a99e2be5d50f8c3d5f55bb3e95790770 Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 18 Dec 2020 19:17:01 +0000 Subject: [PATCH] Process 'give default if needed' when saving instead of after each change made in the API (#2775) --- .../common/api/implementation/ApiPermissionHolder.java | 8 ++++---- .../common/api/implementation/ApiUserManager.java | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java index d980f64e7..e35e5c086 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java @@ -222,7 +222,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo @Override public void clear() { - if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, true)) { + if (ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, false)) { onNodeChange(); } } @@ -230,7 +230,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo @Override public void clear(@NonNull Predicate 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(); } } @@ -239,7 +239,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo @Override public void clear(@NonNull 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(); } } @@ -248,7 +248,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo public void clear(@NonNull ContextSet contextSet, @NonNull Predicate test) { Objects.requireNonNull(contextSet, "contextSet"); 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(); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUserManager.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUserManager.java index ad774bc03..e4d6b74f4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUserManager.java @@ -90,8 +90,9 @@ public class ApiUserManager extends ApiAbstractManager saveUser(net.luckperms.api.model.user.@NonNull User user) { - Objects.requireNonNull(user, "user"); - return this.plugin.getStorage().saveUser(ApiUser.cast(user)); + User internal = ApiUser.cast(Objects.requireNonNull(user, "user")); + this.plugin.getUserManager().giveDefaultIfNeeded(internal); + return this.plugin.getStorage().saveUser(internal); } @Override