From f46b9daae4679e00603d4c3eae086a5ff362debe Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 13:20:42 -0600 Subject: trying spectator mode again --- .../brysonsteck/Resurrection/PlayerListener.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/net/brysonsteck/Resurrection') diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/PlayerListener.java index 7eb8892..0582356 100644 --- a/src/net/brysonsteck/Resurrection/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/PlayerListener.java @@ -1,21 +1,18 @@ package net.brysonsteck.Resurrection; import org.bukkit.GameMode; +import org.bukkit.Location; 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.PlayerMoveEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class PlayerListener implements Listener { - @EventHandler - public void onJoin() { - - } - @EventHandler public void onDeath(PlayerDeathEvent e) { System.out.println("Resurrection: A player has died!"); @@ -38,7 +35,17 @@ public class PlayerListener implements Listener { public void onPlayerRespawn(PlayerRespawnEvent e) { Player p = e.getPlayer(); p.sendMessage("You have respawned"); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000000, 500)); - p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000000000, 500)); + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,500000, 500)); + p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 500000, 500)); + } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent e) { + Player p = e.getPlayer(); + Location location = p.getLocation(); + if (p.getGameMode() == GameMode.SPECTATOR) { + p.teleport(location); + } + } } -- cgit v1.2.3