fix applying of enchant books to items after whitelist change

This commit is contained in:
aurora 2020-08-31 10:06:50 +00:00
parent de8c6e69e4
commit 08d2d5c75f
2 changed files with 4 additions and 2 deletions

View File

@ -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())

View File

@ -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