mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Replace "to expensive" as config option.
- Added "replace_to_expensive" option and its usage. - Changed "limit_repair_value" range - Moved order of some field to make sens between code and config
This commit is contained in:
parent
de51617059
commit
f684e15c5b
3 changed files with 73 additions and 40 deletions
|
|
@ -547,7 +547,7 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
|
|||
val player = event.view.player
|
||||
if(player is Player){
|
||||
if(player.gameMode != GameMode.CREATIVE ){
|
||||
packetManager.setInstantBuild(player, finalAnvilCost >= 40)
|
||||
packetManager.setInstantBuild(player, (ConfigOptions.replaceToExpensive) && (finalAnvilCost >= 40))
|
||||
}
|
||||
player.updateInventory()
|
||||
|
||||
|
|
|
|||
|
|
@ -10,15 +10,18 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder
|
|||
*/
|
||||
object ConfigOptions {
|
||||
|
||||
// Path for default enchantment limits
|
||||
private const val DEFAULT_LIMIT_PATH = "default_limit"
|
||||
|
||||
// Path for limiting repair cost
|
||||
const val LIMIT_REPAIR_COST = "limit_repair_cost"
|
||||
|
||||
// Path for repair value limit
|
||||
const val LIMIT_REPAIR_VALUE = "limit_repair_value"
|
||||
|
||||
// Path for removing repair cost limits
|
||||
const val REMOVE_REPAIR_LIMIT = "remove_repair_limit"
|
||||
|
||||
// Path for removing repair cost limits
|
||||
const val REPLACE_TO_EXPENSIVE = "replace_to_expensive"
|
||||
|
||||
// Path for level cost on item repair
|
||||
const val ITEM_REPAIR_COST = "item_repair_cost"
|
||||
|
||||
|
|
@ -31,12 +34,14 @@ object ConfigOptions {
|
|||
// Path for level cost on illegal enchantment on sacrifice
|
||||
const val SACRIFICE_ILLEGAL_COST = "sacrifice_illegal_enchant_cost"
|
||||
|
||||
// Path for removing repair cost limits
|
||||
const val REMOVE_REPAIR_LIMIT = "remove_repair_limit"
|
||||
// Path for default enchantment limits
|
||||
private const val DEFAULT_LIMIT_PATH = "default_limit"
|
||||
|
||||
|
||||
// Root path for enchantment limits
|
||||
const val ENCHANT_LIMIT_ROOT = "enchant_limits"
|
||||
|
||||
|
||||
// Root path for enchantment values
|
||||
const val ENCHANT_VALUES_ROOT = "enchant_values"
|
||||
|
||||
|
|
@ -44,14 +49,13 @@ object ConfigOptions {
|
|||
private const val KEY_BOOK = "book"
|
||||
private const val KEY_ITEM = "item"
|
||||
|
||||
|
||||
// Debug logging toggle path
|
||||
private const val DEBUG_LOGGING = "debug_log"
|
||||
|
||||
// Debug verbose logging toggle path
|
||||
private const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose"
|
||||
|
||||
// Default value for enchantment limits
|
||||
private const val DEFAULT_ENCHANT_LIMIT = 5
|
||||
|
||||
// Default value for limiting repair cost
|
||||
const val DEFAULT_LIMIT_REPAIR = false
|
||||
|
|
@ -59,6 +63,12 @@ object ConfigOptions {
|
|||
// Default value for repair cost limit
|
||||
const val DEFAULT_LIMIT_REPAIR_VALUE = 39
|
||||
|
||||
// Default for removing repair cost limits
|
||||
const val DEFAULT_REMOVE_LIMIT = false
|
||||
|
||||
// Default for removing repair cost limits
|
||||
const val DEFAULT_REPLACE_TO_EXPENSIVE = false
|
||||
|
||||
// Default value for level cost on item repair
|
||||
const val DEFAULT_ITEM_REPAIR_COST = 2
|
||||
|
||||
|
|
@ -71,9 +81,20 @@ object ConfigOptions {
|
|||
// Default value for level cost on illegal enchantment on sacrifice
|
||||
const val DEFAULT_SACRIFICE_ILLEGAL_COST = 1
|
||||
|
||||
|
||||
// Default value for enchantment limits
|
||||
private const val DEFAULT_ENCHANT_LIMIT = 5
|
||||
|
||||
// Default value for debug logging
|
||||
private const val DEFAULT_DEBUG_LOG = false
|
||||
|
||||
// Default value for debug logging
|
||||
private const val DEFAULT_VERBOSE_DEBUG_LOG = false
|
||||
|
||||
|
||||
// Valid range for repair cost limit
|
||||
@JvmField
|
||||
val REPAIR_LIMIT_RANGE = 1..39
|
||||
val REPAIR_LIMIT_RANGE = 1..255
|
||||
|
||||
// Valid range for repair cost
|
||||
@JvmField
|
||||
|
|
@ -87,32 +108,14 @@ object ConfigOptions {
|
|||
@JvmField
|
||||
val SACRIFICE_ILLEGAL_COST_RANGE = 0..255
|
||||
|
||||
// Default for removing repair cost limits
|
||||
const val DEFAULT_REMOVE_LIMIT = false
|
||||
|
||||
// Valid range for an enchantment limit
|
||||
@JvmField
|
||||
val ENCHANT_LIMIT_RANGE = 1..255
|
||||
|
||||
|
||||
// Default value for an enchantment multiplier
|
||||
private const val DEFAULT_ENCHANT_VALUE = 0
|
||||
|
||||
// Default value for debug logging
|
||||
private const val DEFAULT_DEBUG_LOG = false
|
||||
|
||||
// Default value for debug logging
|
||||
private const val DEFAULT_VERBOSE_DEBUG_LOG = false
|
||||
|
||||
/**
|
||||
* Default enchantment limit
|
||||
*/
|
||||
private val defaultEnchantLimit: Int
|
||||
get() {
|
||||
return ConfigHolder.DEFAULT_CONFIG
|
||||
.config
|
||||
.getInt(DEFAULT_LIMIT_PATH, DEFAULT_ENCHANT_LIMIT)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to limit repair costs to the vanilla limit
|
||||
*/
|
||||
|
|
@ -135,6 +138,26 @@ object ConfigOptions {
|
|||
?: DEFAULT_LIMIT_REPAIR_VALUE
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to remove repair cost limit
|
||||
*/
|
||||
val removeRepairLimit: Boolean
|
||||
get() {
|
||||
return ConfigHolder.DEFAULT_CONFIG
|
||||
.config
|
||||
.getBoolean(REMOVE_REPAIR_LIMIT, DEFAULT_REMOVE_LIMIT)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to remove repair cost limit
|
||||
*/
|
||||
val replaceToExpensive: Boolean
|
||||
get() {
|
||||
return ConfigHolder.DEFAULT_CONFIG
|
||||
.config
|
||||
.getBoolean(REPLACE_TO_EXPENSIVE, DEFAULT_REPLACE_TO_EXPENSIVE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of an item repair
|
||||
*/
|
||||
|
|
@ -184,13 +207,13 @@ object ConfigOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether to remove repair cost limit
|
||||
* Default enchantment limit
|
||||
*/
|
||||
val removeRepairLimit: Boolean
|
||||
private val defaultEnchantLimit: Int
|
||||
get() {
|
||||
return ConfigHolder.DEFAULT_CONFIG
|
||||
.config
|
||||
.getBoolean(REMOVE_REPAIR_LIMIT, DEFAULT_REMOVE_LIMIT)
|
||||
.getInt(DEFAULT_LIMIT_PATH, DEFAULT_ENCHANT_LIMIT)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,19 +5,34 @@ limit_repair_cost: false
|
|||
|
||||
# Value to limit repair costs to when limit_repair_cost is true
|
||||
#
|
||||
# Valid values include 1 to 39 (vanilla will consider 40+ as "too expensive")
|
||||
# Valid values include 1 to 255 (anvil will display cost above 39 as "too expensive" if "replace_to_expensive" is false)
|
||||
limit_repair_value: 39
|
||||
|
||||
# Whether the anvil's repair limit should be removed entirely
|
||||
#
|
||||
# The anvil will still visually display "too expensive" however the action will be completable
|
||||
# The anvil will still visually display "too expensive" if "replace_to_expensive" is false.
|
||||
# However, the action will be completable if xp requirement is meet.
|
||||
remove_repair_limit: false
|
||||
|
||||
# Whenever anvil cost is above 39 should display the true price and not "to expensive".
|
||||
#
|
||||
# However, when cost is above 39, anvil price will be displayed a green,
|
||||
# even if player do not have the required xp level.
|
||||
# But the action will not be completable.
|
||||
#
|
||||
# Require ProtocoLib.
|
||||
replace_to_expensive: false
|
||||
|
||||
# XP Level amount added to the anvil when the item is repaired by another item of the same type
|
||||
#
|
||||
# Valid values include 0 to 255
|
||||
item_repair_cost: 2
|
||||
|
||||
# XP Level amount added to the anvil when the item is renamed
|
||||
#
|
||||
# Valid values include 0 to 255
|
||||
item_rename_cost: 1
|
||||
|
||||
# XP Level amount added to the anvil when the item is repaired by an "unit"
|
||||
# For example: a Diamond on a Diamond Sword
|
||||
# What's considered unit for what can be edited on the unit repair configuration.
|
||||
|
|
@ -25,11 +40,6 @@ item_repair_cost: 2
|
|||
# Valid values include 0 to 255
|
||||
unit_repair_cost: 1
|
||||
|
||||
# XP Level amount added to the anvil when the item is renamed
|
||||
#
|
||||
# Valid values include 0 to 255
|
||||
item_rename_cost: 1
|
||||
|
||||
# XP Level amount added to the anvil when a sacrifice enchantment
|
||||
# conflict with one of the left item enchantment
|
||||
#
|
||||
|
|
@ -229,4 +239,4 @@ debug_log: false
|
|||
# Whether to show verbose debug logging
|
||||
debug_log_verbose: false
|
||||
|
||||
configVersion: 1.4.3
|
||||
configVersion: 1.4.4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue