Implement fix better

This commit is contained in:
fullwall 2012-10-12 21:40:38 +08:00
parent 042a0b5ba6
commit c0f61381b7

View File

@ -728,11 +728,13 @@ public class NPCCommands {
flags = "t", flags = "t",
permission = "npc.vulnerable") permission = "npc.vulnerable")
public void vulnerable(CommandContext args, CommandSender sender, NPC npc) { public void vulnerable(CommandContext args, CommandSender sender, NPC npc) {
boolean vulnerable = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (args.hasFlag('t')) if (args.hasFlag('t')) {
npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, !vulnerable); npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, vulnerable);
else } else {
npc.data().setPersistent(NPC.DEFAULT_PROTECTED_METADATA, !vulnerable); vulnerable = !npc.data().getPersistent(NPC.DEFAULT_PROTECTED_METADATA, true);
npc.data().setPersistent(NPC.DEFAULT_PROTECTED_METADATA, vulnerable);
}
String key = vulnerable ? Messages.VULNERABLE_SET : Messages.VULNERABLE_STOPPED; String key = vulnerable ? Messages.VULNERABLE_SET : Messages.VULNERABLE_STOPPED;
Messaging.sendTr(sender, key, npc.getName()); Messaging.sendTr(sender, key, npc.getName());
} }