Fix getUuid and getName API methods returning null for User, Group and Track instances

This commit is contained in:
Luck 2017-02-26 20:46:37 +00:00
parent df99ef4481
commit fd4963c74b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 53 additions and 24 deletions

View File

@ -23,7 +23,6 @@
package me.lucko.luckperms.common.api.delegates; package me.lucko.luckperms.common.api.delegates;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; 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} * Provides a link between {@link Group} and {@link me.lucko.luckperms.common.core.model.Group}
*/ */
@EqualsAndHashCode(of = {"name"}, callSuper = false) public final class GroupDelegate extends PermissionHolderDelegate implements Group {
public class GroupDelegate extends PermissionHolderDelegate implements Group {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final me.lucko.luckperms.common.core.model.Group master; 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) { public GroupDelegate(@NonNull me.lucko.luckperms.common.core.model.Group master) {
super(master); super(master);
this.master = master; this.master = master;
this.name = master.getName(); }
@Override
public String getName() {
return master.getName();
} }
@Override @Override
@ -169,4 +168,16 @@ public class GroupDelegate extends PermissionHolderDelegate implements Group {
public List<String> getLocalGroups(@NonNull String server) { public List<String> getLocalGroups(@NonNull String server) {
return master.getLocalGroups(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();
}
} }

View File

@ -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} * Provides a link between {@link PermissionHolder} and {@link me.lucko.luckperms.common.core.model.PermissionHolder}
*/ */
@SuppressWarnings("unused")
@AllArgsConstructor @AllArgsConstructor
public class PermissionHolderDelegate implements PermissionHolder { public class PermissionHolderDelegate implements PermissionHolder {
private final me.lucko.luckperms.common.core.model.PermissionHolder master; private final me.lucko.luckperms.common.core.model.PermissionHolder master;

View File

@ -23,7 +23,7 @@
package me.lucko.luckperms.common.api.delegates; package me.lucko.luckperms.common.api.delegates;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; 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} * Provides a link between {@link Track} and {@link me.lucko.luckperms.common.core.model.Track}
*/ */
@EqualsAndHashCode(of = {"name"}) @AllArgsConstructor
public class TrackDelegate implements Track { public final class TrackDelegate implements Track {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final me.lucko.luckperms.common.core.model.Track master; private final me.lucko.luckperms.common.core.model.Track master;
@Getter @Override
private final String name; public String getName() {
return master.getName();
public TrackDelegate(@NonNull me.lucko.luckperms.common.core.model.Track master) {
this.master = master;
this.name = master.getName();
} }
@Override @Override
@ -113,4 +110,16 @@ public class TrackDelegate implements Track {
public void clearGroups() { public void clearGroups() {
master.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();
}
} }

View File

@ -22,7 +22,6 @@
package me.lucko.luckperms.common.api.delegates; package me.lucko.luckperms.common.api.delegates;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; 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} * Provides a link between {@link User} and {@link me.lucko.luckperms.common.core.model.User}
*/ */
@EqualsAndHashCode(of = {"uuid"}, callSuper = false) public final class UserDelegate extends PermissionHolderDelegate implements User {
public class UserDelegate extends PermissionHolderDelegate implements User {
@Getter @Getter
private final me.lucko.luckperms.common.core.model.User master; 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) { public UserDelegate(@NonNull me.lucko.luckperms.common.core.model.User master) {
super(master); super(master);
this.master = master; this.master = master;
this.uuid = master.getUuid(); }
@Override
public UUID getUuid() {
return master.getUuid();
} }
@Override @Override
@ -205,4 +204,15 @@ public class UserDelegate extends PermissionHolderDelegate implements User {
return master.getLocalGroups(server); 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();
}
} }