Added on-books for soulbound

This commit is contained in:
Auxilor 2021-05-04 10:24:55 +01:00
parent 56bbc56a6f
commit 3c8b39d7ac
2 changed files with 10 additions and 5 deletions

View File

@ -63,10 +63,12 @@ public class Soulbound extends EcoEnchant {
soulboundItems.add(itemStack);
}
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "on-books")) {
if (itemStack.getItemMeta() instanceof EnchantmentStorageMeta && (((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this.getEnchantment()))) {
soulboundItems.add(itemStack);
}
}
}
event.getDrops().removeAll(soulboundItems);
@ -77,9 +79,11 @@ public class Soulbound extends EcoEnchant {
container.set(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER, 1);
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "remove-after")) {
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "on-books")) {
if (meta instanceof EnchantmentStorageMeta) {
((EnchantmentStorageMeta) meta).removeStoredEnchant(this);
}
}
meta.removeEnchant(this);
}

View File

@ -21,3 +21,4 @@ general-config:
config:
remove-after: false # If soulbound should be 1-time use
on-books: true # If soulbound should work on books