diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/GroupDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/GroupDelegate.java index cb6a326b..9a26f297 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/GroupDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/GroupDelegate.java @@ -23,7 +23,6 @@ package me.lucko.luckperms.common.api.delegates; import lombok.AccessLevel; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -40,19 +39,19 @@ import static me.lucko.luckperms.common.api.ApiUtils.checkTime; /** * Provides a link between {@link Group} and {@link me.lucko.luckperms.common.core.model.Group} */ -@EqualsAndHashCode(of = {"name"}, callSuper = false) -public class GroupDelegate extends PermissionHolderDelegate implements Group { +public final class GroupDelegate extends PermissionHolderDelegate implements Group { @Getter(AccessLevel.PACKAGE) private final me.lucko.luckperms.common.core.model.Group master; - @Getter - private final String name; - public GroupDelegate(@NonNull me.lucko.luckperms.common.core.model.Group master) { super(master); this.master = master; - this.name = master.getName(); + } + + @Override + public String getName() { + return master.getName(); } @Override @@ -169,4 +168,16 @@ public class GroupDelegate extends PermissionHolderDelegate implements Group { public List getLocalGroups(@NonNull String server) { return master.getLocalGroups(server); } + + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof GroupDelegate)) return false; + + GroupDelegate other = (GroupDelegate) o; + return this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()); + } + + public int hashCode() { + return this.getName().hashCode(); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/PermissionHolderDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/PermissionHolderDelegate.java index accf3d76..28e8aab7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/PermissionHolderDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/PermissionHolderDelegate.java @@ -49,7 +49,6 @@ import static me.lucko.luckperms.common.api.ApiUtils.checkTime; /** * Provides a link between {@link PermissionHolder} and {@link me.lucko.luckperms.common.core.model.PermissionHolder} */ -@SuppressWarnings("unused") @AllArgsConstructor public class PermissionHolderDelegate implements PermissionHolder { private final me.lucko.luckperms.common.core.model.PermissionHolder master; diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/TrackDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/TrackDelegate.java index ba36f740..a4aa598e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/TrackDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/TrackDelegate.java @@ -23,7 +23,7 @@ package me.lucko.luckperms.common.api.delegates; import lombok.AccessLevel; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; @@ -39,18 +39,15 @@ import static me.lucko.luckperms.common.api.ApiUtils.checkGroup; /** * Provides a link between {@link Track} and {@link me.lucko.luckperms.common.core.model.Track} */ -@EqualsAndHashCode(of = {"name"}) -public class TrackDelegate implements Track { +@AllArgsConstructor +public final class TrackDelegate implements Track { @Getter(AccessLevel.PACKAGE) private final me.lucko.luckperms.common.core.model.Track master; - @Getter - private final String name; - - public TrackDelegate(@NonNull me.lucko.luckperms.common.core.model.Track master) { - this.master = master; - this.name = master.getName(); + @Override + public String getName() { + return master.getName(); } @Override @@ -113,4 +110,16 @@ public class TrackDelegate implements Track { public void clearGroups() { master.clearGroups(); } + + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof TrackDelegate)) return false; + + TrackDelegate other = (TrackDelegate) o; + return this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()); + } + + public int hashCode() { + return this.getName().hashCode(); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/UserDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/UserDelegate.java index ee07aedd..301c8f02 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/UserDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/UserDelegate.java @@ -22,7 +22,6 @@ package me.lucko.luckperms.common.api.delegates; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -42,19 +41,19 @@ import static me.lucko.luckperms.common.api.ApiUtils.checkTime; /** * Provides a link between {@link User} and {@link me.lucko.luckperms.common.core.model.User} */ -@EqualsAndHashCode(of = {"uuid"}, callSuper = false) -public class UserDelegate extends PermissionHolderDelegate implements User { +public final class UserDelegate extends PermissionHolderDelegate implements User { @Getter private final me.lucko.luckperms.common.core.model.User master; - @Getter - private final UUID uuid; - public UserDelegate(@NonNull me.lucko.luckperms.common.core.model.User master) { super(master); this.master = master; - this.uuid = master.getUuid(); + } + + @Override + public UUID getUuid() { + return master.getUuid(); } @Override @@ -205,4 +204,15 @@ public class UserDelegate extends PermissionHolderDelegate implements User { return master.getLocalGroups(server); } + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof UserDelegate)) return false; + + UserDelegate other = (UserDelegate) o; + return this.getUuid() == null ? other.getUuid() == null : this.getUuid().equals(other.getUuid()); + } + + public int hashCode() { + return this.getUuid().hashCode(); + } }