Fix regression in invalid home check (#4425)

This commit is contained in:
Josh Roy 2021-08-02 08:23:40 -07:00 committed by GitHub
parent f57de40668
commit b84207f955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -161,6 +161,15 @@ public abstract class UserData extends PlayerExtension implements IConf {
return loc != null ? loc.location() : null;
}
public boolean hasValidHomes() {
for (final LazyLocation loc : holder.homes().values()) {
if (loc != null && loc.location() != null) {
return true;
}
}
return false;
}
public Location getHome(final Location world) {
if (getHomes().isEmpty()) {
return null;

View file

@ -81,7 +81,7 @@ public class Commandhome extends EssentialsCommand {
} else {
showError(user.getBase(), new Exception(tl("noHomeSetPlayer")), commandLabel);
}
} else if (homes.isEmpty() || finalPlayer.getHome(homes.get(0)) == null) {
} else if (homes.isEmpty() || !finalPlayer.hasValidHomes()) {
showError(user.getBase(), new Exception(tl("noHomeSetPlayer")), commandLabel);
} else if (homes.size() == 1 && finalPlayer.equals(user)) {
try {