From d75b29f51d9fae00d45d02d44cd9cce6426cbdc1 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 8 Nov 2017 15:48:55 +0000 Subject: [PATCH] Move a couple more methods around in the API --- .../java/me/lucko/luckperms/api/Group.java | 24 ------------------- .../lucko/luckperms/api/PermissionHolder.java | 23 ++++++++++++++++++ .../java/me/lucko/luckperms/api/User.java | 22 ----------------- .../common/api/delegates/model/ApiGroup.java | 11 --------- .../delegates/model/ApiPermissionHolder.java | 10 ++++++++ .../common/api/delegates/model/ApiUser.java | 12 ---------- 6 files changed, 33 insertions(+), 69 deletions(-) diff --git a/api/src/main/java/me/lucko/luckperms/api/Group.java b/api/src/main/java/me/lucko/luckperms/api/Group.java index b51302802..2e6bba30c 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Group.java +++ b/api/src/main/java/me/lucko/luckperms/api/Group.java @@ -25,8 +25,6 @@ package me.lucko.luckperms.api; -import me.lucko.luckperms.api.context.ContextSet; - import java.util.OptionalInt; import javax.annotation.Nonnull; @@ -44,28 +42,6 @@ public interface Group extends PermissionHolder { @Nonnull String getName(); - /** - * Check to see if a group inherits another group directly - * - * @param group The group to check membership of - * @return true if the group inherits the other group - * @throws NullPointerException if the group is null - * @throws IllegalStateException if the group instance was not obtained from LuckPerms. - */ - boolean inheritsGroup(@Nonnull Group group); - - /** - * Check to see if a group inherits another group directly - * - * @param group The group to check membership of - * @param contextSet the context set to filter by - * @return true if the group inherits the other group - * @throws NullPointerException if the group is null - * @throws IllegalStateException if the group instance was not obtained from LuckPerms. - * @since 3.2 - */ - boolean inheritsGroup(@Nonnull Group group, @Nonnull ContextSet contextSet); - /** * Gets the weight of this group, if present. * diff --git a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java index af3d0ce1e..ae9e745a5 100644 --- a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java +++ b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java @@ -284,6 +284,29 @@ public interface PermissionHolder { @Nonnull Tristate inheritsPermission(@Nonnull Node node); + /** + * Check to see if this holder inherits another group directly + * + * @param group The group to check membership of + * @return true if the group inherits the other group + * @throws NullPointerException if the group is null + * @throws IllegalStateException if the group instance was not obtained from LuckPerms. + * @since 4.0 + */ + boolean inheritsGroup(@Nonnull Group group); + + /** + * Check to see if this holder inherits another group directly + * + * @param group The group to check membership of + * @param contextSet the context set to filter by + * @return true if the group inherits the other group + * @throws NullPointerException if the group is null + * @throws IllegalStateException if the group instance was not obtained from LuckPerms. + * @since 4.0 + */ + boolean inheritsGroup(@Nonnull Group group, @Nonnull ContextSet contextSet); + /** * Sets a permission for the object * diff --git a/api/src/main/java/me/lucko/luckperms/api/User.java b/api/src/main/java/me/lucko/luckperms/api/User.java index 4d4a6e30b..95b01a8c6 100644 --- a/api/src/main/java/me/lucko/luckperms/api/User.java +++ b/api/src/main/java/me/lucko/luckperms/api/User.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.api; import me.lucko.luckperms.api.caching.UserData; -import me.lucko.luckperms.api.context.ContextSet; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -96,27 +95,6 @@ public interface User extends PermissionHolder { @Nonnull CompletableFuture refreshCachedData(); - /** - * Check to see if the user is a direct member of a group - * - * @param group The group to check membership of - * @return true if the user is a member of the group - * @throws NullPointerException if the group is null - * @throws IllegalStateException if the group instance was not obtained from LuckPerms. - */ - boolean isInGroup(@Nonnull Group group); - - /** - * Check to see if the user is a direct member of a group in a specific context - * - * @param group the group to check membership of - * @param contextSet the context set to filter by - * @return true if the user is a member of the group - * @throws IllegalStateException if the group instance was not obtained from LuckPerms. - * @since 3.2 - */ - boolean isInGroup(@Nonnull Group group, @Nonnull ContextSet contextSet); - /** * Refresh and re-assign the users permissions. * diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java index 448656e21..26bad1eca 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java @@ -32,7 +32,6 @@ import lombok.NonNull; import com.google.common.base.Preconditions; import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.context.ContextSet; import java.util.OptionalInt; @@ -55,16 +54,6 @@ public final class ApiGroup extends ApiPermissionHolder implements Group { return handle.getName(); } - @Override - public boolean inheritsGroup(@NonNull Group group) { - return handle.inheritsGroup(cast(group)); - } - - @Override - public boolean inheritsGroup(@NonNull Group group, @NonNull ContextSet contextSet) { - return handle.inheritsGroup(cast(group), contextSet); - } - @Override public OptionalInt getWeight() { return handle.getWeight(); diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java index fe4aaa7c6..b2636570d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java @@ -136,6 +136,16 @@ public class ApiPermissionHolder implements PermissionHolder { return handle.inheritsPermission(node); } + @Override + public boolean inheritsGroup(@NonNull me.lucko.luckperms.api.Group group) { + return handle.inheritsGroup(ApiGroup.cast(group)); + } + + @Override + public boolean inheritsGroup(@NonNull me.lucko.luckperms.api.Group group, @NonNull ContextSet contextSet) { + return handle.inheritsGroup(ApiGroup.cast(group), contextSet); + } + @Override public DataMutateResult setPermission(@NonNull Node node) { return handle.setPermission(node); diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java index 1c586be74..78e5f91e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java @@ -31,10 +31,8 @@ import lombok.NonNull; import com.google.common.base.Preconditions; import me.lucko.luckperms.api.DataMutateResult; -import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.caching.UserData; -import me.lucko.luckperms.api.context.ContextSet; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -92,16 +90,6 @@ public final class ApiUser extends ApiPermissionHolder implements User { return handle.getRefreshBuffer().request(); } - @Override - public boolean isInGroup(@NonNull Group group) { - return handle.inheritsGroup(ApiGroup.cast(group)); - } - - @Override - public boolean isInGroup(@NonNull Group group, @NonNull ContextSet contextSet) { - return handle.inheritsGroup(ApiGroup.cast(group), contextSet); - } - @Override @Deprecated public void refreshPermissions() {