From 05a639f4cc4b064bb66d1af0deebe72ed55f5b29 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 12 Jun 2023 10:03:03 +1000 Subject: [PATCH] SPIGOT-7350: Add methods to get hints from EnchantItemEvent By: Parker Hawke --- .../event/enchantment/EnchantItemEvent.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java index 5a3e74f90c..1829529c99 100644 --- a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java @@ -24,16 +24,20 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { private int level; private boolean cancelled; private final Map enchants; + private final Enchantment enchantmentHint; + private final int levelHint; private final Player enchanter; private final int button; - public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, final int i) { + public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, @NotNull final Enchantment enchantmentHint, final int levelHint, final int i) { super(view); this.enchanter = enchanter; this.table = table; this.item = item; this.level = level; this.enchants = new HashMap(enchants); + this.enchantmentHint = enchantmentHint; + this.levelHint = levelHint; this.cancelled = false; this.button = i; } @@ -102,6 +106,27 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { return enchants; } + /** + * Get the {@link Enchantment} that was displayed as a hint to the player + * on the selected enchantment offer. + * + * @return the hinted enchantment + */ + @NotNull + public Enchantment getEnchantmentHint() { + return enchantmentHint; + } + + /** + * Get the level of the enchantment that was displayed as a hint to the + * player on the selected enchantment offer. + * + * @return the level of the hinted enchantment + */ + public int getLevelHint() { + return levelHint; + } + /** * Which button was pressed to initiate the enchanting. *