mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Add work type config gui
also add custom recipe use type also fix increase not working for rename
This commit is contained in:
parent
b6d2c63b86
commit
2cb053e0ca
7 changed files with 255 additions and 61 deletions
|
|
@ -38,7 +38,9 @@ object ConfigOptions {
|
|||
const val USE_OF_COLOR_COST = "use_of_color_cost"
|
||||
|
||||
//const val WORK_PENALTY_TYPE = "work_penalty_type" TODO move old value to config migration
|
||||
const val WORK_PENALTY = "work_penalty"
|
||||
const val WORK_PENALTY_ROOT = "work_penalty"
|
||||
const val WORK_PENALTY_INCREASE = "increase"
|
||||
const val WORK_PENALTY_ADDITIVE = "additive"
|
||||
|
||||
const val DEFAULT_LIMIT_PATH = "default_limit"
|
||||
|
||||
|
|
@ -278,14 +280,14 @@ object ConfigOptions {
|
|||
* How work penalty should work
|
||||
*/
|
||||
fun workPenaltyPart(type: AnvilUseType): WorkPenaltyPart {
|
||||
val config = ConfigHolder.CONFLICT_HOLDER.config
|
||||
val path = WORK_PENALTY + "." + type.typeName
|
||||
val config = ConfigHolder.DEFAULT_CONFIG.config
|
||||
val path = WORK_PENALTY_ROOT + "." + type.typeName
|
||||
|
||||
// Find values
|
||||
val section = config.getConfigurationSection(path) ?: return WorkPenaltyPart.ONLY_TRUE_PART
|
||||
val section = config.getConfigurationSection(path) ?: return type.defaultPenalty
|
||||
|
||||
val penaltyIncrease = section.getBoolean("penalty_increase", true)
|
||||
val penaltyAdditive = section.getBoolean("penalty_additive", true)
|
||||
val penaltyIncrease = section.getBoolean(WORK_PENALTY_INCREASE, true)
|
||||
val penaltyAdditive = section.getBoolean(WORK_PENALTY_ADDITIVE, true)
|
||||
|
||||
return WorkPenaltyPart(penaltyIncrease, penaltyAdditive)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,12 @@ class PrepareAnvilListener : Listener {
|
|||
|
||||
event.result = resultItem
|
||||
if(DependencyManager.tryTreatAnvilResult(event, resultItem)) return true
|
||||
AnvilXpUtil.setAnvilInvXp(inventory, event.view, player, recipe.xpCostPerCraft * amount, true)
|
||||
|
||||
// Maybe add an option on custom craft to ignore/not ignore penalty ??
|
||||
var xpCost = recipe.xpCostPerCraft * amount
|
||||
xpCost += AnvilXpUtil.calculatePenalty(first, null, resultItem, AnvilUseType.CUSTOM_CRAFT)
|
||||
|
||||
AnvilXpUtil.setAnvilInvXp(inventory, event.view, player, xpCost, true)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,29 @@
|
|||
package xyz.alexcrea.cuanvil.util
|
||||
|
||||
enum class AnvilUseType(val typeName: String) {
|
||||
import org.bukkit.Material
|
||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType.WorkPenaltyPart
|
||||
|
||||
RENAME_ONLY("rename_only"),
|
||||
MERGE("merge"),
|
||||
UNIT_REPAIR("unit_repair"),
|
||||
enum class AnvilUseType(val typeName: String,
|
||||
val defaultPenalty: WorkPenaltyPart,
|
||||
val displayName: String, val displayMat: Material
|
||||
) {
|
||||
|
||||
RENAME_ONLY("rename_only",
|
||||
WorkPenaltyPart(false, true),
|
||||
"Rename Only", Material.NAME_TAG
|
||||
),
|
||||
MERGE("merge",
|
||||
WorkPenaltyPart(true, true),
|
||||
"Merge", Material.ANVIL
|
||||
),
|
||||
UNIT_REPAIR("unit_repair",
|
||||
WorkPenaltyPart(true, true),
|
||||
"Unit Repair", Material.DIAMOND
|
||||
),
|
||||
CUSTOM_CRAFT("custom_craft",
|
||||
WorkPenaltyPart(false, false),
|
||||
"Custom Craft", Material.CRAFTING_TABLE
|
||||
),
|
||||
;
|
||||
|
||||
}
|
||||
|
|
@ -84,9 +84,8 @@ object AnvilXpUtil {
|
|||
if (right == null) 0
|
||||
else (right.itemMeta as? Repairable)?.repairCost ?: 0
|
||||
|
||||
|
||||
// Increase penalty on fusing or unit repair
|
||||
if(penaltyType.penaltyIncrease && (right != null || AnvilUseType.UNIT_REPAIR == useType)){
|
||||
if(penaltyType.penaltyIncrease){
|
||||
result.itemMeta?.let {
|
||||
(it as? Repairable)?.repairCost = leftPenalty * 2 + 1
|
||||
result.itemMeta = it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue