Skip to content

Commit

Permalink
Add dInventory metas.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Aug 24, 2013
1 parent dea70bf commit 706a1b4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 49 deletions.
66 changes: 33 additions & 33 deletions src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -778,14 +778,14 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity>
// @return dEntity
// @returns dEntity
// @description
// Returns the dEntity of the entity.
// -->

// <--[tag]
// @attribute <e@entity.get_vehicle>
// @return dEntity
// @returns dEntity
// @description
// If the entity is in a vehicle, returns the vehicle as a
// dEntity. Else, returns null.
Expand All @@ -799,7 +799,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.custom_name>
// @return Element
// @returns Element
// @description
// If the entity has a custom name, returns the name as an
// Element. Else, returns null.
Expand All @@ -811,7 +811,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.name>
// @return Element
// @returns Element
// @description
// Returns the name of the entity.
// -->
Expand All @@ -828,7 +828,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.entity_type>
// @return Element
// @returns Element
// @description
// Returns the type of the entity.
// -->
Expand All @@ -838,7 +838,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.custom_id>
// @return dScript/Element
// @returns dScript/Element
// @description
// If the entity has a script ID, returns the dScript of that
// ID. Else, returns the name of the entity type.
Expand All @@ -854,7 +854,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.location.cursor_on>
// @return dLocation
// @returns dLocation
// @description
// Returns the dLocation of where the entity is looking.
// -->
Expand All @@ -867,7 +867,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.location.standing_on>
// @return dLocation
// @returns dLocation
// @description
// Returns the dLocation of what the entity is standing on.
// -->
Expand All @@ -877,7 +877,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.eye_location>
// @return dLocation
// @returns dLocation
// @description
// returns a dLocation of the entity's eyes.
// -->
Expand All @@ -887,7 +887,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.location>
// @return dLocation
// @returns dLocation
// @description
// Returns the dLocation of the entity.
// -->
Expand All @@ -911,7 +911,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <e@entity.health.formatted>
// @return Element
// @returns Element
// @description
// Returns a 'formatted' value of the player's current health level.
// May be 'dying', 'seriously wounded', 'injured', 'scraped', or 'healthy'.
Expand All @@ -934,7 +934,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.health.percentage>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns the entity's current health as a percentage.
// -->
Expand All @@ -948,7 +948,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.health.max>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns the maximum health of the entity.
// -->
Expand All @@ -958,7 +958,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.health>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns the current health of the entity.
// -->
Expand All @@ -968,7 +968,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.is_inside_vehicle>
// @return Element(Boolean)
// @returns Element(Boolean)
// @description
// Returns true if the entity is inside a vehicle. Else, returns false.
// -->
Expand All @@ -978,7 +978,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.killer>
// @return dPlayer
// @returns dPlayer
// @description
// Returns the player that last killed the entity.
// -->
Expand All @@ -988,7 +988,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.last_damage.cause>
// @return Element
// @returns Element
// @description
// Returns the cause of the last damage taken by the entity.
// -->
Expand All @@ -998,7 +998,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.last_damage.amount>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns the amount of the last damage taken by the entity.
// -->
Expand All @@ -1008,7 +1008,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.last_damage.duration>
// @return Duration
// @returns Duration
// @description
// Returns the duration of the last damage taken by the entity.
// -->
Expand All @@ -1018,7 +1018,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.time_lived>
// @return Duration
// @returns Duration
// @description
// Returns how long the entity has lived.
// -->
Expand All @@ -1028,7 +1028,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.can_see[<entity>]>
// @return Element(Boolean)
// @returns Element(Boolean)
// @description
// Returns true if the entity can see the other entity.
// -->
Expand All @@ -1041,7 +1041,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.can_pickup_items>
// @return Element(Boolean)
// @returns Element(Boolean)
// @description
// Returns true if the entity can pick up items. Else, returns false.
// -->
Expand All @@ -1051,7 +1051,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.eid>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns the entity's Bukkit entity ID
// -->
Expand All @@ -1061,7 +1061,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.fall_distance>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns how far the entity has fallen.
// -->
Expand All @@ -1071,7 +1071,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <e@entity.uuid>
// @return Element(Number)
// @returns Element(Number)
// @description
// Returns a unique ID for the entity.
// -->
Expand All @@ -1081,7 +1081,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.has_effect[<effect>]>
// @return Element(Boolean)
// @returns Element(Boolean)
// @description
// Returns true if the entity has an effect. If no effect is
// specified, returns true if the entity has any effect. Else,
Expand All @@ -1099,7 +1099,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.equipment>
// @return dInventory
// @returns dInventory
// @description
// Returns the dInventory of the entity.
// -->
Expand All @@ -1109,7 +1109,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.world>
// @return dWorld
// @returns dWorld
// @description
// Returns the world the entity is in.
// -->
Expand All @@ -1120,7 +1120,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.prefix>
// @return Element
// @returns Element
// @description
// Returns the prefix of the entity.
// -->
Expand All @@ -1130,7 +1130,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.debug.log>
// @return Element(Boolean)
// @returns Element(Boolean)
// @description
// Debugs the entity in the log and returns true.
// -->
Expand All @@ -1142,7 +1142,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.debug.no_color>
// @return Element
// @returns Element
// @description
// Returns the entity's debug with no color.
// -->
Expand All @@ -1153,7 +1153,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.debug>
// @return Element
// @returns Element
// @description
// Returns the entity's debug.
// -->
Expand All @@ -1164,7 +1164,7 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)

// <--[tag]
// @attribute <entity.type>
// @return Element
// @returns Element
// @description
// Returns 'Entity', the type of this dObject.
// -->
Expand Down
48 changes: 32 additions & 16 deletions src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -669,8 +669,10 @@ public String getAttribute(Attribute attribute) {

if (attribute == null) return null;

// <--
// <inventory.contains[<item>].qty[<#>]> -> Element(Number)
// <--[tag]
// @attribute <i@inventory.contains[<item>].qty[<#>]>
// @returns Element(Number)
// @description
// Check if the inventory contains a certain quantity (1 by default) of an item
// and return true or false
// -->
Expand All @@ -692,8 +694,10 @@ public String getAttribute(Attribute attribute) {
}
}

// <--
// <inventory.location> -> dLocation
// <--[tag]
// @attribute <i@inventory.location>
// @returns dLocation
// @description
// Returns the location of this inventory's holder.
// -->
if (attribute.startsWith("location")) {
Expand All @@ -702,8 +706,10 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <inventory.qty[<item>]> -> Element(Number)
// <--[tag]
// @attribute <i@inventory.qty[<item>]>
// @returns Element(Number)
// @description
// Returns the combined quantity of itemstacks that match an item if
// one if specified, or the combined quantity of all itemstacks
// if one is not
Expand All @@ -717,16 +723,20 @@ public String getAttribute(Attribute attribute) {
return new Element(String.valueOf(count(null, false)))
.getAttribute(attribute.fulfill(1));

// <--
// <inventory.size> -> Element(Number)
// <--[tag]
// @attribute <i@inventory.size>
// @returns Element(Number)
// @description
// Return the number of slots in the inventory
// -->
if (attribute.startsWith("size"))
return new Element(String.valueOf(getSize()))
.getAttribute(attribute.fulfill(1));

// <--
// <inventory.stacks> -> Element(Number)
// <--[tag]
// @attribute <i@inventory.stacks>
// @returns Element(Number)
// @description
// Returns the number of itemstacks that match an item if one is
// specified, or the number of all itemstacks if one is not
// -->
Expand All @@ -739,16 +749,20 @@ public String getAttribute(Attribute attribute) {
return new Element(String.valueOf(count(null, true)))
.getAttribute(attribute.fulfill(1));

// <--
// <inventory.type> -> Element
// <--[tag]
// @attribute <i@inventory.type>
// @returns Element
// @description
// Returns the type of the inventory (e.g. "PLAYER", "CRAFTING", "HORSE")
// -->
if (attribute.startsWith("type"))
return new Element(getInventory().getType().name())
.getAttribute(attribute.fulfill(1));

// <--
// <inventory.equipment> -> dInventory(Equipment)
// <--[tag]
// @attribute <i@inventory.equipment>
// @returns dInventory(Equipment)
// @description
// Returns the equipment of an inventory. If the inventory has no
// equipment (Generally, if it's not alive), this returns null.
// -->
Expand Down Expand Up @@ -780,8 +794,10 @@ else if (getInventory() instanceof HorseInventory) {
}
}

// <--
// <inventory.list_contents> -> dList(dItem)
// <--[tag]
// @attribute <i@inventory.list_contents>
// @returns dList(dItem)
// @description
// Returns a list of all items in the inventory.
// -->
if (attribute.startsWith("list_contents")) {
Expand Down

0 comments on commit 706a1b4

Please sign in to comment.