mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
new work penalty
also removed old penalty config gui
This commit is contained in:
parent
ea19ffc4a1
commit
b6d2c63b86
7 changed files with 66 additions and 128 deletions
|
|
@ -4,7 +4,10 @@ import io.delilaheve.CustomAnvil
|
|||
import io.delilaheve.util.EnchantmentUtil.enchantmentName
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType
|
||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType.WorkPenaltyPart
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.util.AnvilUseType
|
||||
import java.util.EnumMap
|
||||
|
||||
/**
|
||||
* Config option accessors
|
||||
|
|
@ -34,7 +37,8 @@ object ConfigOptions {
|
|||
const val PERMISSION_NEEDED_FOR_COLOR = "permission_needed_for_color"
|
||||
const val USE_OF_COLOR_COST = "use_of_color_cost"
|
||||
|
||||
const val WORK_PENALTY_TYPE = "work_penalty_type"
|
||||
//const val WORK_PENALTY_TYPE = "work_penalty_type" TODO move old value to config migration
|
||||
const val WORK_PENALTY = "work_penalty"
|
||||
|
||||
const val DEFAULT_LIMIT_PATH = "default_limit"
|
||||
|
||||
|
|
@ -113,7 +117,7 @@ object ConfigOptions {
|
|||
private const val DEFAULT_ENCHANT_VALUE = 0
|
||||
|
||||
// Default max before merge disabled (negative mean enabled)
|
||||
const val DEFAULT_MAX_BEFORE_MERGE_DISABLED = -1;
|
||||
const val DEFAULT_MAX_BEFORE_MERGE_DISABLED = -1
|
||||
|
||||
// -------------
|
||||
// Get methods
|
||||
|
|
@ -257,16 +261,35 @@ object ConfigOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* How many xp should use of color should cost
|
||||
* How work penalties should work
|
||||
*/
|
||||
val workPenaltyType: WorkPenaltyType
|
||||
get() {
|
||||
return WorkPenaltyType.fromString(
|
||||
ConfigHolder.DEFAULT_CONFIG
|
||||
.config
|
||||
.getString(WORK_PENALTY_TYPE));
|
||||
val penaltyMap = EnumMap<AnvilUseType, WorkPenaltyPart>(AnvilUseType::class.java)
|
||||
|
||||
for (type in AnvilUseType.entries) {
|
||||
penaltyMap[type] = workPenaltyPart(type)
|
||||
}
|
||||
|
||||
return WorkPenaltyType(penaltyMap)
|
||||
}
|
||||
|
||||
/**
|
||||
* How work penalty should work
|
||||
*/
|
||||
fun workPenaltyPart(type: AnvilUseType): WorkPenaltyPart {
|
||||
val config = ConfigHolder.CONFLICT_HOLDER.config
|
||||
val path = WORK_PENALTY + "." + type.typeName
|
||||
|
||||
// Find values
|
||||
val section = config.getConfigurationSection(path) ?: return WorkPenaltyPart.ONLY_TRUE_PART
|
||||
|
||||
val penaltyIncrease = section.getBoolean("penalty_increase", true)
|
||||
val penaltyAdditive = section.getBoolean("penalty_additive", true)
|
||||
|
||||
return WorkPenaltyPart(penaltyIncrease, penaltyAdditive)
|
||||
}
|
||||
|
||||
/**
|
||||
* Default enchantment limit
|
||||
*/
|
||||
|
|
@ -303,11 +326,11 @@ object ConfigOptions {
|
|||
fun enchantLimit(enchantment: CAEnchantment): Int {
|
||||
// Test namespace
|
||||
var limit = enchantLimit(enchantment.key.toString())
|
||||
if(limit != null) return limit;
|
||||
if(limit != null) return limit
|
||||
|
||||
// Test legacy (name only)
|
||||
limit = enchantLimit(enchantment.enchantmentName)
|
||||
if(limit != null) return limit;
|
||||
if(limit != null) return limit
|
||||
|
||||
// get default (and test old legacy if present)
|
||||
return getDefaultLevel(enchantment.enchantmentName)
|
||||
|
|
@ -348,11 +371,11 @@ object ConfigOptions {
|
|||
): Int {
|
||||
// Test namespace
|
||||
var limit = enchantmentValue(enchantment.key.toString(), isFromBook)
|
||||
if(limit != null) return limit;
|
||||
if(limit != null) return limit
|
||||
|
||||
// Test legacy (name only)
|
||||
limit = enchantmentValue(enchantment.enchantmentName, isFromBook)
|
||||
if(limit != null) return limit;
|
||||
if(limit != null) return limit
|
||||
|
||||
// get default (and test old legacy if present)
|
||||
return getDefaultValue(enchantment, isFromBook)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue