From c18c642b977462a6229638c1cdc5282bfe3b4fbb Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 12:18:29 -0600 Subject: i think the death thing works now --- .../Resurrection/commands/CommandResurrect.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/net/brysonsteck/Resurrection/commands/CommandResurrect.java (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 new file mode 100644 index 0000000..eb24e7d --- /dev/null +++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java @@ -0,0 +1,64 @@ +package net.brysonsteck.Resurrection.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; + +public class CommandResurrect implements CommandExecutor { + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { + boolean valid = (strings.length != 1); + + if (commandSender instanceof Player) { + Player p = (Player) commandSender; + if (valid) { + Player resurrectPlayer = Bukkit.getPlayer(strings[0]); + if (resurrectPlayer == null) { + p.sendMessage("That player does not exist! Failed to resurrect."); + return false; + } + if (resurrectPlayer.getGameMode() == GameMode.SPECTATOR) { + for (PotionEffect effect : resurrectPlayer.getActivePotionEffects()) + resurrectPlayer.removePotionEffect(effect.getType()); + resurrectPlayer.setGameMode(GameMode.SURVIVAL); + Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!"); + return true; + } else { + p.sendMessage(strings[0] + " is not dead! Failed to resurrect."); + return false; + } + } else { + System.out.println("Too few arguments!"); + System.out.println("Usage: /resurrect PLAYER"); + return false; + } + } else { + if (valid) { + Player resurrectPlayer = Bukkit.getPlayer(strings[0]); + if (resurrectPlayer == null) { + System.out.println("That player does not exist! Failed to resurrect."); + return false; + } + if (resurrectPlayer.getGameMode() == GameMode.SPECTATOR) { + for (PotionEffect effect : resurrectPlayer.getActivePotionEffects()) + resurrectPlayer.removePotionEffect(effect.getType()); + resurrectPlayer.setGameMode(GameMode.SURVIVAL); + Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!"); + return true; + } else { + System.out.println(strings[0] + " is not dead! Failed to resurrect."); + return false; + } + } else { + System.out.println("Too few arguments!"); + System.out.println("Usage: /resurrect PLAYER"); + return false; + } + } + } +} -- cgit v1.2.3