From 08d2d5c75f772ff2ae0cb3786aac525fdc0078c7 Mon Sep 17 00:00:00 2001 From: aurora Date: Mon, 31 Aug 2020 10:06:50 +0000 Subject: [PATCH] fix applying of enchant books to items after whitelist change --- .../java/com/songoda/epicenchants/commands/CommandApply.java | 3 ++- .../com/songoda/epicenchants/listeners/item/BookListener.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/epicenchants/commands/CommandApply.java b/src/main/java/com/songoda/epicenchants/commands/CommandApply.java index dbba58f..1865083 100644 --- a/src/main/java/com/songoda/epicenchants/commands/CommandApply.java +++ b/src/main/java/com/songoda/epicenchants/commands/CommandApply.java @@ -1,6 +1,7 @@ package com.songoda.epicenchants.command.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.epicenchants.CommandCommons; import com.songoda.epicenchants.EpicEnchants; import com.songoda.epicenchants.enums.EnchantResult; @@ -61,7 +62,7 @@ public class CommandApply extends AbstractCommand { int level = Integer.parseInt(args[1]); Player player = (Player) sender; - if (!enchant.getItemWhitelist().contains(player.getItemInHand().getType())) { + if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(player.getItemInHand()))) { System.out.println("List = " + enchant.getItemWhitelist()); plugin.getLocale().getMessage("command.apply.invaliditem") .processPlaceholder("enchant", enchant.getIdentifier()) diff --git a/src/main/java/com/songoda/epicenchants/listeners/item/BookListener.java b/src/main/java/com/songoda/epicenchants/listeners/item/BookListener.java index addc131..aaa8597 100644 --- a/src/main/java/com/songoda/epicenchants/listeners/item/BookListener.java +++ b/src/main/java/com/songoda/epicenchants/listeners/item/BookListener.java @@ -1,5 +1,6 @@ package com.songoda.epicenchants.listeners.item; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.epicenchants.EpicEnchants; import com.songoda.epicenchants.enums.EnchantResult; import com.songoda.epicenchants.events.EnchantApplyEvent; @@ -35,7 +36,7 @@ public class BookListener extends ItemListener { ItemStack toApply = event.getCurrentItem(); Enchant enchant = instance.getEnchantManager().getValue(cursor.getString("enchant")).orElseThrow(() -> new IllegalStateException("Book without enchant!")); - if (!enchant.getItemWhitelist().contains(current.getItem().getType())) { + if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(current.getItem()))) { return; } // get total amount of enchantments on item