From 2c99c062b66e703c525fda9068c548cb95d9f599 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 9 Sep 2012 21:39:53 +0800 Subject: [PATCH] Add /npc vulnerable command --- .../command/command/NPCCommands.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 2127244de..603f658d9 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -622,4 +622,24 @@ public class NPCCommands { npc.getBukkitEntity().teleport(player, TeleportCause.COMMAND); Messaging.send(player, StringHelper.wrap(npc.getName()) + " was teleported to your location."); } + + @Command( + aliases = { "npc" }, + usage = "vulnerable (-t)", + desc = "Toggles an NPC's vulnerability", + modifiers = { "vulnerable" }, + min = 1, + max = 1, + flags = "t", + permission = "npc.vulnerable") + public void vulnerable(CommandContext args, CommandSender sender, NPC npc) { + boolean vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); + if (args.hasFlag('t')) + npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, vulnerable); + else + npc.data().setPersistent(NPC.DEFAULT_PROTECTED_METADATA, vulnerable); + + Messaging.sendF(sender, ChatColor.GREEN + "%s is %s vulnerable.", StringHelper.wrap(npc.getName()), + vulnerable ? "now" : "no longer"); + } } \ No newline at end of file