Avoid overriding left item name on custom name. fix #8

Also version up for convenience.
This commit is contained in:
alexcrea 2024-04-23 02:24:23 +02:00
parent 76fc354127
commit 2861238f58
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
3 changed files with 6 additions and 3 deletions

View file

@ -4,7 +4,7 @@ plugins {
} }
group = "xyz.alexcrea" group = "xyz.alexcrea"
version = "1.4.1a" version = "1.4.2a"
repositories { repositories {
mavenCentral() mavenCentral()

View file

@ -9,6 +9,7 @@ import io.delilaheve.util.ItemUtil.isEnchantedBook
import io.delilaheve.util.ItemUtil.repairFrom import io.delilaheve.util.ItemUtil.repairFrom
import io.delilaheve.util.ItemUtil.setEnchantmentsUnsafe import io.delilaheve.util.ItemUtil.setEnchantmentsUnsafe
import io.delilaheve.util.ItemUtil.unitRepair import io.delilaheve.util.ItemUtil.unitRepair
import org.bukkit.ChatColor
import org.bukkit.GameMode import org.bukkit.GameMode
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.entity.Player import org.bukkit.entity.Player
@ -161,7 +162,9 @@ class AnvilEventListener : Listener {
private fun handleRename(resultItem: ItemStack, inventory: AnvilInventory): Int { private fun handleRename(resultItem: ItemStack, inventory: AnvilInventory): Int {
// Rename item and add renaming cost // Rename item and add renaming cost
resultItem.itemMeta?.let { resultItem.itemMeta?.let {
if (!it.displayName.contentEquals(inventory.renameText)) { val displayName = ChatColor.stripColor(it.displayName)
val inventoryName = ChatColor.stripColor(inventory.renameText)
if (!displayName.contentEquals(inventoryName)) {
it.setDisplayName(inventory.renameText) it.setDisplayName(inventory.renameText)
resultItem.itemMeta = it resultItem.itemMeta = it
return ConfigOptions.itemRenameCost return ConfigOptions.itemRenameCost

View file

@ -1,7 +1,7 @@
main: io.delilaheve.CustomAnvil main: io.delilaheve.CustomAnvil
name: CustomAnvil name: CustomAnvil
prefix: "Custom Anvil" prefix: "Custom Anvil"
version: 1.4.1a version: 1.4.2a
description: Allow to customise anvil mechanics description: Allow to customise anvil mechanics
api-version: 1.18 api-version: 1.18
load: POSTWORLD load: POSTWORLD