mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
v4.5: Bulk delete, regex customization, QoL & API work (#486)
* Improve validator error specificity, fix #481 * Add more sanity-checking to cluster IDs, close #482 * Add bulk/player-delete command, close #484, close #257 * Fix checkstyle formatting in tests * Add missing strings to other locale files * Use morepaperlib for runtime command registration on spigot * api: make creation methods return a future, close #473 * Add name/description restriction regex customization * docs: Update config file with new regex options * bump version number to 4.5 * fix typo, correct command confirmation logic * Make confirmation locales more clear * Fix confirmation checking logic
This commit is contained in:
1 parent
e2c9a52911
commit
6bfd69f232
38 files changed
+1161
-692
No files matched your search
@@ -181,16 +181,16 @@ public class HomesManager {
|
||||
userHomes.remove(user.getUuid().toString());
|
||||
}
|
||||
|
||||
|
||||
public void createHome(@NotNull User owner, @NotNull String name, @NotNull Position position,
|
||||
@NotNull
|
||||
public Home createHome(@NotNull User owner, @NotNull String name, @NotNull Position position,
|
||||
boolean overwrite, boolean buyAdditionalSlots) throws ValidationException {
|
||||
final Optional<Home> existingHome = plugin.getDatabase().getHome(owner, name);
|
||||
if (existingHome.isPresent() && !overwrite) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_TAKEN);
|
||||
}
|
||||
if (!plugin.getValidator().isValidName(name)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
|
||||
// Validate the home name; throw an exception if invalid
|
||||
plugin.getValidator().validateName(name);
|
||||
|
||||
// Determine what the new home count would be & validate against user max homes
|
||||
int homes = plugin.getDatabase().getHomes(owner).size() + (existingHome.isPresent() ? 0 : 1);
|
||||
@@ -224,11 +224,12 @@ public class HomesManager {
|
||||
.orElse(Home.from(position, PositionMeta.create(name, ""), owner));
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
return home;
|
||||
}
|
||||
|
||||
public void createHome(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position position) throws ValidationException {
|
||||
createHome(owner, name, position, plugin.getSettings().doOverwriteExistingHomesWarps(), true);
|
||||
this.createHome(owner, name, position, plugin.getSettings().doOverwriteExistingHomesWarps(), true);
|
||||
}
|
||||
|
||||
public void deleteHome(@NotNull User owner, @NotNull String name) throws ValidationException {
|
||||
@@ -257,6 +258,19 @@ public class HomesManager {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
final int deleted = plugin.getDatabase().deleteAllHomes(worldName, serverName);
|
||||
userHomes.values().forEach(homes -> homes.removeIf(
|
||||
h -> h.getWorld().getName().equals(worldName) && h.getServer().equals(serverName)
|
||||
));
|
||||
publicHomes.removeIf(h -> h.getWorld().getName().equals(worldName) && h.getServer().equals(serverName));
|
||||
if (plugin.getSettings().doCrossServer() && serverName.equals(plugin.getServerName())) {
|
||||
plugin.getMapHook().ifPresent(hook -> hook.clearHomes(worldName));
|
||||
}
|
||||
plugin.getManager().propagateCacheUpdate();
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setHomePosition(@NotNull User owner, @NotNull String name,
|
||||
@NotNull Position position) throws ValidationException {
|
||||
final Optional<Home> optionalHome = plugin.getDatabase().getHome(owner, name);
|
||||
@@ -284,10 +298,7 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
public void setHomeName(@NotNull Home home, @NotNull String newName) throws ValidationException {
|
||||
if (!plugin.getValidator().isValidName(newName)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateName(newName);
|
||||
home.getMeta().setName(newName);
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
@@ -304,10 +315,7 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
public void setHomeDescription(@NotNull Home home, @NotNull String description) {
|
||||
if (!plugin.getValidator().isValidDescription(description)) {
|
||||
throw new ValidationException(ValidationException.Type.DESCRIPTION_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateDescription(description);
|
||||
home.getMeta().setDescription(description);
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
|
||||
Reference in new issue
Block a user