trying threads

This commit is contained in:
Bryson Steck 2021-06-06 19:10:32 -06:00
parent 357ef1da6c
commit 22410ae7b9
5 changed files with 23 additions and 9 deletions

View file

@ -1,5 +1,6 @@
package net.brysonsteck.Resurrection; package net.brysonsteck.Resurrection;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,6 +12,8 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import static org.bukkit.Bukkit.getServer;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
@EventHandler @EventHandler
@ -31,16 +34,22 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerRespawn(PlayerRespawnEvent e) { public void onPlayerRespawn(PlayerRespawnEvent e) {
Player p = e.getPlayer(); final Player p = e.getPlayer();
p.setGameMode(GameMode.ADVENTURE); 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 @EventHandler

View file

@ -4,11 +4,15 @@ import net.brysonsteck.Resurrection.commands.CommandAbout;
import net.brysonsteck.Resurrection.commands.CommandResurrect; import net.brysonsteck.Resurrection.commands.CommandResurrect;
import net.brysonsteck.Resurrection.startup.CheckForUpdate; import net.brysonsteck.Resurrection.startup.CheckForUpdate;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; 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); // public Plugin plugin = getPlugin(Resurrection.class);
//spigot things //spigot things
@ -21,6 +25,7 @@ public class Resurrection extends JavaPlugin {
public void onEnable() { public void onEnable() {
super.onEnable(); super.onEnable();
PluginDescriptionFile pluginInfo = getDescription(); PluginDescriptionFile pluginInfo = getDescription();
getServer().getPluginManager().registerEvents(this, this);
// check for updates // check for updates
System.out.println("[Resurrection] Checking for updates..."); System.out.println("[Resurrection] Checking for updates...");