From 213e0d103d8f113cdd61959980a0ab6bbf7d04e1 Mon Sep 17 00:00:00 2001 From: Jeremy Schroeder Date: Sat, 3 Aug 2013 13:55:24 -0400 Subject: [PATCH] add --- .../aufdemrand/denizen/CommandHandler.java | 3 +- .../listeners/core/KillListenerInstance.java | 9 +- .../net/aufdemrand/denizen/objects/dItem.java | 5 +- .../aufdemrand/denizen/objects/dLocation.java | 89 ++++++++++--------- 4 files changed, 55 insertions(+), 51 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/CommandHandler.java b/src/main/java/net/aufdemrand/denizen/CommandHandler.java index 7ef3142ac5..411668395e 100644 --- a/src/main/java/net/aufdemrand/denizen/CommandHandler.java +++ b/src/main/java/net/aufdemrand/denizen/CommandHandler.java @@ -736,7 +736,8 @@ public void version(CommandContext args, CommandSender sender, NPC npc) throws C desc = "Saves the current state of Denizen/saves.yml.", modifiers = { "save" }, min = 1, max = 3, permission = "denizen.basic", flags = "s") public void save(CommandContext args, CommandSender sender, NPC npc) throws CommandException { - ((Denizen) plugin.getServer().getPluginManager().getPlugin("Denizen")).saveSaves(); + + DenizenAPI.getCurrentInstance().saveSaves(); Messaging.send(sender, ChatColor.GREEN + "Denizen/saves.yml saved to disk from memory."); } diff --git a/src/main/java/net/aufdemrand/denizen/listeners/core/KillListenerInstance.java b/src/main/java/net/aufdemrand/denizen/listeners/core/KillListenerInstance.java index 9810006392..597d209cd3 100644 --- a/src/main/java/net/aufdemrand/denizen/listeners/core/KillListenerInstance.java +++ b/src/main/java/net/aufdemrand/denizen/listeners/core/KillListenerInstance.java @@ -59,7 +59,6 @@ public String report() { @Override public void onBuild(List args) { - // Build the listener from script arguments. onBuild() is called when a new listener is // made with the LISTEN command. All arguments except type, id, and script // are passed through to here. @@ -98,7 +97,6 @@ else if (arg.matchesPrefix("targets, target, t, name, names")) @Override public void onLoad() { - // Build the listener from saved data. id and type are saved automatically. // onBuild() will not be called, this should handle everything onBuild() would with the // saved data from onSave(). @@ -115,7 +113,6 @@ public void onLoad() { @Override public void onSave() { - // If the player leaves the game while a listener is in progress, save the information // so that it can be rebuilt onLoad(). id and type are done automatically. store("Type", type.name()); @@ -149,7 +146,6 @@ public void onCancel() { @Override public void constructed() { - // Called after build and load methods. Perfect place to register // any bukkit events! denizen.getServer().getPluginManager().registerEvents(this, denizen); @@ -161,18 +157,17 @@ public void constructed() { @Override public void deconstructed() { - // Called when the instance is deconstructed due to either it being // saved, finished, or cancelled. // This is the perfect place to unregister any bukkit events so it // can be cleanly removed from memory. + EntityDeathEvent.getHandlerList().unregister(this); } @EventHandler public void listen(EntityDeathEvent event) { - // Only continue if the event is an event for the player that owns this listener. if (event.getEntity().getKiller() != player.getPlayerEntity()) return; @@ -290,12 +285,12 @@ else if (type == KillType.GROUP) { public void check() { - // Check current kills vs. required kills; finish() if necessary. if (kills_so_far >= required) finish(); } + @EventHandler public void listenTag(ReplaceableTagEvent event) { diff --git a/src/main/java/net/aufdemrand/denizen/objects/dItem.java b/src/main/java/net/aufdemrand/denizen/objects/dItem.java index 91447c9b9c..500fe23bb5 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dItem.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dItem.java @@ -78,7 +78,6 @@ public static void remove(String id) { //////////////// public static dItem valueOf(String string) { - return valueOf(string, null, null); } @@ -352,7 +351,7 @@ public int comparesTo(ItemStack item) { * Check whether this item contains a lore that starts * with a certain prefix. * - * @param String The prefix + * @param prefix The prefix * @return True if it does, otherwise false * */ @@ -373,7 +372,7 @@ public boolean containsLore(String prefix) { * Get the lore from this item that starts with a * certain prefix. * - * @param String The prefix + * @param prefix The prefix * @return String The lore * */ diff --git a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java index c6fe245ed4..c1140548f0 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java @@ -302,7 +302,7 @@ public String getAttribute(Attribute attribute) { if (attribute == null) return null; // <-- - // -> Element + // -> Element // Returns the formatted biome name at the location. // --> if (attribute.startsWith("biome.formatted")) @@ -310,7 +310,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(2)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the current humidity at the location. // --> if (attribute.startsWith("biome.humidity")) @@ -318,7 +318,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(2)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the current temperature at the location. // --> if (attribute.startsWith("biome.temperature")) @@ -326,7 +326,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(2)); // <-- - // -> Element + // -> Element // Returns Bukkit biome name at the location. // --> if (attribute.startsWith("biome")) @@ -334,7 +334,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(1)); // <-- - // -> dLocation + // -> dLocation // Returns the dLocation of the block below the location. // --> if (attribute.startsWith("block.below")) @@ -342,7 +342,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(2)); // <-- - // -> dLocation + // -> dLocation // Returns the dLocation of the block above the location. // --> if (attribute.startsWith("block.above")) @@ -350,7 +350,7 @@ public String getAttribute(Attribute attribute) { .getAttribute(attribute.fulfill(2)); // <-- - // -> dLocation + // -> dLocation // Adds to location coordinates, and returns the sum. // --> if (attribute.startsWith("add")) { @@ -367,7 +367,7 @@ public String getAttribute(Attribute attribute) { } // <-- - // -> dLocation + // -> dLocation // Returns the dLocation with pitch and yaw. // --> if (attribute.startsWith("with_pose")) { @@ -395,7 +395,7 @@ public String getAttribute(Attribute attribute) { attribute.fulfill(1); // <-- - // |...].within[X]> -> dList + // |...].within[X]> -> dList // Returns a dList of blocks within a radius. // --> if (attribute.startsWith("blocks") @@ -432,7 +432,7 @@ public int compare(dLocation loc1, dLocation loc2) { } // <-- - // |...].within[X]> -> dList + // |...].within[X]> -> dList // Returns a dList of surface blocks within a radius. // --> else if (attribute.startsWith("surface_blocks") @@ -477,7 +477,7 @@ public int compare(dLocation loc1, dLocation loc2) { } // <-- - // -> dList + // -> dList // Returns a dList of players within a radius. // --> else if (attribute.startsWith("players") @@ -501,7 +501,7 @@ public int compare(dPlayer pl1, dPlayer pl2) { } // <-- - // -> dList + // -> dList // Returns a dList of entities within a radius. // --> else if (attribute.startsWith("entities") @@ -528,7 +528,7 @@ public int compare(dEntity ent1, dEntity ent2) { } // <-- - // -> Element + // -> Element // Returns the Bukkit material name of the block at the // location. // --> @@ -537,7 +537,7 @@ public int compare(dEntity ent1, dEntity ent2) { // <-- - // -> Element + // -> Element // Returns the compass direction of the block or entity // at the location. // --> @@ -559,7 +559,7 @@ public int compare(dEntity ent1, dEntity ent2) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the distance between 2 locations. // --> if (attribute.startsWith("distance")) { @@ -567,13 +567,13 @@ public int compare(dEntity ent1, dEntity ent2) { dLocation toLocation = dLocation.valueOf(attribute.getContext(1)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the horizontal distance between 2 locations. // --> if (attribute.getAttribute(2).startsWith("horizontal")) { // <-- - // -> Element(Number) + // -> Element(Number) // Returns the horizontal distance between 2 multiworld locations. // --> if (attribute.getAttribute(3).startsWith("multiworld")) @@ -589,13 +589,13 @@ else if (this.getWorld() == toLocation.getWorld()) } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the vertical distance between 2 locations. // --> else if (attribute.getAttribute(2).startsWith("vertical")) { // <-- - // -> Element(Number) + // -> Element(Number) // Returns the vertical distance between 2 multiworld locations. // --> if (attribute.getAttribute(3).startsWith("multiworld")) @@ -612,7 +612,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) } // <-- - // -> Element + // -> Element // Returns the simple version of a dLocation. // --> if (attribute.startsWith("simple")) @@ -620,7 +620,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) + "," + getWorld().getName()).getAttribute(attribute.fulfill(1)); // <-- - // -> Element + // -> Element // Returns the formatted simple version of a dLocation. // --> if (attribute.startsWith("formatted.simple")) @@ -630,7 +630,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) + "', in world '" + getWorld().getName() + "'").getAttribute(attribute.fulfill(2)); // <-- - // -> Element + // -> Element // Returns the formatted version of a dLocation. // --> if (attribute.startsWith("formatted")) @@ -640,7 +640,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) + "', in world '" + getWorld().getName() + "'").getAttribute(attribute.fulfill(1)); // <-- - // -> Element(Boolean) + // -> Element(Boolean) // If the block at the location is a liquid, return // true. Otherwise, returns false. // --> @@ -649,7 +649,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) // <-- - // -> Element(Number) + // -> Element(Number) // Returns the amount of light from blocks that is // on the location. // --> @@ -659,7 +659,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) .getAttribute(attribute.fulfill(2)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the amount of light from the sky that is // on the location. // --> @@ -669,7 +669,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) .getAttribute(attribute.fulfill(2)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the total amount of light on the location. // --> if (attribute.startsWith("light")) @@ -677,7 +677,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) .getAttribute(attribute.fulfill(1)); // <-- - // -> Element(Number) + // -> Element(Number) // Returns the pitch of the object at the location. // --> if (attribute.startsWith("pitch")) { @@ -685,7 +685,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the raw yaw of the object at the location. // --> if (attribute.startsWith("yaw.raw")) { @@ -694,7 +694,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the normalized yaw of the object at the location. // --> if (attribute.startsWith("yaw")) { @@ -703,7 +703,7 @@ else return new Element(String.valueOf(this.distance(toLocation))) } // <-- - // ]> -> Element(Boolean) + // ]> -> Element(Boolean) // Returns true if the location's yaw is facing another // entity or location. Otherwise, returns false. // --> @@ -745,7 +745,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the current power level of a block. // --> if (attribute.startsWith("power")) @@ -753,7 +753,7 @@ else if (dEntity.matches(attribute.getContext(1))) { .getAttribute(attribute.fulfill(1)); // <-- - // ]> -> Element(Boolean) + // ]> -> Element(Boolean) // If a region name is specified, returns true if the // location is in that region, else it returns true if // the location is in any region. Otherwise, returns false. @@ -781,7 +781,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> dList + // -> dList // Returns the list of regions that the location is in. // --> if (attribute.startsWith("regions")) { @@ -790,7 +790,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> dWorld + // -> dWorld // Returns the dWorld that the location is in. // --> if (attribute.startsWith("world")) { @@ -807,7 +807,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the Y coordinate of the block. // --> if (attribute.startsWith("block.y")) { @@ -815,7 +815,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the Z coordinate of the block. // --> if (attribute.startsWith("block.z")) { @@ -823,7 +823,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the X coordinate of the location. // --> if (attribute.startsWith("x")) { @@ -831,7 +831,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the Y coordinate of the location. // --> if (attribute.startsWith("y")) { @@ -839,7 +839,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> Element(Number) + // -> Element(Number) // Returns the Z coordinate of the location. // --> if (attribute.startsWith("z")) { @@ -847,7 +847,7 @@ else if (dEntity.matches(attribute.getContext(1))) { } // <-- - // -> dList + // -> dList // Returns a list of lines on a sign. // --> if (attribute.startsWith("block.sign_contents")) { @@ -858,6 +858,15 @@ else if (dEntity.matches(attribute.getContext(1))) { else return "null"; } + // <-- + // -> dLocation + // Returns the location of the block at x,z with the highest y. + // --> + if (attribute.startsWith("highest_y")) { + return new dLocation(getWorld().getHighestBlockAt(this).getLocation()) + .getAttribute(attribute.fulfill(1)); + } + return new Element(identify()).getAttribute(attribute.fulfill(0)); }