From ac05a64559138741200e6bb79c75a26568a3fe40 Mon Sep 17 00:00:00 2001 From: Morphan1 Date: Mon, 29 Dec 2014 00:27:18 -0500 Subject: [PATCH] Add contexts 'button' and 'cost' and an XP determination to "on item enchanted" --- .../denizen/scripts/containers/core/WorldScriptHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java index 765f8bd26f..9e168d2c98 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java @@ -2444,8 +2444,11 @@ else if (dItem.matches(determination)) { // returns the dLocation of the enchanting table. // returns the dInventory of the enchanting table. // returns the dItem to be enchanted. + // returns which button was pressed to initiate the enchanting. + // returns the experience level cost of the enchantment. // // @Determine + // Element(Number) to set the experience level cost of the enchantment. // "CANCELLED" to stop the item from being enchanted. // // --> @@ -2460,6 +2463,7 @@ public void enchantItemEvent(EnchantItemEvent event) { context.put("location", new dLocation(event.getEnchantBlock().getLocation())); context.put("inventory", dInventory.mirrorBukkitInventory(event.getInventory())); context.put("item", item); + context.put("button", new Element(event.whichButton())); String determination = EventManager.doEvents(Arrays.asList ("item enchanted", @@ -2468,6 +2472,8 @@ public void enchantItemEvent(EnchantItemEvent event) { if (determination.toUpperCase().startsWith("CANCELLED")) event.setCancelled(true); + else if (Argument.valueOf(determination).matchesPrimitive(PrimitiveType.Integer)) + event.setExpLevelCost(Integer.valueOf(determination)); } // <--[language]