Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open fun parseBackEnchantments(enchantments : List<String>, item : ItemStack) {
- enchantments.forEach {
- //Gets the enchantment before the : from the parseToEnchantments method below\\
- val enchantment = Enchantment.getByName(it.split(":")[0])
- //Gets the enchantment value after the : from the parseToEnchantments method below\\
- val enchantmentValue = Ints.tryParse(it.split(":")[1]) ?: 0
- //Adds the enchantments accordingly
- item.addUnsafeEnchantment(enchantment, enchantmentValue)
- }
- }
- open fun parseToEnchants(enchantments : Map<Enchantment, Int>) : List<String> =
- //Maps the values into a string list so the enchantments go into the config like\\
- // ENCHANTMENT:VALUE \\
- enchantments.map { "${it.key.name}:${it.value}" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement