Added option to keep old islands when resetting

Implements https://github.com/BentoBoxWorld/BentoBox/issues/1188
This commit is contained in:
Florian CUNY 2020-04-20 17:20:12 +02:00
parent b6dd7d114e
commit 91ccf51a54
2 changed files with 31 additions and 1 deletions

View File

@ -232,6 +232,18 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "island.automated-ownership-transfer.ignore-ranks", hidden = true)
private boolean autoOwnershipTransferIgnoreRanks = false;
// Island deletion related settings
@ConfigComment("Toggles whether islands, when players are resetting them, should be kept in the world or deleted.")
@ConfigComment("* If set to 'true', whenever a player resets his island, his previous island will become unowned and won't be deleted from the world.")
@ConfigComment(" You can, however, still delete those unowned islands through purging.")
@ConfigComment(" On bigger servers, this can lead to an increasing world size.")
@ConfigComment(" Yet, this allows admins to retrieve a player's old island in case of an improper use of the reset command.")
@ConfigComment(" Admins can indeed re-add the player to his old island by registering him to it.")
@ConfigComment("* If set to 'false', whenever a player resets his island, his previous island will be deleted from the world.")
@ConfigComment(" This is the default behaviour.")
@ConfigEntry(path = "island.deletion.keep-previous-island-on-reset", since = "1.13.0")
private boolean keepPreviousIslandOnReset = false;
/* WEB */
@ConfigComment("Toggle whether BentoBox can connect to GitHub to get data about updates and addons.")
@ConfigComment("Disabling this will result in the deactivation of the update checker and of some other")
@ -631,4 +643,22 @@ public class Settings implements ConfigObject {
public void setDatabasePrefix(String databasePrefix) {
this.databasePrefix = databasePrefix;
}
/**
* Returns whether islands, when reset, should be kept or deleted.
* @return {@code true} if islands, when reset, should be kept; {@code false} otherwise.
* @since 1.13.0
*/
public boolean isKeepPreviousIslandOnReset() {
return keepPreviousIslandOnReset;
}
/**
* Sets whether islands, when reset, should be kept or deleted.
* @param keepPreviousIslandOnReset {@code true} if islands, when reset, should be kept; {@code false} otherwise.
* @since 1.13.0
*/
public void setKeepPreviousIslandOnReset(boolean keepPreviousIslandOnReset) {
this.keepPreviousIslandOnReset = keepPreviousIslandOnReset;
}
}

View File

@ -246,7 +246,7 @@ public class NewIsland {
User.removePlayer(user.getPlayer());
}
// Delete old island
if (oldIsland != null) {
if (oldIsland != null && !plugin.getSettings().isKeepPreviousIslandOnReset()) {
// Delete the old island
plugin.getIslands().deleteIsland(oldIsland, true, user.getUniqueId());
}