commit 0da4a1dfa5c9dcb8c7f2f38e9c8a8c1368e1c14c
parent 0df3308fe33ca07928b1237660aaf10d453836f6
Author: chunksize <reisingerluca@gmail.com>
Date: Fri, 17 Nov 2023 13:49:19 +0100
feat: Added heal command
Diffstat:
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/res/plugin.yml b/res/plugin.yml
@@ -52,3 +52,7 @@ commands:
gm:
usage: /gm
description: Toggle gamemode between surivial and creative
+ test:
+ heal:
+ usage: /heal <player>
+ description: Heals the player
diff --git a/src/poppy/Main.java b/src/poppy/Main.java
@@ -178,6 +178,8 @@ public class Main extends JavaPlugin implements Listener
return teleportToWorld(player, args);
case "gm":
return changeGameMode(player);
+ case "heal":
+ return heal(player, args);
default:
return false;
}
@@ -575,4 +577,34 @@ public class Main extends JavaPlugin implements Listener
return true;
}
+
+ private boolean heal(final Player player, final String[] args)
+ {
+ if(args.length != 0)
+ {
+ Player argPlayer = Bukkit.getPlayer(args[0]);
+
+ if(argPlayer == null)
+ {
+ player.sendMessage("Player" + args[0] + " not found");
+ return false;
+
+ }
+
+ argPlayer.setHealth(20);
+ argPlayer.setFoodLevel(20);
+
+ player.sendMessage("You have healed " + argPlayer.getName());
+ argPlayer.sendMessage("You have been healed");
+ }
+ else
+ {
+ player.setHealth(20);
+ player.setFoodLevel(20);
+
+ player.sendMessage("You have been healed");
+ }
+
+ return true;
+ }
}