Skip to content

Commit

Permalink
Make Heal and Hurt not require the Health trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jun 16, 2013
1 parent d05b30f commit ffd2fa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Expand Up @@ -5,7 +5,6 @@

import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.npc.traits.HealthTrait;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.utilities.arguments.aH;
Expand Down Expand Up @@ -87,12 +86,12 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

case NPC:
NPC npc = scriptEntry.getNPC().getCitizen();
if (!npc.hasTrait(HealthTrait.class)) npc.addTrait(HealthTrait.class);

// Set health to max
if (amount == Integer.MAX_VALUE)
npc.getTrait(HealthTrait.class).setHealth(npc.getTrait(HealthTrait.class).getMaxhealth());
npc.getBukkitEntity().setHealth(npc.getBukkitEntity().getMaxHealth());
// else, set Health
else npc.getTrait(HealthTrait.class).heal(amount);
else npc.getBukkitEntity().setHealth(npc.getBukkitEntity().getHealth() + amount);
return;

case PLAYER:
Expand Down
Expand Up @@ -2,7 +2,6 @@

import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.npc.traits.HealthTrait;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.utilities.arguments.aH;
Expand Down Expand Up @@ -65,14 +64,10 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

case NPC:
NPC npc = scriptEntry.getNPC().getCitizen();
if (!npc.hasTrait(HealthTrait.class)) npc.addTrait(HealthTrait.class);
// Set health to max
if (amount == Integer.MAX_VALUE)
npc.getTrait(HealthTrait.class).setHealth(npc.getTrait(HealthTrait.class).getMaxhealth());
// else, set Health
else npc.getTrait(HealthTrait.class).heal(amount);
return;

npc.getBukkitEntity().setHealth(npc.getBukkitEntity().getHealth() - amount);
return;

case PLAYER:
Player player = scriptEntry.getPlayer();
// Injure player
Expand Down

0 comments on commit ffd2fa0

Please sign in to comment.