mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
fix repair and rename cost
This commit is contained in:
parent
c07cda87a1
commit
8c3447338e
3 changed files with 29 additions and 6 deletions
|
|
@ -54,7 +54,7 @@ class AnvilEventListener : Listener {
|
||||||
if (!first.isBook() && !second.isBook()) {
|
if (!first.isBook() && !second.isBook()) {
|
||||||
// we only need to be concerned with repair when neither item is a book
|
// we only need to be concerned with repair when neither item is a book
|
||||||
val repaired = resultItem.repairFrom(first, second)
|
val repaired = resultItem.repairFrom(first, second)
|
||||||
anvilCost += if(repaired) 2 else 0
|
anvilCost += if(repaired) ConfigOptions.itemRepairCost else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if nothing change and stop.
|
// Test if nothing change and stop.
|
||||||
|
|
@ -67,7 +67,7 @@ class AnvilEventListener : Listener {
|
||||||
resultItem.itemMeta?.let {
|
resultItem.itemMeta?.let {
|
||||||
if(!it.displayName.contentEquals(inventory.renameText)){
|
if(!it.displayName.contentEquals(inventory.renameText)){
|
||||||
it.setDisplayName(inventory.renameText)
|
it.setDisplayName(inventory.renameText)
|
||||||
anvilCost += ConfigOptions.itemRepairCost
|
anvilCost += ConfigOptions.itemRenameCost
|
||||||
}
|
}
|
||||||
resultItem.itemMeta = it
|
resultItem.itemMeta = it
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ object ConfigOptions {
|
||||||
private const val LIMIT_REPAIR_VALUE = "limit_repair_value"
|
private const val LIMIT_REPAIR_VALUE = "limit_repair_value"
|
||||||
// Path for level cost on item repair
|
// Path for level cost on item repair
|
||||||
private const val ITEM_REPAIR_COST = "item_repair_cost"
|
private const val ITEM_REPAIR_COST = "item_repair_cost"
|
||||||
|
// Path for level cost on item renaming
|
||||||
|
private const val ITEM_RENAME_COST = "item_rename_cost"
|
||||||
// Path for level cost on illegal enchantment on sacrifice
|
// Path for level cost on illegal enchantment on sacrifice
|
||||||
private const val SACRIFICE_ILLEGAL_COST = "sacrifice_illegal_enchant_cost"
|
private const val SACRIFICE_ILLEGAL_COST = "sacrifice_illegal_enchant_cost"
|
||||||
// Path for removing repair cost limits
|
// Path for removing repair cost limits
|
||||||
|
|
@ -39,13 +41,17 @@ object ConfigOptions {
|
||||||
private const val DEFAULT_LIMIT_REPAIR_VALUE = 39
|
private const val DEFAULT_LIMIT_REPAIR_VALUE = 39
|
||||||
// Default value for level cost on item repair
|
// Default value for level cost on item repair
|
||||||
private const val DEFAULT_ITEM_REPAIR_COST = 2
|
private const val DEFAULT_ITEM_REPAIR_COST = 2
|
||||||
|
// Default value for level cost on item renaming
|
||||||
|
private const val DEFAULT_ITEM_RENAME_COST = 1
|
||||||
// Default value for level cost on illegal enchantment on sacrifice
|
// Default value for level cost on illegal enchantment on sacrifice
|
||||||
private const val DEFAULT_SACRIFICE_ILLEGAL_COST = 1
|
private const val DEFAULT_SACRIFICE_ILLEGAL_COST = 1
|
||||||
// Valid range for repair cost limit
|
// Valid range for repair cost limit
|
||||||
private val REPAIR_LIMIT_RANGE = 1..39
|
private val REPAIR_LIMIT_RANGE = 1..39
|
||||||
// Valid range for repair cost limit
|
// Valid range for repair cost
|
||||||
private val ITEM_REPAIR_COST_RANGE = 0..255
|
private val ITEM_REPAIR_COST_RANGE = 0..255
|
||||||
// Valid range for repair cost limit
|
// Valid range for rename cost
|
||||||
|
private val ITEM_RENAME_COST_RANGE = 0..255
|
||||||
|
// Valid range for illegal enchantment conflict cost
|
||||||
private val SACRIFICE_ILLEGAL_COST_RANGE = 0..255
|
private val SACRIFICE_ILLEGAL_COST_RANGE = 0..255
|
||||||
// Default for removing repair cost limits
|
// Default for removing repair cost limits
|
||||||
private const val DEFAULT_REMOVE_LIMIT = false
|
private const val DEFAULT_REMOVE_LIMIT = false
|
||||||
|
|
@ -89,7 +95,7 @@ object ConfigOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value to limit repair costs to
|
* Value of an item repair
|
||||||
*/
|
*/
|
||||||
val itemRepairCost: Int
|
val itemRepairCost: Int
|
||||||
get() {
|
get() {
|
||||||
|
|
@ -101,7 +107,19 @@ object ConfigOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value to limit repair costs to
|
* Value of an item rename
|
||||||
|
*/
|
||||||
|
val itemRenameCost: Int
|
||||||
|
get() {
|
||||||
|
return UnsafeEnchants.instance
|
||||||
|
.config
|
||||||
|
.getInt(ITEM_RENAME_COST, DEFAULT_ITEM_RENAME_COST)
|
||||||
|
.takeIf { it in ITEM_RENAME_COST_RANGE }
|
||||||
|
?: DEFAULT_ITEM_RENAME_COST
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value of illegal enchantment conflict
|
||||||
*/
|
*/
|
||||||
val sacrificeIllegalCost: Int
|
val sacrificeIllegalCost: Int
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@ remove_repair_limit: false
|
||||||
# Valid range of 0 - 255
|
# Valid range of 0 - 255
|
||||||
item_repair_cost: 2
|
item_repair_cost: 2
|
||||||
|
|
||||||
|
# Value added to the anvil when the item is renamed
|
||||||
|
#
|
||||||
|
# Valid range of 0 - 255
|
||||||
|
item_rename_cost: 1
|
||||||
|
|
||||||
# Value added to the anvil when a sacrifice enchantment conflict
|
# Value added to the anvil when a sacrifice enchantment conflict
|
||||||
# with one of the left item enchantment
|
# with one of the left item enchantment
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue