Implement TeamJoinDeathReset.

Add TeamJoinEvent listener that checks if TeamJoinDeathReset is enabled and resets player death count.
This commit is contained in:
BONNe1704 2019-01-02 11:11:31 +02:00
parent 1121bbcbb5
commit 4a73534570

View File

@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent.TeamJoinEvent;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.level.Level;
import world.bentobox.level.calculators.CalcIslandLevel;
@ -47,6 +48,24 @@ public class NewIslandListener implements Listener {
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTeamJoin(TeamJoinEvent event)
{
if (this.addon.getSettings().isTeamJoinDeathReset())
{
this.cil.putIfAbsent(event.getIsland(),
new CalcIslandLevel(this.addon,
event.getIsland(),
() -> zeroLevel(event.getIsland())));
this.addon.getPlayers().setDeaths(event.getIsland().getWorld(),
event.getOwner(),
0);
}
}
private void zeroLevel(Island island) {
if (cil.containsKey(island)) {
addon.setInitialIslandLevel(island, cil.get(island).getResult().getLevel());