From 22410ae7b9d11e5b32fed2fb1044d4298dd36cda Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 19:10:32 -0600 Subject: trying threads --- out/artifacts/Resurrection_jar/Resurrection.jar | Bin 1335861 -> 1336247 bytes .../brysonsteck/Resurrection/PlayerListener.class | Bin 3143 -> 4027 bytes .../brysonsteck/Resurrection/Resurrection.class | Bin 3062 -> 3115 bytes .../brysonsteck/Resurrection/PlayerListener.java | 25 ++++++++++++++------- src/net/brysonsteck/Resurrection/Resurrection.java | 7 +++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar index 9162506..70af613 100644 Binary files a/out/artifacts/Resurrection_jar/Resurrection.jar and b/out/artifacts/Resurrection_jar/Resurrection.jar differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/PlayerListener.class b/out/production/Resurrection/net/brysonsteck/Resurrection/PlayerListener.class index 2955902..9dcc2e8 100644 Binary files a/out/production/Resurrection/net/brysonsteck/Resurrection/PlayerListener.class and b/out/production/Resurrection/net/brysonsteck/Resurrection/PlayerListener.class differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class index 4bbc08a..c1d7340 100644 Binary files a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class and b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class differ diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/PlayerListener.java index c48f303..e50359e 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; @@ -11,6 +12,8 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import static org.bukkit.Bukkit.getServer; + public class PlayerListener implements Listener { @EventHandler @@ -31,16 +34,22 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); p.setGameMode(GameMode.ADVENTURE); + new Thread(() -> { + try { + Thread.sleep(100); + } catch (InterruptedException interruptedException) { + interruptedException.printStackTrace(); + } + PotionEffect invisibility = new PotionEffect(PotionEffectType.INVISIBILITY, 200, 10, false); + PotionEffect blindness = new PotionEffect(PotionEffectType.BLINDNESS, 200, 10, false); + PotionEffect slowness = new PotionEffect(PotionEffectType.SLOW, 200, 10, false); + invisibility.apply(p); + blindness.apply(p); + slowness.apply(p); + }).start(); - PotionEffect invisibility = new PotionEffect(PotionEffectType.INVISIBILITY, 200, 10, false); - PotionEffect blindness = new PotionEffect(PotionEffectType.BLINDNESS, 200, 10, false); - PotionEffect slowness = new PotionEffect(PotionEffectType.SLOW, 200, 10, false); - invisibility.apply(p); - blindness.apply(p); - slowness.apply(p); - p.setNoDamageTicks(1728000); } @EventHandler diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index 33c5b99..cfd196d 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -4,11 +4,15 @@ import net.brysonsteck.Resurrection.commands.CommandAbout; import net.brysonsteck.Resurrection.commands.CommandResurrect; import net.brysonsteck.Resurrection.startup.CheckForUpdate; import org.bukkit.command.CommandExecutor; +import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +import org.w3c.dom.stylesheets.LinkStyle; -public class Resurrection extends JavaPlugin { +import static org.bukkit.Bukkit.getServer; + +public class Resurrection extends JavaPlugin implements Listener { // public Plugin plugin = getPlugin(Resurrection.class); //spigot things @@ -21,6 +25,7 @@ public class Resurrection extends JavaPlugin { public void onEnable() { super.onEnable(); PluginDescriptionFile pluginInfo = getDescription(); + getServer().getPluginManager().registerEvents(this, this); // check for updates System.out.println("[Resurrection] Checking for updates..."); -- cgit v1.2.3