Skip to content

Commit

Permalink
add exhaustion control, fixes #1464
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 13, 2016
1 parent 4326455 commit 75ec5ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -1132,6 +1132,17 @@ else if (attribute.startsWith("uuid") && !isOnline())
.getAttribute(attribute.fulfill(2));
}

// <--[tag]
// @attribute <p@player.exhaustion>
// @returns Element(Decimal)
// @description
// Returns how fast the food level drops (exhaustion).
// -->
if (attribute.startsWith("exhaustion")) {
return new Element(getPlayerEntity().getExhaustion())
.getAttribute(attribute.fulfill(1));
}

// Handle dEntity oxygen tags here to allow getting them when the player is offline
if (attribute.startsWith("oxygen.max")) {
return new Duration((long) getMaximumAir()).getAttribute(attribute.fulfill(2));
Expand Down Expand Up @@ -2522,6 +2533,19 @@ public void adjust(Mechanism mechanism) {
getPlayerEntity().setWalkSpeed(value.asFloat());
}

// <--[mechanism]
// @object dPlayer
// @name exhaustion
// @input Element(Decimal)
// @description
// Sets the exhaustion level of a player.
// @tags
// <p@player.exhaustion>
// -->
if (mechanism.matches("exhaustion") && mechanism.requireFloat()) {
getPlayerEntity().setExhaustion(value.asFloat());
}

// <--[mechanism]
// @object dPlayer
// @name show_entity
Expand Down
Expand Up @@ -100,7 +100,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
if (custom.asBoolean()) {
for (dLocation location : locations) {
for (Player player : location.getWorld().getPlayers())
// Note: Randomly defining 100 blocks as maximum hear distance.
// Note: Randomly defining 100 blocks as maximum hearing distance.
{
if (player.getLocation().distanceSquared(location) < 100 * 100) {
player.playSound(location, sound.asString(),
Expand Down

0 comments on commit 75ec5ab

Please sign in to comment.