From 5f4a1be67e98033280505f1b3d8a17ffb71d7c26 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Fri, 28 Jun 2024 21:22:15 -0400 Subject: [PATCH] anvil event feedback --- .../abstraction/bukkit/BukkitMCAnvilInventory.java | 2 +- .../abstraction/events/MCPrepareAnvilEvent.java | 4 ---- .../core/events/drivers/InventoryEvents.java | 14 ++++++-------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCAnvilInventory.java b/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCAnvilInventory.java index 54a9cbd06..9961fad70 100644 --- a/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCAnvilInventory.java +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCAnvilInventory.java @@ -40,7 +40,7 @@ public int getRepairCost() { @Override public int getRepairCostAmount() { - return ai.getRepairCost(); + return ai.getRepairCostAmount(); } @Override diff --git a/src/main/java/com/laytonsmith/abstraction/events/MCPrepareAnvilEvent.java b/src/main/java/com/laytonsmith/abstraction/events/MCPrepareAnvilEvent.java index ba86becb0..dacd666d9 100644 --- a/src/main/java/com/laytonsmith/abstraction/events/MCPrepareAnvilEvent.java +++ b/src/main/java/com/laytonsmith/abstraction/events/MCPrepareAnvilEvent.java @@ -1,15 +1,11 @@ package com.laytonsmith.abstraction.events; import com.laytonsmith.abstraction.MCHumanEntity; -import com.laytonsmith.abstraction.MCInventory; import com.laytonsmith.abstraction.MCItemStack; import java.util.List; public interface MCPrepareAnvilEvent extends MCInventoryEvent { - @Override - MCInventory getInventory(); - List getViewers(); void setResult(MCItemStack i); diff --git a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java index d01596e1a..587002501 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java @@ -1002,10 +1002,10 @@ public String getName() { public String docs() { return "{}" + " Fires when a recipe is formed in an anvil, but the result has not yet been clicked." - + " { viewers: all human entities looking at this anvil " - + " | first_item: the first item in the anvil" - + " | second_item: the second item in the anvil" - + " | result: the result of the anvil" + + " { viewers: all players viewing this anvil's interface." + + " | first_item: the first item being used in the recipe." + + " | second_item: the second item being used in the recipe." + + " | result: the result of the recipe." + " | max_repair_cost: the maximum possible cost of this repair." + " | level_repair_cost: how many levels are needed to perform this repair?" + " | item_repair_cost: how many items are needed to perform this repair? }" @@ -1028,8 +1028,7 @@ public BindableEvent convert(CArray manualObject, Target t) { @Override public Map evaluate(BindableEvent event) throws EventException { - if(event instanceof MCPrepareAnvilEvent) { - MCPrepareAnvilEvent e = (MCPrepareAnvilEvent) event; + if(event instanceof MCPrepareAnvilEvent e) { MCAnvilInventory anvil = (MCAnvilInventory) e.getInventory(); Map ret = evaluate_helper(e); @@ -1059,9 +1058,8 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, BindableEvent event) { - if(event instanceof MCPrepareAnvilEvent) { + if(event instanceof MCPrepareAnvilEvent e) { Target t = value.getTarget(); - MCPrepareAnvilEvent e = (MCPrepareAnvilEvent) event; if(key.equalsIgnoreCase("result")) { e.setResult(ObjectGenerator.GetGenerator().item(value, t)); return true;