From 0f89320996551ca6b5584be55b230f0511a5ad2c Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 17:48:46 -0600 Subject: finishing the appearance of being dead --- src/net/brysonsteck/Resurrection/PlayerListener.java | 12 ++++-------- src/net/brysonsteck/Resurrection/TImeCheck.java | 20 -------------------- src/net/brysonsteck/Resurrection/TimeCheck.java | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 src/net/brysonsteck/Resurrection/TImeCheck.java create mode 100644 src/net/brysonsteck/Resurrection/TimeCheck.java (limited to 'src/net/brysonsteck/Resurrection') diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/PlayerListener.java index 0582356..f0c5d6e 100644 --- a/src/net/brysonsteck/Resurrection/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/PlayerListener.java @@ -17,7 +17,7 @@ public class PlayerListener implements Listener { public void onDeath(PlayerDeathEvent e) { System.out.println("Resurrection: A player has died!"); Player p = e.getEntity(); - p.setGameMode(GameMode.ADVENTURE); + p.setGameMode(GameMode.SPECTATOR); Long timeOfDeath = System.currentTimeMillis(); Long resurrectionTime = timeOfDeath + 86400000; @@ -27,25 +27,21 @@ public class PlayerListener implements Listener { String deathFormatted = death.formatTime(); String resurrectFormatted = resurrect.formatTime(); - - p.sendMessage("You have died! You will be able to respawn in 24 hours."); + p.sendMessage("You have died!! You will be able to respawn in the next " + resurrectFormatted); } @EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { Player p = e.getPlayer(); - p.sendMessage("You have respawned"); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,500000, 500)); - p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 500000, 500)); + p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 86400, 255)); } @EventHandler public void onPlayerMove(PlayerMoveEvent e) { Player p = e.getPlayer(); Location location = p.getLocation(); - if (p.getGameMode() == GameMode.SPECTATOR) { + if (p.getGameMode() == GameMode.SPECTATOR && p.hasPotionEffect(PotionEffectType.BLINDNESS)) { p.teleport(location); } - } } diff --git a/src/net/brysonsteck/Resurrection/TImeCheck.java b/src/net/brysonsteck/Resurrection/TImeCheck.java deleted file mode 100644 index a7ea06c..0000000 --- a/src/net/brysonsteck/Resurrection/TImeCheck.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.brysonsteck.Resurrection; - -import java.util.concurrent.TimeUnit; - -class TimeCheck { - long millis; - - public TimeCheck(long millis) { - this.millis = millis; - } - - public String formatTime() { - String formattedTime = String.format("%d hrs, %d min, %d sec", - TimeUnit.MILLISECONDS.toHours(millis), - TimeUnit.MILLISECONDS.toMinutes(millis), - TimeUnit.MILLISECONDS.toSeconds(millis) - - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); - return formattedTime; - } -} diff --git a/src/net/brysonsteck/Resurrection/TimeCheck.java b/src/net/brysonsteck/Resurrection/TimeCheck.java new file mode 100644 index 0000000..a7ea06c --- /dev/null +++ b/src/net/brysonsteck/Resurrection/TimeCheck.java @@ -0,0 +1,20 @@ +package net.brysonsteck.Resurrection; + +import java.util.concurrent.TimeUnit; + +class TimeCheck { + long millis; + + public TimeCheck(long millis) { + this.millis = millis; + } + + public String formatTime() { + String formattedTime = String.format("%d hrs, %d min, %d sec", + TimeUnit.MILLISECONDS.toHours(millis), + TimeUnit.MILLISECONDS.toMinutes(millis), + TimeUnit.MILLISECONDS.toSeconds(millis) - + TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); + return formattedTime; + } +} -- cgit v1.2.3