-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/mcmonkey4eva/Denizen
- Loading branch information
Showing
5 changed files
with
173 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityAnger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package net.aufdemrand.denizen.objects.properties.entity; | ||
|
||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.Mechanism; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.objects.properties.Property; | ||
import net.aufdemrand.denizencore.tags.Attribute; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.PigZombie; | ||
|
||
public class EntityAnger implements Property { | ||
|
||
public static boolean describes(dObject entity) { | ||
return entity instanceof dEntity && ((dEntity) entity).getBukkitEntityType() == EntityType.PIG_ZOMBIE; | ||
} | ||
|
||
public static EntityAnger getFrom(dObject entity) { | ||
if (!describes(entity)) return null; | ||
|
||
else return new EntityAnger((dEntity) entity); | ||
} | ||
|
||
/////////////////// | ||
// Instance Fields and Methods | ||
///////////// | ||
|
||
private EntityAnger(dEntity entity) { | ||
this.entity = entity; | ||
} | ||
|
||
dEntity entity; | ||
|
||
///////// | ||
// Property Methods | ||
/////// | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return String.valueOf(((PigZombie) entity.getBukkitEntity()).getAnger()); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "anger"; | ||
} | ||
|
||
/////////// | ||
// dObject Attributes | ||
//////// | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
|
||
if (attribute == null) return "null"; | ||
|
||
// <--[tag] | ||
// @attribute <e@entity.anger> | ||
// @returns Element(Integer) | ||
// @mechanism dEntity.anger | ||
// @group properties | ||
// @description | ||
// Returns the anger level of a PigZombie. | ||
// --> | ||
if (attribute.startsWith("anger")) { | ||
if (entity.getBukkitEntityType() == EntityType.PIG_ZOMBIE) { | ||
return new Element(((PigZombie) entity.getBukkitEntity()).getAnger()) | ||
.getAttribute(attribute.fulfill(1)); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object dEntity | ||
// @name anger | ||
// @input Element(Boolean) | ||
// @description | ||
// Changes the anger level of a PigZombie. | ||
// @tags | ||
// <e@entity.anger> | ||
// --> | ||
|
||
if (mechanism.matches("anger") && mechanism.requireInteger()) { | ||
if (entity.getBukkitEntityType() == EntityType.PIG_ZOMBIE) { | ||
((PigZombie) entity.getBukkitEntity()).setAnger(mechanism.getValue().asInt()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters