From 8571f510c8af4706063bbe6a7bae8de6058fd25d Mon Sep 17 00:00:00 2001 From: mcmonkey4eva Date: Mon, 28 Oct 2013 19:43:29 -0700 Subject: [PATCH] add list.get[x].to[y] --- .../aufdemrand/denizen/CommandHandler.java | 4 +-- .../aufdemrand/denizen/objects/dEntity.java | 3 +- .../net/aufdemrand/denizen/objects/dList.java | 32 +++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/CommandHandler.java b/src/main/java/net/aufdemrand/denizen/CommandHandler.java index 10b557b11c..c320c63e59 100644 --- a/src/main/java/net/aufdemrand/denizen/CommandHandler.java +++ b/src/main/java/net/aufdemrand/denizen/CommandHandler.java @@ -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 diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 4372d9f4ed..cb13ac0e69 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -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 { diff --git a/src/main/java/net/aufdemrand/denizen/objects/dList.java b/src/main/java/net/aufdemrand/denizen/objects/dList.java index 30a973a39e..89fd437a01 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dList.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dList.java @@ -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 + // @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]