Fix edithome permission logic check & warn against bad rtp spawn radius (#531)

* Fixup edithome logic

* Add warning against bad spawn radius
This commit is contained in:
William authored and GitHub committed 2023-12-05 16:30:26 +00:00
1 parent 8a69e4a075
commit 859993b37e
3 files changed
+28 -10

No files matched your search

@@ -336,14 +336,16 @@ public class HomesManager {
throw new ValidationException(ValidationException.Type.NOT_FOUND);
}
this.setHomePrivacy(optionalHome.get(), isPublic);
this.setHomePrivacy(owner, optionalHome.get(), isPublic);
}
public void setHomePrivacy(@NotNull Home home, boolean isPublic) {
if (isPublic && home.getOwner() instanceof OnlineUser online) {
final int publicHomes = plugin.getDatabase().getHomes(home.getOwner()).stream()
.filter(Home::isPublic)
.toList().size();
this.setHomePrivacy(home.getOwner(), home, isPublic);
}
public void setHomePrivacy(@NotNull User owner, @NotNull Home home, boolean isPublic) {
if (isPublic && owner instanceof OnlineUser online) {
int publicHomes = plugin.getDatabase().getHomes(owner).stream().filter(Home::isPublic).toList().size();
if (publicHomes >= getMaxPublicHomes(online)) {
throw new ValidationException(ValidationException.Type.REACHED_MAX_PUBLIC_HOMES);
}