aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandDead.java2
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandResurrect.java4
-rw-r--r--src/net/brysonsteck/Resurrection/player/PlayerListener.java94
-rw-r--r--src/plugin.yml2
4 files changed, 64 insertions, 38 deletions
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandDead.java b/src/net/brysonsteck/Resurrection/commands/CommandDead.java
index dd23174..96fe736 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandDead.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandDead.java
@@ -25,7 +25,7 @@ public class CommandDead implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/about` command was ran by " + commandSender.getName());
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/dead` command was ran by " + commandSender.getName());
}
PlayerData playerData = new PlayerData();
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
index e26575c..0715046 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
@@ -64,7 +64,7 @@ public class CommandResurrect implements CommandExecutor {
// for versions > 1.8
player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
// for version 1.8
- //player.playSound(player.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ // player.playSound(player.getLocation(), Sound.WITHER_DEATH, 1, 0);
}
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + strings[0] + " has been resurrected manually by an admin!");
removeDeath(resurrectPlayer);
@@ -114,7 +114,7 @@ public class CommandResurrect implements CommandExecutor {
// for versions > 1.8
player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
// for version 1.8
- //player.playSound(player.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ // player.playSound(player.getLocation(), Sound.WITHER_DEATH, 1, 0);
}
Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!");
removeDeath(resurrectPlayer);
diff --git a/src/net/brysonsteck/Resurrection/player/PlayerListener.java b/src/net/brysonsteck/Resurrection/player/PlayerListener.java
index 424e0fc..45bd343 100644
--- a/src/net/brysonsteck/Resurrection/player/PlayerListener.java
+++ b/src/net/brysonsteck/Resurrection/player/PlayerListener.java
@@ -3,6 +3,8 @@ package net.brysonsteck.Resurrection.player;
import net.brysonsteck.Resurrection.startup.ParseSettings;
import net.brysonsteck.Resurrection.Resurrection;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Logger;
import org.bukkit.*;
@@ -25,6 +27,7 @@ public class PlayerListener implements Listener {
World world = Bukkit.getWorlds().get(0);
Location spawn = world.getSpawnLocation();
//Hashtable<String, Location> playerSpawns = new Hashtable<>();
+ Map<String, Location> playerSpawns = new HashMap<>();
ParseSettings parseSettings;
boolean DEBUG;
Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
@@ -110,7 +113,8 @@ public class PlayerListener implements Listener {
PotionEffect slowness = new PotionEffect(PotionEffectType.SLOW, 999999999, 10, false);
blindness.apply(p);
slowness.apply(p);
- p.teleport(spawn);
+ // p.teleport(spawn);
+ playerSpawns.put(p.getDisplayName(), p.getLocation());
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1);
timeToResurrection = timeToResurrection - System.currentTimeMillis();
@@ -122,11 +126,17 @@ public class PlayerListener implements Listener {
new BukkitRunnable() {
@Override
public void run() {
+ playerData.readData();
String rawData = playerData.getRawData();
int index = 0;
+ boolean alreadyAlive = false;
for (String players : rawPlayers) {
if (players.startsWith(p.getDisplayName())) {
String[] playerSplit = players.split(",");
+ if (playerSplit[1] == "false") {
+ alreadyAlive = true;
+ break;
+ }
playerSplit[1] = "false";
playerSplit[2] = "0";
@@ -137,21 +147,23 @@ public class PlayerListener implements Listener {
}
index++;
}
- stillDead = false;
- for (PotionEffect effect : p.getActivePotionEffects())
- p.removePotionEffect(effect.getType());
- p.setGameMode(GameMode.SURVIVAL);
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + p.getDisplayName() + " has resurrected!");
- if (p.getBedSpawnLocation() != null) {
- p.teleport(p.getBedSpawnLocation());
- } else {
- p.teleport(spawn);
- }
- for(Player p : Bukkit.getOnlinePlayers()){
- // for versions > 1.8
- p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
- // for version 1.8
- //p.playSound(p.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ if (!alreadyAlive) {
+ stillDead = false;
+ for (PotionEffect effect : p.getActivePotionEffects())
+ p.removePotionEffect(effect.getType());
+ p.setGameMode(GameMode.SURVIVAL);
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + p.getDisplayName() + " has resurrected!");
+ if (p.getBedSpawnLocation() != null) {
+ p.teleport(p.getBedSpawnLocation());
+ // } else {
+ // p.teleport(spawn);
+ }
+ for(Player p : Bukkit.getOnlinePlayers()){
+ // for versions > 1.8
+ p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
+ // for version 1.8
+ // p.playSound(p.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ }
}
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection);
@@ -216,11 +228,19 @@ public class PlayerListener implements Listener {
@Override
public void run() {
// save death to false
- String rawData = playerData.getRawData();
+ PlayerData playerData2 = new PlayerData();
+ playerData2.readData();
+ String rawData = playerData2.getRawData();
int index = 0;
+ boolean alreadyAlive = false;
for (String players : rawPlayers) {
if (players.startsWith(p.getDisplayName())) {
String[] playerSplit = players.split(",");
+ log.info(playerSplit[1]);
+ if (playerSplit[1] == "false") {
+ alreadyAlive = true;
+ break;
+ }
playerSplit[1] = "false";
playerSplit[2] = "0";
@@ -231,21 +251,23 @@ public class PlayerListener implements Listener {
}
index++;
}
- stillDead = false;
- for (PotionEffect effect : p.getActivePotionEffects())
- p.removePotionEffect(effect.getType());
- p.setGameMode(GameMode.SURVIVAL);
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + p.getDisplayName() + " has resurrected!");
- if (p.getBedSpawnLocation() != null) {
- p.teleport(p.getBedSpawnLocation());
- } else {
- p.teleport(spawn);
- }
- for(Player p : Bukkit.getOnlinePlayers()){
- // for versions > 1.8
- p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
- // for version 1.8
- //p.playSound(p.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ if (!alreadyAlive) {
+ stillDead = false;
+ for (PotionEffect effect : p.getActivePotionEffects())
+ p.removePotionEffect(effect.getType());
+ p.setGameMode(GameMode.SURVIVAL);
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + p.getDisplayName() + " has resurrected!");
+ if (p.getBedSpawnLocation() != null) {
+ p.teleport(p.getBedSpawnLocation());
+ // } else {
+ // p.teleport(spawn);
+ }
+ for(Player p : Bukkit.getOnlinePlayers()){
+ // for versions > 1.8
+ p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0);
+ // for version 1.8
+ // p.playSound(p.getLocation(), Sound.WITHER_DEATH, 1, 0);
+ }
}
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection);
@@ -263,6 +285,7 @@ public class PlayerListener implements Listener {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player " + p.getDisplayName() + " has respawned before their resurrection time");
}
+
TimeCheck timeCheck = new TimeCheck(Long.parseLong(parseSettings.getSetting("resurrection_time")));
//playerSpawns.put(p.getDisplayName(), p.getLocation());
p.setGameMode(GameMode.SPECTATOR);
@@ -281,6 +304,8 @@ public class PlayerListener implements Listener {
// invisibility.apply(p);
blindness.apply(p);
slowness.apply(p);
+ // put location in map
+ playerSpawns.put(p.getDisplayName(), p.getLocation());
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1);
}
@@ -289,11 +314,12 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
- if (p.getGameMode() == GameMode.SPECTATOR) {
+ if (p.getGameMode() == GameMode.SPECTATOR && stillDead) {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player " + p.getDisplayName() + " attempted to move while in dead state, teleporting to spawn until their resurrection time");
}
- p.teleport(spawn);
+ //p.teleport(spawn);
+ p.teleport(playerSpawns.get(p.getDisplayName()));
}
}
}
diff --git a/src/plugin.yml b/src/plugin.yml
index 97990bf..c4c21f7 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -1,7 +1,7 @@
main: net.brysonsteck.Resurrection.Resurrection
name: Resurrection
author: 'Bryson Steck'
-version: '1.3'
+version: '1.3.1'
website: https://brysonsteck.net/resurrection.html
description: Makes players wait large amounts of time before respawning!
database: false