mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +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 {
|
private fun handleRename(resultItem: ItemStack, inventory: AnvilInventory, player: HumanEntity): Int {
|
||||||
// Rename item and add renaming cost
|
// Can be null
|
||||||
resultItem.itemMeta?.let {
|
|
||||||
val displayName = ChatColor.stripColor(it.displayName)
|
|
||||||
var inventoryName = ChatColor.stripColor(inventory.renameText)
|
var inventoryName = ChatColor.stripColor(inventory.renameText)
|
||||||
|
|
||||||
var sumCost = 0
|
var sumCost = 0
|
||||||
|
|
||||||
var useColor = false
|
var useColor = false
|
||||||
if(ConfigOptions.renameColorPossible){
|
if(ConfigOptions.renameColorPossible && inventoryName != null){
|
||||||
val resultString = StringBuilder(inventoryName)
|
val resultString = StringBuilder(inventoryName)
|
||||||
|
|
||||||
useColor = AnvilColorUtil.handleRenamingColor(resultString, player)
|
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))) {
|
if ((!useColor && (!displayName.contentEquals(inventoryName))) || (useColor && !(it.displayName).contentEquals(inventoryName))) {
|
||||||
it.setDisplayName(inventoryName)
|
it.setDisplayName(inventoryName)
|
||||||
resultItem.itemMeta = it
|
resultItem.itemMeta = it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue