mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-25 20:17:38 +01:00
Added support for lore conversion on enchanted books
This commit is contained in:
parent
b9a46d5494
commit
21fd92ef58
@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class HoldItemListener implements Listener {
|
|||||||
List<String> lore = meta.getLore();
|
List<String> lore = meta.getLore();
|
||||||
|
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
lore = new ArrayList<>();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String line : new ArrayList<>(lore)) {
|
for (String line : new ArrayList<>(lore)) {
|
||||||
@ -77,8 +78,13 @@ public class HoldItemListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enchant != null) {
|
if (enchant != null) {
|
||||||
lore.remove(rawLine);
|
if (meta instanceof EnchantmentStorageMeta) {
|
||||||
|
((EnchantmentStorageMeta) meta).addStoredEnchant(enchant, level, true);
|
||||||
|
lore.clear();
|
||||||
|
} else {
|
||||||
meta.addEnchant(enchant, level, true);
|
meta.addEnchant(enchant, level, true);
|
||||||
|
lore.remove(rawLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user