diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-06-16 18:02:05 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-06-16 18:02:05 -0600 |
commit | 98478964f2464170b228890602e8c30995013973 (patch) | |
tree | 8df6dbf20ceb80c8eb94869b4fe1b2c5d21fc216 | |
parent | bf005f030be6658f2d2a7180b5c5ce32af5f68ae (diff) | |
download | resurrection-98478964f2464170b228890602e8c30995013973.tar resurrection-98478964f2464170b228890602e8c30995013973.tar.gz resurrection-98478964f2464170b228890602e8c30995013973.tar.bz2 |
resurrect command should remove death
-rw-r--r-- | out/artifacts/Resurrection_jar/Resurrection.jar | bin | 1343587 -> 1344889 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class | bin | 4914 -> 4914 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class | bin | 4040 -> 5046 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class | bin | 2626 -> 1424 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class | bin | 6486 -> 6215 bytes | |||
-rw-r--r-- | src/net/brysonsteck/Resurrection/Resurrection.java | 2 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/commands/CommandResurrect.java | 25 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/PlayerListener.java | 21 |
8 files changed, 41 insertions, 7 deletions
diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar Binary files differindex 6d12991..0ba1311 100644 --- a/out/artifacts/Resurrection_jar/Resurrection.jar +++ b/out/artifacts/Resurrection_jar/Resurrection.jar diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class Binary files differindex 7bb8b9d..b092eae 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class Binary files differindex 44cc29e..9e71d9b 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class Binary files differindex 47363a5..1a60ffb 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class Binary files differindex 4aedb1b..dff62d1 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index 68074b8..4692a7f 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -129,6 +129,8 @@ public class Resurrection extends JavaPlugin implements Listener { // rawData = String.join(";", rawPlayers); // playerData.saveData(rawData); // System.out.println(rawData); +// String[] array = ";bryzinga,false,0".split(";"); +// System.out.println(array.length); } diff --git a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java index 732221a..75c280d 100644 --- a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java +++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java @@ -1,5 +1,6 @@ package net.brysonsteck.Resurrection.commands; +import net.brysonsteck.Resurrection.player.PlayerData; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -31,6 +32,7 @@ public class CommandResurrect implements CommandExecutor { player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); } Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + strings[0] + " has been resurrected manually by an admin!"); + removeDeath(resurrectPlayer); return true; } else { p.sendMessage(ChatColor.RED + strings[0] + " is not dead! Failed to resurrect."); @@ -56,6 +58,7 @@ public class CommandResurrect implements CommandExecutor { player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); } Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!"); + removeDeath(resurrectPlayer); return true; } else { System.out.println(strings[0] + " is not dead! Failed to resurrect."); @@ -68,4 +71,26 @@ public class CommandResurrect implements CommandExecutor { } } } + + public void removeDeath(Player p) { + PlayerData playerData = new PlayerData(); + playerData.readData(); + String rawData = playerData.getRawData(); + String[] rawPlayers = rawData.split(";"); + int index = 0; + for (String players : rawPlayers) { + if (players.startsWith(p.getDisplayName())) { + String[] playerSplit = players.split(","); + playerSplit[1] = "false"; + playerSplit[2] = "0"; + + // save data + rawPlayers[index] = String.join(",", playerSplit); + rawData = String.join(";", rawPlayers); + playerData.saveData(rawData); + break; + } + index++; + } + } } diff --git a/src/net/brysonsteck/Resurrection/player/PlayerListener.java b/src/net/brysonsteck/Resurrection/player/PlayerListener.java index 026cf03..d4abcaa 100644 --- a/src/net/brysonsteck/Resurrection/player/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/player/PlayerListener.java @@ -37,11 +37,11 @@ public class PlayerListener implements Listener { boolean dead = Boolean.parseBoolean(playerSplit[1]); resurrectTime = Long.parseLong(playerSplit[2]); - if (p.getGameMode() == GameMode.SPECTATOR && !dead) { + if (!dead) { for (PotionEffect effect : p.getActivePotionEffects()) p.removePotionEffect(effect.getType()); p.setGameMode(GameMode.SURVIVAL); - } else if (p.getGameMode() == GameMode.SPECTATOR && dead) { + } else { resumeDeath = true; } @@ -57,14 +57,21 @@ public class PlayerListener implements Listener { playerData.saveData(rawData + ";" + p.getDisplayName() + ",false,0"); } if (resumeDeath) { - PotionEffect blindness = new PotionEffect(PotionEffectType.BLINDNESS, 999999999, 10, false); - PotionEffect slowness = new PotionEffect(PotionEffectType.SLOW, 999999999, 10, false); - blindness.apply(p); - slowness.apply(p); - // convert to seconds and to ticks + new BukkitRunnable() { + @Override + public void run() { + p.setGameMode(GameMode.SPECTATOR); + PotionEffect blindness = new PotionEffect(PotionEffectType.BLINDNESS, 999999999, 10, false); + PotionEffect slowness = new PotionEffect(PotionEffectType.SLOW, 999999999, 10, false); + blindness.apply(p); + slowness.apply(p); + // convert to seconds and to ticks + } + }.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1); resurrectTime = resurrectTime - System.currentTimeMillis(); resurrectTime = resurrectTime / 1000; resurrectTime = resurrectTime * 20; + new BukkitRunnable() { @Override public void run() { |