mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Make sure rename work when null
This commit is contained in:
parent
5f557e3d49
commit
1db6385082
1 changed files with 18 additions and 17 deletions
|
|
@ -116,15 +116,12 @@ class PrepareAnvilListener : Listener {
|
|||
}
|
||||
|
||||
private fun handleRename(resultItem: ItemStack, inventory: AnvilInventory, player: HumanEntity): Int {
|
||||
// Rename item and add renaming cost
|
||||
resultItem.itemMeta?.let {
|
||||
val displayName = ChatColor.stripColor(it.displayName)
|
||||
// Can be null
|
||||
var inventoryName = ChatColor.stripColor(inventory.renameText)
|
||||
|
||||
var sumCost = 0
|
||||
|
||||
var useColor = false
|
||||
if(ConfigOptions.renameColorPossible){
|
||||
if(ConfigOptions.renameColorPossible && inventoryName != null){
|
||||
val resultString = StringBuilder(inventoryName)
|
||||
|
||||
useColor = AnvilColorUtil.handleRenamingColor(resultString, player)
|
||||
|
|
@ -136,6 +133,10 @@ class PrepareAnvilListener : Listener {
|
|||
}
|
||||
}
|
||||
|
||||
// Rename item and add renaming cost
|
||||
resultItem.itemMeta?.let {
|
||||
|
||||
val displayName = ChatColor.stripColor(it.displayName)
|
||||
if ((!useColor && (!displayName.contentEquals(inventoryName))) || (useColor && !(it.displayName).contentEquals(inventoryName))) {
|
||||
it.setDisplayName(inventoryName)
|
||||
resultItem.itemMeta = it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue