Skip to content

Commit

Permalink
Add "furnace burns", "furnace smelts", "piston extends", "piston retr…
Browse files Browse the repository at this point in the history
…acts", etc. world events. Remove some unused imports. Some cleanup.
  • Loading branch information
davidcernat committed Sep 14, 2013
1 parent b049450 commit dea7567
Show file tree
Hide file tree
Showing 25 changed files with 597 additions and 294 deletions.
Expand Up @@ -16,7 +16,6 @@
import net.aufdemrand.denizen.listeners.core.ItemDropListenerType.ItemDropType;
import net.aufdemrand.denizen.utilities.Utilities;
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.objects.aH.ArgumentType;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.depends.WorldGuardUtilities;

Expand Down
52 changes: 35 additions & 17 deletions src/main/java/net/aufdemrand/denizen/objects/Element.java
Expand Up @@ -3,6 +3,7 @@
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.utilities.debugging.dB;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

import java.text.DecimalFormat;
Expand Down Expand Up @@ -80,19 +81,19 @@ public Element(String prefix, String string) {
}

public double asDouble() {
return Double.valueOf(element.replace("%", ""));
return Double.valueOf(element.replaceAll("(el@)|%", ""));
}

public float asFloat() {
return Float.valueOf(element.replace("%", ""));
return Float.valueOf(element.replaceAll("(el@)|%", ""));
}

public int asInt() {
return Integer.valueOf(element.replace("%", ""));
return Integer.valueOf(element.replaceAll("(el@)|%", ""));
}

public boolean asBoolean() {
return Boolean.valueOf(element);
return Boolean.valueOf(element.replaceAll("el@", ""));
}

public String asString() {
Expand Down Expand Up @@ -341,7 +342,37 @@ public String getAttribute(Attribute attribute) {
return new Element(prefix)
.getAttribute(attribute.fulfill(1));


/////////////////////
// INITIALIZATION ATTRIBUTES
/////////////////

// <--[tag]
// @attribute <element.double[<#>]>
// @returns Element(Double)
// @description
// Returns a double from the value inside the brackets
// -->
if (attribute.startsWith("double")
&& attribute.hasContext(1)) {
return new Element(Double.valueOf(attribute.getContext(1)))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <element.int[<#>]>
// @returns Element(Integer)
// @description
// Returns an integer from the value inside the brackets, useful
// whenever <element.as_int> cannot be used.
// -->
if (attribute.startsWith("int")
&& attribute.hasContext(1)) {
return new Element(Math.round(Double.valueOf(attribute.getContext(1))))
.getAttribute(attribute.fulfill(1));
}


/////////////////////
// MATH ATTRIBUTES
/////////////////
Expand Down Expand Up @@ -380,19 +411,6 @@ public String getAttribute(Attribute attribute) {
return new Element(asDouble() / aH.getDoubleFrom(attribute.getContext(1)))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <element.int[<#>]>
// @returns Element(Integer)
// @description
// Returns an integer from the value inside the brackets, useful
// whenever <element.as_int> cannot be used.
// -->
if (attribute.startsWith("int")
&& attribute.hasContext(1)) {
return new Element(Math.round(Double.valueOf(attribute.getContext(1))))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <element.mod[<#>]>
Expand Down
Expand Up @@ -96,8 +96,8 @@ public void registerCoreMembers() {
// @Usage animate [<entity>|...] [animation:<name>]
// @Required 1
// @Stable Todo
// @Short Todo
// @Author Todo
// @Short Makes a list of entities perform a certain animation.
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -172,8 +172,8 @@ public void registerCoreMembers() {
// @Usage attack (cancel) (<entity>|...) (target:<entity>)
// @Required 0
// @Stable Todo
// @Short Causes the NPC to attack a target.
// @Author Todo
// @Short Makes a list of entities attack a target.
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -210,8 +210,8 @@ public void registerCoreMembers() {
// @Usage burn [<entity>|...] (duration:<value>)
// @Required 1
// @Stable Todo
// @Short Sets an entity on fire.
// @Author Todo
// @Short Sets a list of entities on fire.
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -744,7 +744,7 @@ public void registerCoreMembers() {
// @Required 0
// @Stable Todo
// @Short Todo
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -801,7 +801,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Todo
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -901,7 +901,7 @@ public void registerCoreMembers() {
// @Required 0
// @Stable Todo
// @Short Changes the NPC's head to look like a player's skin.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -996,7 +996,7 @@ public void registerCoreMembers() {
// @Required 2
// @Stable Todo
// @Short Todo
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1175,7 +1175,7 @@ public void registerCoreMembers() {
// @Required 0
// @Stable Todo
// @Short Mounts one entity onto another.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1307,8 +1307,8 @@ public void registerCoreMembers() {
// @Usage playeffect [<location>] [effect:<name>] (data:<#.#>) (visibility:<#.#>) (qty:<#>) (offset:<#.#>)
// @Required 2
// @Stable Todo
// @Short Plays a visible effect at the location.
// @Author Todo
// @Short Plays a visible or audible effect at the location.
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1380,22 +1380,22 @@ public void registerCoreMembers() {

// <--[command]
// @Name Push
// @Usage push [<entity>|...] (origin:<location>) (destination:<location>) (speed:<#.#>) (duration:<duration>)
// @Usage push [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (speed:<#.#>) (<duration>) (<script>)
// @Required 1
// @Stable Todo
// @Short Pushes an entity from one location to another.
// @Author Davidcernat, mcmonkey
// @Stable mostly
// @Short Pushes entities through the air in a straight line.
// @Author David Cernat
// @Description
// Todo
// Pushes entities through the air in a straight line at a certain speed and for a certain duration, triggering a script when they hit an obstacle or stop flying.
// @Tags
// Todo
// @Usage
// Todo
// @Example
// Todo
// - push e@cow destination:<l@Obelisk>
// -->
registerCoreMember(PushCommand.class,
"PUSH", "pause push [<entity>|...] (origin:<location>) (destination:<location>) (speed:<#.#>) (duration:<duration>)", 1);
"PUSH", "push [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (speed:<#.#>) (<duration>) (<script>)", 1);

// <--[command]
// @Name Queue
Expand Down Expand Up @@ -1440,8 +1440,8 @@ public void registerCoreMembers() {
// @Usage remove [<entity>|...] (region:<name>)
// @Required 0
// @Stable Todo
// @Short Despawns an entity.
// @Author Todo
// @Short Despawns a list of entities.
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1592,11 +1592,11 @@ public void registerCoreMembers() {
// @Name Shoot
// @Usage shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (gravity:<#.#>) (script:<name>))
// @Required 1
// @Stable Todo
// @Short Fires an entity from the origin to the target.
// @Author Todo
// @Stable work in progress
// @Short Shoots an entity through the air up to a certain height.
// @Author David Cernat
// @Description
// Todo
// Shoots an entity through the air up to a certain height, optionally using a custom gravity value and triggering a script on impact with a surface.
// @Tags
// Todo
// @Usage
Expand Down Expand Up @@ -1632,7 +1632,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Modifies a sign.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1670,7 +1670,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Spawns an entity.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1765,7 +1765,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Teleports the player or NPC to a new location.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand All @@ -1784,7 +1784,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Changes the current time in the minecraft world.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down Expand Up @@ -1904,7 +1904,7 @@ public void registerCoreMembers() {
// @Required 1
// @Stable Todo
// @Short Changes the current weather in the minecraft world.
// @Author Todo
// @Author David Cernat
// @Description
// Todo
// @Tags
Expand Down
Expand Up @@ -6,9 +6,6 @@
import net.aufdemrand.denizen.scripts.ScriptBuilder;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.scripts.queues.ScriptQueue;
import net.aufdemrand.denizen.scripts.queues.core.InstantQueue;
import net.aufdemrand.denizen.scripts.queues.core.TimedQueue;
import net.aufdemrand.denizen.utilities.debugging.dB;

import java.util.List;
Expand Down

0 comments on commit dea7567

Please sign in to comment.