From 2d9d34f8a5d7551b05e8440d46950faa4e7f4abe Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 18:34:30 -0600 Subject: trying syncdelaytask --- .../brysonsteck/Resurrection/PlayerListener.java | 27 +++++++++++++--------- src/net/brysonsteck/Resurrection/Resurrection.java | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/PlayerListener.java index 039f723..f87f257 100644 --- a/src/net/brysonsteck/Resurrection/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/PlayerListener.java @@ -1,5 +1,6 @@ package net.brysonsteck.Resurrection; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -10,8 +11,10 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.plugin.java.JavaPlugin; -public class PlayerListener implements Listener { + +public class PlayerListener extends JavaPlugin implements Listener { @EventHandler public void onDeath(PlayerDeathEvent e) { @@ -31,17 +34,19 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); p.setGameMode(GameMode.ADVENTURE); - try { - Thread.sleep(1000); - } catch (InterruptedException interruptedException) { - interruptedException.printStackTrace(); - } - p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1728000, 10, false)); - p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1728000, 10, false)); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1728000, 10, false)); - p.setNoDamageTicks(1728000); + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(Resurrection.class), new Runnable() + { + public void run() + { + p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1728000, 10, false)); + p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1728000, 10, false)); + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1728000, 10, false)); + p.setNoDamageTicks(1728000); + } + }, (1)); } @EventHandler diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index 33c5b99..23c0c4a 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -9,7 +9,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class Resurrection extends JavaPlugin { -// public Plugin plugin = getPlugin(Resurrection.class); + public Plugin plugin = getPlugin(Resurrection.class); //spigot things @Override -- cgit v1.2.3