experimenting with new respawns
This commit is contained in:
parent
db0d6991fa
commit
cd0edf247f
1 changed files with 5 additions and 1 deletions
|
@ -14,11 +14,14 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
boolean stillDead;
|
boolean stillDead;
|
||||||
boolean timerRunning = false;
|
boolean timerRunning = false;
|
||||||
Location spawn;
|
Location spawn;
|
||||||
|
Hashtable<String, Location> playerSpawns = new Hashtable<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
@ -170,6 +173,7 @@ public class PlayerListener implements Listener {
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
||||||
if (stillDead) {
|
if (stillDead) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
|
playerSpawns.put(p.getDisplayName(), p.getLocation());
|
||||||
p.setGameMode(GameMode.SPECTATOR);
|
p.setGameMode(GameMode.SPECTATOR);
|
||||||
p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "YOU HAVE DIED!!");
|
p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "YOU HAVE DIED!!");
|
||||||
p.sendMessage(ChatColor.RED + "You will be able to respawn in the next 24 hours.");
|
p.sendMessage(ChatColor.RED + "You will be able to respawn in the next 24 hours.");
|
||||||
|
@ -192,7 +196,7 @@ public class PlayerListener implements Listener {
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if (p.getGameMode() == GameMode.SPECTATOR) {
|
if (p.getGameMode() == GameMode.SPECTATOR) {
|
||||||
p.teleport(this.spawn);
|
p.teleport(playerSpawns.get(p.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue