mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-27 20:46:19 +01:00
Added death resetting.
Untested... https://github.com/BentoBoxWorld/Level/issues/30
This commit is contained in:
parent
ba606abfef
commit
1121bbcbb5
@ -7,11 +7,11 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import world.bentobox.level.Level;
|
|
||||||
import world.bentobox.level.calculators.CalcIslandLevel;
|
|
||||||
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent;
|
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent;
|
||||||
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent;
|
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.level.Level;
|
||||||
|
import world.bentobox.level.calculators.CalcIslandLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens for new islands and sets the level to zero automatically
|
* Listens for new islands and sets the level to zero automatically
|
||||||
@ -34,11 +34,17 @@ public class NewIslandListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onNewIsland(IslandCreatedEvent e) {
|
public void onNewIsland(IslandCreatedEvent e) {
|
||||||
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
|
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
|
||||||
|
// Set deaths to zero just in case
|
||||||
|
addon.getPlayers().setDeaths(e.getIsland().getWorld(), e.getOwner(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onNewIsland(IslandResettedEvent e) {
|
public void onNewIsland(IslandResettedEvent e) {
|
||||||
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
|
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
|
||||||
|
// Reset deaths
|
||||||
|
if (addon.getSettings().isIslandResetDeathReset()) {
|
||||||
|
addon.getPlayers().setDeaths(e.getIsland().getWorld(), e.getOwner(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void zeroLevel(Island island) {
|
private void zeroLevel(Island island) {
|
||||||
|
Loading…
Reference in New Issue
Block a user