mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-23 18:45:17 +01:00
Implement TeamJoinDeathReset.
Add TeamJoinEvent listener that checks if TeamJoinDeathReset is enabled and resets player death count.
This commit is contained in:
parent
1121bbcbb5
commit
4a73534570
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user