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 /src/net/brysonsteck/Resurrection/commands | |
parent | bf005f030be6658f2d2a7180b5c5ce32af5f68ae (diff) | |
download | resurrection-98478964f2464170b228890602e8c30995013973.tar resurrection-98478964f2464170b228890602e8c30995013973.tar.gz resurrection-98478964f2464170b228890602e8c30995013973.tar.bz2 |
resurrect command should remove death
Diffstat (limited to 'src/net/brysonsteck/Resurrection/commands')
-rw-r--r-- | src/net/brysonsteck/Resurrection/commands/CommandResurrect.java | 25 |
1 files changed, 25 insertions, 0 deletions
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++; + } + } } |