From bc338ed4cfd83b32b7f8ed71d0885a8efe415028 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 27 May 2020 11:29:01 +0200 Subject: [PATCH] feat: add heal command --- .../de/cliffbreak/varo/commands/VaroCommand.java | 14 ++++++++++++-- .../cliffbreak/varo/commands/VaroTabCompleter.java | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/varo/src/main/java/de/cliffbreak/varo/commands/VaroCommand.java b/varo/src/main/java/de/cliffbreak/varo/commands/VaroCommand.java index 0362a37..a3c0c5b 100644 --- a/varo/src/main/java/de/cliffbreak/varo/commands/VaroCommand.java +++ b/varo/src/main/java/de/cliffbreak/varo/commands/VaroCommand.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -80,7 +81,15 @@ public class VaroCommand implements CommandExecutor { } else { sender.sendMessage("§c§lFehler: §r§cBitte überprüfe deine Eingabe."); } - + } else if (args.length == 2 && args[0].equals("heal")) { + Player p = Bukkit.getPlayerExact(args[1]); + if (p == null) { + sender.sendMessage("§c§lFehler: §r§cDer Spieler ist nicht online."); + return true; + } + p.setHealth(20.0d); + p.setFoodLevel(20); + p.setSaturation(5.0f); } else if (args.length == 1 && args[0].equals("addspawns")) { if (!(sender instanceof Player)) { sender.sendMessage("§c§lFehler: §r§cDieses Kommando kann nur von einem Spieler ausgeführt werden."); @@ -97,7 +106,7 @@ public class VaroCommand implements CommandExecutor { this.addSpawnsCounter.put(p.getUniqueId(), teamPlayerId); firstRun = true; } - final JSONArray teams = this.plugin.getTeamManager().getTeams(); + final JSONArray teams = this.plugin.getTeamManager().getJSONTeams(); final JSONObject team = (JSONObject) teams.get(teamPlayerId.team); final JSONArray players = (JSONArray) team.get("players"); @@ -139,6 +148,7 @@ public class VaroCommand implements CommandExecutor { sender.sendMessage("\n§6========== §b§lCliffbreak.de VARO §r§6============\n "); sender.sendMessage("§a/varo ban [Spieler]: §rSpieler bannen"); sender.sendMessage("§a/varo unban [Spieler]: §rSpieler wieder auf den Server lassen"); + sender.sendMessage("§a/varo heal [Spieler]: §rSpieler heilen und Hunger auffüllen"); sender.sendMessage("§a/varo portal [enable/disable]: §rAktiviere/Deaktiviere die Portal-Erstellung"); sender.sendMessage("§a/varo addspawns: §rStarte den Spawn-Erstellungs-Wizard"); sender.sendMessage("\n§6=========================================="); diff --git a/varo/src/main/java/de/cliffbreak/varo/commands/VaroTabCompleter.java b/varo/src/main/java/de/cliffbreak/varo/commands/VaroTabCompleter.java index 6d2b973..4c08088 100644 --- a/varo/src/main/java/de/cliffbreak/varo/commands/VaroTabCompleter.java +++ b/varo/src/main/java/de/cliffbreak/varo/commands/VaroTabCompleter.java @@ -25,6 +25,7 @@ public class VaroTabCompleter implements TabCompleter { if (args.length == 1) { list.add("unban"); list.add("ban"); + list.add("heal"); list.add("portal"); list.add("addspawns"); } else if (args.length == 2 && args[0].equals("unban")) { @@ -32,7 +33,7 @@ public class VaroTabCompleter implements TabCompleter { for (String uuid : bans) { list.add(this.plugin.getPlayerCache().getName(uuid)); } - } else if (args.length == 2 && args[0].equals("ban")) { + } else if (args.length == 2 && (args[0].equals("ban") || args[0].equals("heal"))) { return null; // Return null to show default player autocomplete } else if (args.length == 2 && args[0].equals("portal")) { list.add("enable");