Skip to content

Commit

Permalink
Add "Animated Death" to config file at Health trait. Fix taking of na…
Browse files Browse the repository at this point in the history
…med items.
  • Loading branch information
davidcernat committed Mar 12, 2013
1 parent a94cdac commit 6a057f5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -51,7 +51,7 @@


public class Denizen extends JavaPlugin {
public final static int configVersion = 1;
public final static int configVersion = 2;
public static String versionTag = "0.8.8 pre-release";

private boolean startedSuccessful = false;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Expand Up @@ -67,6 +67,17 @@ public static boolean HealthTraitRespawnEnabled() {

/*
# Whether NPCs with the Health trait should have a death animation
*/

public static boolean HealthTraitAnimatedDeathEnabled() {
return DenizenAPI.getCurrentInstance().getConfig()
.getBoolean("Traits.Health.Animated Death.Enabled", true);
}

/*
# How long it should take for NPCs with the Health trait to respawn
*/
Expand Down
Expand Up @@ -31,7 +31,7 @@ public class HealthTrait extends Trait implements Listener {
private int currenthealth = 20;

@Persist("animatedeath")
private boolean animatedeath = true;
private boolean animatedeath = Settings.HealthTraitAnimatedDeathEnabled();
@Persist("animatedeathdelayinseconds")
private String animationDelay = "3s";

Expand Down
Expand Up @@ -90,7 +90,9 @@ public void execute(ScriptEntry scriptEntry)
scriptEntry.getPlayer().setItemInHand(newHandItem);
} else {
// amount is less than what's in hand, need to make a new itemstack of what's left...
newHandItem = new ItemStack(scriptEntry.getPlayer().getItemInHand().getType(), inHandAmt - theAmount, scriptEntry.getPlayer().getItemInHand().getData().getData());
newHandItem = new ItemStack(scriptEntry.getPlayer().getItemInHand().getType(),
inHandAmt - theAmount, scriptEntry.getPlayer().getItemInHand().getData().getData());
newHandItem.setItemMeta(scriptEntry.getPlayer().getItemInHand().getItemMeta());
scriptEntry.getPlayer().setItemInHand(newHandItem);
scriptEntry.getPlayer().updateInventory();
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Expand Up @@ -16,6 +16,8 @@ Traits:
Respawn:
Enabled: true
Delay: 10s
Animated Death:
Enabled: true

Triggers:
Chat:
Expand Down Expand Up @@ -57,4 +59,4 @@ Commands:
# configuration file is outdated or too new

Config:
Version: 1
Version: 2

0 comments on commit 6a057f5

Please sign in to comment.