mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-08 09:27:38 +01:00
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:
parent
8b79ce3b3e
commit
b6fcf511a6
@ -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.
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user