mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Fix for dying in the void in non-island location causes spectator mode.
https://github.com/BentoBoxWorld/bentobox/issues/286
This commit is contained in:
parent
0f5ab8ab7d
commit
a49739d45a
@ -4,6 +4,7 @@
|
||||
package world.bentobox.bentobox.listeners.flags;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -72,8 +73,9 @@ public class InvincibleVisitorsListener extends AbstractFlagListener implements
|
||||
// Open a new panel for visitor protection
|
||||
PanelBuilder pb = new PanelBuilder();
|
||||
pb.user(user).name(ivPanelName);
|
||||
|
||||
// Make panel items
|
||||
Arrays.stream(EntityDamageEvent.DamageCause.values()).forEach(c -> pb.item(getPanelItem(c, user)));
|
||||
Arrays.stream(EntityDamageEvent.DamageCause.values()).sorted(Comparator.comparing(DamageCause::name)).forEach(c -> pb.item(getPanelItem(c, user)));
|
||||
pb.build();
|
||||
}
|
||||
|
||||
@ -109,9 +111,17 @@ public class InvincibleVisitorsListener extends AbstractFlagListener implements
|
||||
Player p = (Player) e.getEntity();
|
||||
// Handle the void - teleport player back to island in a safe spot
|
||||
if(e.getCause().equals(DamageCause.VOID)) {
|
||||
// Will be set back after the teleport
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
getIslands().getIslandAt(p.getLocation()).ifPresent(i -> new SafeSpotTeleport.Builder(getPlugin()).entity(p).island(i).build());
|
||||
if (getIslands().getIslandAt(p.getLocation()).isPresent()) {
|
||||
// Will be set back after the teleport
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
getIslands().getIslandAt(p.getLocation()).ifPresent(i -> new SafeSpotTeleport.Builder(getPlugin()).entity(p).island(i).build());
|
||||
} else if (getIslands().hasIsland(p.getWorld(), User.getInstance(p))) {
|
||||
// No island in this location - if the player has an island try to teleport them back
|
||||
getIslands().homeTeleport(p.getWorld(), p);
|
||||
} else {
|
||||
// Else die, sorry.
|
||||
e.setCancelled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user