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 --- TODO.md | 4 +- out/artifacts/Resurrection_jar/Resurrection.jar | Bin 1332094 -> 1333874 bytes .../brysonsteck/Resurrection/Resurrection.class | Bin 1415 -> 1516 bytes .../Resurrection/commands/CommandResurrect.class | Bin 0 -> 3034 bytes src/net/brysonsteck/Resurrection/Resurrection.java | 5 +- .../Resurrection/commands/CommandResurrect.java | 64 +++++++++++++++++++++ 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class create mode 100644 src/net/brysonsteck/Resurrection/commands/CommandResurrect.java diff --git a/TODO.md b/TODO.md index 92787ef..8e217d5 100644 --- a/TODO.md +++ b/TODO.md @@ -2,11 +2,13 @@ ### Done! * get the player death event working +* figure out how to convert milliseconds to an actual date and time for the end user +* figure out commands and how to use them + * `about` ### For first release * figure out how to get the player.data file to add a user when one joins the server for the first time -* figure out how to convert milliseconds to an actual date and time for the end user * figure out commands and how to use them * `about` * `resurrect PLAYER` (resurrects a player now if needed) diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar index 1a1705e..5956672 100644 Binary files a/out/artifacts/Resurrection_jar/Resurrection.jar and b/out/artifacts/Resurrection_jar/Resurrection.jar differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class index 98142e0..f100f11 100644 Binary files a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class and b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class new file mode 100644 index 0000000..574532c Binary files /dev/null and b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class differ diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index 0b90c1b..bfd8363 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -1,6 +1,8 @@ package net.brysonsteck.Resurrection; import net.brysonsteck.Resurrection.commands.CommandAbout; +import net.brysonsteck.Resurrection.commands.CommandResurrect; +import org.bukkit.command.CommandExecutor; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -22,8 +24,9 @@ public class Resurrection extends JavaPlugin { // register commands this.getCommand("about").setExecutor(new CommandAbout()); + this.getCommand("resurrect").setExecutor(new CommandResurrect()); - System.out.println("Resurrection: I'm alive!"); + System.out.println("[Resurrection] I'm alive!"); } // end of spigot things 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