aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2021-06-06 12:18:29 -0600
committerBryson Steck <steck.bryson@gmail.com>2021-06-06 12:18:29 -0600
commitc18c642b977462a6229638c1cdc5282bfe3b4fbb (patch)
treea46ecf7dd44b2d616fd4e8c2cdf9267a9d9ebabd /src/net/brysonsteck
parent8449343bdfe60b983e0af8a180ced301971b0108 (diff)
downloadresurrection-c18c642b977462a6229638c1cdc5282bfe3b4fbb.tar
resurrection-c18c642b977462a6229638c1cdc5282bfe3b4fbb.tar.gz
resurrection-c18c642b977462a6229638c1cdc5282bfe3b4fbb.tar.bz2
i think the death thing works now
Diffstat (limited to 'src/net/brysonsteck')
-rw-r--r--src/net/brysonsteck/Resurrection/Resurrection.java5
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandResurrect.java64
2 files changed, 68 insertions, 1 deletions
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;
+ }
+ }
+ }
+}