Skip to content

Commit

Permalink
add list.get[x].to[y]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 29, 2013
1 parent e8984bb commit 8571f51
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/aufdemrand/denizen/CommandHandler.java
Expand Up @@ -742,14 +742,14 @@ public void run() {
// To enable debugging mode, simply type '/denizen debug'. While debug is enabled, all debuggable
// scripts, and any invoked actions, will output information to the console as they are executed.
// By default, all scripts are debuggable while the dBugger is enabled. To disable a script
// specifically from debugging, simply add the'debug:' node with a value of 'false' to your script
// specifically from debugging, simply add the 'debug:' node with a value of 'false' to your script
// container. This is typically used to silence particularly spammy scripts. Any kind of script
// container can be silenced using this method.
//
// To stop debugging, simply type the '/denizen debug' command again. This must be used without
// any additional options. A message will be sent to show the current status of the dBugger.
// Note: While your server is in 'live production mode', the dBugger should be disabled as your
// server will run more slowly outputting debug information.
// server will run slower while outputting debug information.
//
// There are also several options to further help debugging. To use an option, simply attach them
// to the /denizen debug command. One option, or multiple options can be used. For example: /denizen debug -ce
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -592,7 +592,8 @@ public World getWorld() {

public void spawnAt(Location location) {
// If the entity is already spawned, teleport it.
if (npc != null) npc.teleport(location, TeleportCause.PLUGIN);

if (isNPC()) getNPC().teleport(location, TeleportCause.PLUGIN);
else if (entity != null && isUnique()) entity.teleport(location);

else {
Expand Down
32 changes: 26 additions & 6 deletions src/main/java/net/aufdemrand/denizen/objects/dList.java
Expand Up @@ -364,12 +364,32 @@ public String getAttribute(Attribute attribute) {
attribute.hasContext(1)) {
if (isEmpty()) return "null";
int index = attribute.getIntContext(1);
if (index > size()) return "null";
String item;
if (index > 0) item = get(index - 1);
else item = get(0);

return new Element(item).getAttribute(attribute.fulfill(1));
if (index > size()) index = size();
if (index < 1) index = 1;
attribute = attribute.fulfill(1);

// <--[tag]
// @attribute <li@list.get[#].to[#]>
// @returns dList
// @description
// returns all elements in the range from the first index to the second.
// -->
if (attribute.startsWith("to") &&
attribute.hasContext(1)) {
int index2 = attribute.getIntContext(1);
if (index2 > size()) index2 = size();
if (index2 < 1) index2 = 1;
String item = "";
for (int i = index; i <= index2; i++) {
item += get(i - 1) + (i < index2 ? "|": "");
}
return new dList(item).getAttribute(attribute.fulfill(1));
}
else {
String item;
item = get(index - 1);
return new Element(item).getAttribute(attribute);
}
}

// <--[tag]
Expand Down

0 comments on commit 8571f51

Please sign in to comment.