Skip to content

Commit

Permalink
Document dWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 9, 2013
1 parent 7b48127 commit 62bf391
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dWorld.java
Expand Up @@ -130,6 +130,10 @@ public String getAttribute(Attribute attribute) {

if (attribute == null) return null;

// <--
// <world.can_generate_structures> -> Element(boolean)
// returns whether the world will generate structures.
// -->
if (attribute.startsWith("can_generate_structures"))
return new Element(String.valueOf(getWorld().canGenerateStructures()))
.getAttribute(attribute.fulfill(1));
Expand All @@ -149,6 +153,10 @@ public String getAttribute(Attribute attribute) {
// getWorld().getAnimalSpawnLimit())
// .getAttribute(attribute.fulfill(1));

// <--
// <world.highest_block> -> dLocation
// returns the location of the highest non-air block.
// -->
if (attribute.startsWith("highest_block")) {
// TODO: finish
int x = 1;
Expand All @@ -160,14 +168,26 @@ public String getAttribute(Attribute attribute) {

// getWorld().getChunkAt()

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

// <--
// <world.name> -> Element
// 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)
// returns a list of online players
// -->
if (attribute.startsWith("players")) {
List<String> players = new ArrayList<String>();
for(Player player : getWorld().getPlayers())
Expand All @@ -177,10 +197,18 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <world.sea_level> -> Element(number)
// 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
// returns the world seed
// -->
if (attribute.startsWith("seed"))
return new Element(String.valueOf(getWorld().getSeed()))
.getAttribute(attribute.fulfill(1));
Expand All @@ -195,6 +223,10 @@ public String getAttribute(Attribute attribute) {
// .getAttribute(attribute.fulfill(1));

// Return "day", "night", "dawn" or "dusk"
// <--
// <world.time.period> -> Element
// returns the time as day, night, dawn, or dusk
// -->
if (attribute.startsWith("time.period")) {

long time = getWorld().getTime();
Expand All @@ -208,14 +240,26 @@ public String getAttribute(Attribute attribute) {
return new Element(period).getAttribute(attribute.fulfill(2));
}

// <--
// <world.time> -> Element(number)
// 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
// 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)
// returns whether there is currently a storm in this world
// -->
if (attribute.startsWith("has_storm"))
return new Element(String.valueOf(getWorld().hasStorm()))
.getAttribute(attribute.fulfill(1));
Expand Down

0 comments on commit 62bf391

Please sign in to comment.