Skip to content

Commit

Permalink
Add contexts 'button' and 'cost' and an XP determination to "on item …
Browse files Browse the repository at this point in the history
…enchanted"
  • Loading branch information
Morphan1 committed Dec 29, 2014
1 parent f923e81 commit ac05a64
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -2444,8 +2444,11 @@ else if (dItem.matches(determination)) {
// <context.location> returns the dLocation of the enchanting table.
// <context.inventory> returns the dInventory of the enchanting table.
// <context.item> returns the dItem to be enchanted.
// <context.button> returns which button was pressed to initiate the enchanting.
// <context.cost> 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.
//
// -->
Expand All @@ -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",
Expand All @@ -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]
Expand Down

0 comments on commit ac05a64

Please sign in to comment.