fix: edithome/warp overwriting existing, close #594

This commit is contained in:
William committed 2024-03-31 16:39:20 +01:00
1 parent 65cc90e79e
commit 0135966c6e
2 files changed
+6

No files matched your search

@@ -311,6 +311,9 @@ public class HomesManager {
}
public void setHomeName(@NotNull Home home, @NotNull String newName) throws ValidationException {
if (plugin.getDatabase().getHome(home.getOwner(), newName).isPresent()) {
throw new ValidationException(ValidationException.Type.NAME_TAKEN);
}
plugin.getValidator().validateName(newName);
home.getMeta().setName(newName);
plugin.getDatabase().saveHome(home);
@@ -206,6 +206,9 @@ public class WarpsManager {
}
public void setWarpName(@NotNull Warp warp, @NotNull String newName) throws ValidationException {
if (plugin.getDatabase().getWarp(newName).isPresent()) {
throw new ValidationException(ValidationException.Type.NAME_TAKEN);
}
plugin.getValidator().validateName(newName);
warp.getMeta().setName(newName);
plugin.getDatabase().saveWarp(warp);