From 98478964f2464170b228890602e8c30995013973 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Wed, 16 Jun 2021 18:02:05 -0600 Subject: resurrect command should remove death --- .../Resurrection/commands/CommandResurrect.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/net/brysonsteck/Resurrection/commands') 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++; + } + } } -- cgit v1.2.3