aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2022-02-27 13:26:34 -0700
committerBryson Steck <steck.bryson@gmail.com>2022-02-27 13:26:34 -0700
commit85e15b956673fcc509cb5c6692500d5702ca26c5 (patch)
tree8fc1b8e6adbd3529dff1c9d85496ef4a208d6468 /src/net/brysonsteck
parent939ef8559410aac8be2e09db8acc83648d2e9d31 (diff)
downloadresurrection-85e15b956673fcc509cb5c6692500d5702ca26c5.tar
resurrection-85e15b956673fcc509cb5c6692500d5702ca26c5.tar.gz
resurrection-85e15b956673fcc509cb5c6692500d5702ca26c5.tar.bz2
hopefully fixed #5
Diffstat (limited to 'src/net/brysonsteck')
-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
3 files changed, 63 insertions, 37 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()));
}
}
}