mirror of
https://github.com/kaboomserver/extras.git
synced 2025-08-06 04:23:21 +00:00
Don't set fire ticks while still in lava
This commit is contained in:
parent
d68c8e54d0
commit
c2ee4fac7e
1 changed files with 20 additions and 25 deletions
|
@ -35,17 +35,34 @@ class PlayerDamage implements Listener {
|
||||||
void onPlayerDeath(PlayerDeathEvent event) {
|
void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
final Player player = event.getEntity();
|
final Player player = event.getEntity();
|
||||||
final AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
final AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||||
boolean maxHealthLow = false;
|
|
||||||
|
|
||||||
maxHealth.setBaseValue(20);
|
|
||||||
try {
|
try {
|
||||||
|
maxHealth.setBaseValue(20);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
|
|
||||||
|
if (player.getBedSpawnLocation() != null) {
|
||||||
|
player.teleportAsync(player.getBedSpawnLocation());
|
||||||
|
} else {
|
||||||
|
final World world = Bukkit.getWorld("world");
|
||||||
|
final Location spawnLocation = world.getSpawnLocation();
|
||||||
|
|
||||||
|
for (double y = spawnLocation.getY(); y <= 256; y++) {
|
||||||
|
final Location yLocation = new Location(world, spawnLocation.getX(), y, spawnLocation.getZ());
|
||||||
|
final Block coordBlock = world.getBlockAt(yLocation);
|
||||||
|
|
||||||
|
if (!coordBlock.getType().isSolid() &&
|
||||||
|
!coordBlock.getRelative(BlockFace.UP).getType().isSolid()) {
|
||||||
|
player.teleportAsync(yLocation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
maxHealth.setBaseValue(Double.POSITIVE_INFINITY);
|
maxHealth.setBaseValue(Double.POSITIVE_INFINITY);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
maxHealth.setBaseValue(20);
|
maxHealth.setBaseValue(20);
|
||||||
maxHealthLow = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
player.setFireTicks(0);
|
player.setFireTicks(0);
|
||||||
player.setRemainingAir(player.getMaximumAir());
|
player.setRemainingAir(player.getMaximumAir());
|
||||||
|
@ -55,27 +72,5 @@ class PlayerDamage implements Listener {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
onlinePlayer.sendMessage(event.getDeathMessage());
|
onlinePlayer.sendMessage(event.getDeathMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxHealthLow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.getBedSpawnLocation() != null) {
|
|
||||||
player.teleportAsync(player.getBedSpawnLocation());
|
|
||||||
} else {
|
|
||||||
final World world = Bukkit.getWorld("world");
|
|
||||||
final Location spawnLocation = world.getSpawnLocation();
|
|
||||||
|
|
||||||
for (double y = spawnLocation.getY(); y <= 256; y++) {
|
|
||||||
final Location yLocation = new Location(world, spawnLocation.getX(), y, spawnLocation.getZ());
|
|
||||||
final Block coordBlock = world.getBlockAt(yLocation);
|
|
||||||
|
|
||||||
if (!coordBlock.getType().isSolid() &&
|
|
||||||
!coordBlock.getRelative(BlockFace.UP).getType().isSolid()) {
|
|
||||||
player.teleportAsync(yLocation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue