API addition - adds reset deaths on new island (#817)

* API addition - adds reset deaths on new island

BentoBox currently tracks deaths in the worlds but the current API only
allows them to be reset when a player joins a team. This setting enables
deaths to be reset when a player starts a new island or resets an
island.

WARN: This should be the only additional WorldSetting we need for deaths.

* Update src/main/java/world/bentobox/bentobox/api/configuration/WorldSettings.java

* Update src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java

* Update src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java

* Update src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java
This commit is contained in:
tastybento 2019-07-06 22:59:49 -07:00 committed by Florian CUNY
parent 8b79ce3b3e
commit b6fcf511a6
3 changed files with 27 additions and 0 deletions

View File

@ -246,6 +246,12 @@ public interface WorldSettings extends ConfigObject {
*/
boolean isDeathsCounted();
/**
* @return true if deaths in the world are reset when the player has a new island
* @since 1.6.0
*/
boolean isDeathsResetOnNewIsland();
/**
* @return whether a player can set their home in the Nether or not.
*/

View File

@ -690,10 +690,26 @@ public class IslandWorldManager {
gameModes.get(world).getWorldSettings().setResetEpoch(System.currentTimeMillis());
}
/**
* Check if the death count should be reset when joining a team in this world
* @param world - world
* @return true or false
*/
public boolean isTeamJoinDeathReset(@NonNull World world) {
return gameModes.get(world).getWorldSettings().isTeamJoinDeathReset();
}
/**
* Check if deaths in the world are reset when the player starts a new island.
* This includes a totally new island and also a new island from a reset.
* @param world - world
* @return true or false
* @since 1.6.0
*/
public boolean isDeathsResetOnNewIsland(@NonNull World world) {
return gameModes.get(world).getWorldSettings().isDeathsResetOnNewIsland();
}
/**
* Get the maximum number of deaths allowed in this world
* @param world - world

View File

@ -176,6 +176,11 @@ public class NewIsland {
// Set home location
plugin.getPlayers().setHomeLocation(user, new Location(next.getWorld(), next.getX() + 0.5D, next.getY(), next.getZ() + 0.5D), 1);
// Reset deaths
if (plugin.getIWM().isDeathsResetOnNewIsland(world)) {
plugin.getPlayers().setDeaths(world, user.getUniqueId(), 0);
}
// Save the player so that if the server crashes weird things won't happen
plugin.getPlayers().save(user.getUniqueId());