From 1922bb3499857a4464f07eba2ee2de932674be5f Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 12:38:24 -0600 Subject: moved effects to respawn event --- src/net/brysonsteck/Resurrection/PlayerListener.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/PlayerListener.java index fe8f2b7..58bc405 100644 --- a/src/net/brysonsteck/Resurrection/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/PlayerListener.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -19,10 +20,7 @@ public class PlayerListener implements Listener { public void onDeath(PlayerDeathEvent e) { System.out.println("Resurrection: A player has died!"); Player p = e.getEntity(); - p.spigot().respawn(); p.setGameMode(GameMode.SPECTATOR); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000000, 500)); - p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000000000, 500)); Long timeOfDeath = System.currentTimeMillis(); Long resurrectionTime = timeOfDeath + 86400000; @@ -35,4 +33,11 @@ public class PlayerListener implements Listener { p.sendMessage("You have died! You will be able to respawn in 24 hours."); } + + @EventHandler + public void onPlayerRespawn(PlayerRespawnEvent e) { + Player p = e.getPlayer(); + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000000, 500)); + p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000000000, 500)); + } } -- cgit v1.2.3