Fix getUuid and getName API methods returning null for User, Group and Track instances
This commit is contained in:
parent
df99ef4481
commit
fd4963c74b
@ -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<String> 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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user