Skip to content

Commit d2cb6f2

Browse files
committed
Fix NPE on Sponge from null sender unique id (#482)
1 parent 509aa7a commit d2cb6f2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,11 @@ public boolean hasPermission(String permission) {
8383
}
8484

8585
@Override
86-
public boolean equals(Object o) {
87-
if (this == o) return true;
88-
if (o == null || getClass() != o.getClass()) return false;
89-
SpongeCommandSender that = (SpongeCommandSender) o;
90-
return this.getUniqueId().equals(that.getUniqueId());
91-
}
92-
93-
@Override
94-
public int hashCode() {
95-
return getUniqueId().hashCode();
86+
protected Object getObjectForComparison() {
87+
UUID uniqueId = getUniqueId();
88+
if (uniqueId != null) {
89+
return uniqueId;
90+
}
91+
return getName();
9692
}
9793
}

0 commit comments

Comments
 (0)