Skip to content

Commit

Permalink
Fix dScript and dWorld meta.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Aug 25, 2013
1 parent 2abe69a commit 683ee4e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 30 deletions.
24 changes: 16 additions & 8 deletions src/main/java/net/aufdemrand/denizen/objects/dScript.java
Expand Up @@ -135,16 +135,20 @@ public dObject setPrefix(String prefix) {
public String getAttribute(Attribute attribute) {
if (attribute == null) return "null";

// <--
// <s@script.container_type> -> Element
// <--[tag]
// @attribute <s@script.container_type>
// @returns Element
// @description
// Returns the container type of a dScript.
// -->
if (attribute.startsWith("container_type"))
return new Element(container.getType())
.getAttribute(attribute.fulfill(1));

// <--
// <s@script.cooled_down[<player>]> -> Element(Boolean)
// <--[tag]
// @attribute <s@script.cooled_down[<player>]>
// @returns Element(Boolean)
// @descripion
// Returns true if the script has been cooled down for the
// player (defaults to current). Otherwise, returns false.
// -->
Expand All @@ -155,8 +159,10 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <s@script.requirements[<player>].check[<path>]> -> Element
// <--[tag]
// @attribute <s@script.requirements[<player>].check[<path>]>
// @returns Element
// @description
// Returns true if the player specified (defaults to current) has the
// requirement. Otherwise, returns false.
// -->
Expand All @@ -170,8 +176,10 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(2));
}

// <--
// <s@script.cooldown[<player>]> -> Duration
// <--[tag]
// @attribute <s@script.cooldown[<player>]>
// @returns Duration
// @description
// Returns the time left for the player to cooldown for the script.
// -->
if (attribute.startsWith("cooldown")) {
Expand Down
66 changes: 44 additions & 22 deletions src/main/java/net/aufdemrand/denizen/objects/dWorld.java
Expand Up @@ -128,8 +128,10 @@ public String getAttribute(Attribute attribute) {

if (attribute == null) return null;

// <--
// <world.can_generate_structures> -> Element(boolean)
// <--[tag]
// @attribute <world.can_generate_structures>
// @returns Element(boolean)
// @description
// returns whether the world will generate structures.
// -->
if (attribute.startsWith("can_generate_structures"))
Expand All @@ -151,8 +153,10 @@ public String getAttribute(Attribute attribute) {
// getWorld().getAnimalSpawnLimit())
// .getAttribute(attribute.fulfill(1));

// <--
// <world.highest_block> -> dLocation
// <--[tag]
// @attribute <world.highest_block>
// @returns dLocation
// @description
// returns the location of the highest non-air block.
// -->
if (attribute.startsWith("highest_block")) {
Expand All @@ -166,24 +170,30 @@ public String getAttribute(Attribute attribute) {

// getWorld().getChunkAt()

// <--
// <world.difficulty> -> Element
// <--[tag]
// @attribute <world.difficulty>
// @returns Element
// @description
// returns the name of the difficulty level
// -->
if (attribute.startsWith("difficulty"))
return new Element(getWorld().getDifficulty().name())
.getAttribute(attribute.fulfill(1));

// <--
// <world.name> -> Element
// <--[tag]
// @attribute <world.name>
// @returns Element
// @description
// returns the name of the world
// -->
if (attribute.startsWith("name"))
return new Element(String.valueOf(getWorld().getName()))
.getAttribute(attribute.fulfill(1));

// <--
// <world.players> -> dList(dPlayer)
// <--[tag]
// @attribute <world.players>
// @returns dList(dPlayer)
// @description
// returns a list of online players
// -->
if (attribute.startsWith("players")) {
Expand All @@ -195,16 +205,20 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <world.sea_level> -> Element(number)
// <--[tag]
// @attribute <world.sea_level>
// @returns Element(number)
// @description
// returns the level of the sea
// -->
if (attribute.startsWith("sea_level"))
return new Element(String.valueOf(getWorld().getSeaLevel()))
.getAttribute(attribute.fulfill(1));

// <--
// <world.seed> -> Element
// <--[tag]
// @attribute <world.seed>
// @returns Element
// @description
// returns the world seed
// -->
if (attribute.startsWith("seed"))
Expand All @@ -221,8 +235,10 @@ public String getAttribute(Attribute attribute) {
// .getAttribute(attribute.fulfill(1));

// Return "day", "night", "dawn" or "dusk"
// <--
// <world.time.period> -> Element
// <--[tag]
// @attribute <world.time.period>
// @returns Element
// @description
// returns the time as day, night, dawn, or dusk
// -->
if (attribute.startsWith("time.period")) {
Expand All @@ -238,24 +254,30 @@ public String getAttribute(Attribute attribute) {
return new Element(period).getAttribute(attribute.fulfill(2));
}

// <--
// <world.time> -> Element(number)
// <--[tag]
// @attribute <world.time>
// @returns Element(number)
// @description
// returns the current time in ticks
// -->
if (attribute.startsWith("time"))
return new Element(String.valueOf(getWorld().getTime()))
.getAttribute(attribute.fulfill(1));

// <--
// <world.weather_duration> -> Element
// <--[tag]
// @attribute <world.weather_duration>
// @returns Element
// @description
// returns the duration of storms in ticks
// -->
if (attribute.startsWith("weather_duration"))
return Duration.valueOf(String.valueOf(getWorld().getWeatherDuration()) + "t")
.getAttribute(attribute.fulfill(1));

// <--
// <world.has_storm> -> Element(boolean)
// <--[tag]
// @attribute <world.has_storm>
// @returns Element(boolean)
// @description
// returns whether there is currently a storm in this world
// -->
if (attribute.startsWith("has_storm"))
Expand Down

0 comments on commit 683ee4e

Please sign in to comment.