mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-30 03:15:41 -05:00
Fix crash bug with /damage command
This commit is contained in:
parent
7da3400d0d
commit
2b3b036079
1 changed files with 7 additions and 1 deletions
|
@ -14,7 +14,10 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import pw.kaboom.extras.Main;
|
||||||
|
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||||
|
|
||||||
public final class PlayerDamage implements Listener {
|
public final class PlayerDamage implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -73,11 +76,14 @@ public final class PlayerDamage implements Listener {
|
||||||
player.setMaxHealth(20);
|
player.setMaxHealth(20);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
|
|
||||||
|
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||||
|
|
||||||
if (player.getBedSpawnLocation() != null) {
|
if (player.getBedSpawnLocation() != null) {
|
||||||
player.teleportAsync(player.getBedSpawnLocation());
|
player.teleportAsync(player.getBedSpawnLocation());
|
||||||
} else {
|
} else {
|
||||||
final World world = Bukkit.getWorld("world");
|
final World world = Bukkit.getWorld("world");
|
||||||
player.teleportAsync(world.getSpawnLocation());
|
PlatformScheduler.executeOnGlobalRegion(plugin, () -> player
|
||||||
|
.teleportAsync(world.getSpawnLocation()));
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
player.setMaxHealth(Double.POSITIVE_INFINITY);
|
player.setMaxHealth(Double.POSITIVE_INFINITY);
|
||||||
|
|
Loading…
Reference in a new issue