mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
change color configs & add do consume to lore removal
This commit is contained in:
parent
4cbfb6eab0
commit
51dbbccc1c
6 changed files with 199 additions and 202 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
package xyz.alexcrea.cuanvil.update;
|
package xyz.alexcrea.cuanvil.update;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
|
import io.delilaheve.util.ConfigOptions;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.config.LoreEditType;
|
import xyz.alexcrea.cuanvil.util.config.LoreEditType;
|
||||||
|
|
||||||
import static io.delilaheve.util.ConfigOptions.*;
|
import static io.delilaheve.util.ConfigOptions.*;
|
||||||
|
|
@ -24,7 +26,7 @@ public class PluginSetDefault {
|
||||||
nbSet += trySetDefault(config, UNIT_REPAIR_COST, DEFAULT_UNIT_REPAIR_COST);
|
nbSet += trySetDefault(config, UNIT_REPAIR_COST, DEFAULT_UNIT_REPAIR_COST);
|
||||||
nbSet += trySetDefault(config, ITEM_RENAME_COST, DEFAULT_ITEM_RENAME_COST);
|
nbSet += trySetDefault(config, ITEM_RENAME_COST, DEFAULT_ITEM_RENAME_COST);
|
||||||
nbSet += trySetDefault(config, SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST);
|
nbSet += trySetDefault(config, SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST);
|
||||||
nbSet+= trySetDefault(config, ALLOW_COLOR_CODE, DEFAULT_ALLOW_COLOR_CODE);
|
nbSet += trySetDefault(config, ConfigOptions.ALLOW_COLOR_CODE, ConfigOptions.DEFAULT_ALLOW_COLOR_CODE);
|
||||||
nbSet += trySetDefault(config, ALLOW_HEXADECIMAL_COLOR, DEFAULT_ALLOW_HEXADECIMAL_COLOR);
|
nbSet += trySetDefault(config, ALLOW_HEXADECIMAL_COLOR, DEFAULT_ALLOW_HEXADECIMAL_COLOR);
|
||||||
nbSet += trySetDefault(config, PERMISSION_NEEDED_FOR_COLOR, DEFAULT_PERMISSION_NEEDED_FOR_COLOR);
|
nbSet += trySetDefault(config, PERMISSION_NEEDED_FOR_COLOR, DEFAULT_PERMISSION_NEEDED_FOR_COLOR);
|
||||||
nbSet += trySetDefault(config, USE_OF_COLOR_COST, DEFAULT_USE_OF_COLOR_COST);
|
nbSet += trySetDefault(config, USE_OF_COLOR_COST, DEFAULT_USE_OF_COLOR_COST);
|
||||||
|
|
@ -36,25 +38,24 @@ public class PluginSetDefault {
|
||||||
|
|
||||||
nbSet += trySetDefault(config, path + IS_ENABLED, DEFAULT_IS_ENABLED);
|
nbSet += trySetDefault(config, path + IS_ENABLED, DEFAULT_IS_ENABLED);
|
||||||
nbSet += trySetDefault(config, path + FIXED_COST, DEFAULT_FIXED_COST);
|
nbSet += trySetDefault(config, path + FIXED_COST, DEFAULT_FIXED_COST);
|
||||||
|
|
||||||
|
nbSet += trySetDefault(config, path + DO_CONSUME, DEFAULT_DO_CONSUME);
|
||||||
if (value.isMultiLine()) {
|
if (value.isMultiLine()) {
|
||||||
nbSet += trySetDefault(config, path + PER_LINE_COST, DEFAULT_PER_LINE_COST);
|
nbSet += trySetDefault(config, path + PER_LINE_COST, DEFAULT_PER_LINE_COST);
|
||||||
}
|
}
|
||||||
if (value.isAppend()) {
|
if (value.isAppend()) {
|
||||||
nbSet+= trySetDefault(config, path + DO_CONSUME, DEFAULT_DO_CONSUME);
|
nbSet += trySetDefault(config, path + LoreEditConfigUtil.ALLOW_COLOR_CODE, LoreEditConfigUtil.DEFAULT_ALLOW_COLOR_CODE);
|
||||||
|
nbSet += trySetDefault(config, path + ALLOW_HEX_COLOR, DEFAULT_ALLOW_HEX_COLOR);
|
||||||
|
nbSet += trySetDefault(config, path + USE_COLOR_COST, DEFAULT_USE_COLOR_COST);
|
||||||
|
} else {
|
||||||
|
nbSet += trySetDefault(config, path + REMOVE_COLOR_ON_LORE_REMOVE, DEFAULT_REMOVE_COLOR_ON_LORE_REMOVE);
|
||||||
|
nbSet += trySetDefault(config, path + REMOVE_COLOR_COST, DEFAULT_REMOVE_COLOR_COST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nbSet += trySetDefault(config, BOOK_PERMISSION_NEEDED, DEFAULT_BOOK_PERMISSION_NEEDED);
|
nbSet += trySetDefault(config, BOOK_PERMISSION_NEEDED, DEFAULT_BOOK_PERMISSION_NEEDED);
|
||||||
nbSet += trySetDefault(config, PAPER_PERMISSION_NEEDED, DEFAULT_PAPER_PERMISSION_NEEDED);
|
nbSet += trySetDefault(config, PAPER_PERMISSION_NEEDED, DEFAULT_PAPER_PERMISSION_NEEDED);
|
||||||
|
|
||||||
nbSet+= trySetDefault(config, COLOR_BOOK_COLOR_CODE, DEFAULT_COLOR_BOOK_COLOR_CODE);
|
|
||||||
nbSet+= trySetDefault(config, COLOR_BOOK_HEX, DEFAULT_COLOR_BOOK_HEX);
|
|
||||||
nbSet+= trySetDefault(config, COLOR_BOOK_COST, DEFAULT_COLOR_BOOK_COST);
|
|
||||||
|
|
||||||
nbSet+= trySetDefault(config, COLOR_PAPER_COLOR_CODE, DEFAULT_COLOR_PAPER_COLOR_CODE);
|
|
||||||
nbSet+= trySetDefault(config, COLOR_PAPER_HEX, DEFAULT_COLOR_PAPER_HEX);
|
|
||||||
nbSet+= trySetDefault(config, COLOR_PAPER_COST, DEFAULT_COLOR_PAPER_COST);
|
|
||||||
|
|
||||||
nbSet += trySetDefault(config, PAPER_EDIT_ORDER, DEFAULT_PAPER_EDIT_ORDER);
|
nbSet += trySetDefault(config, PAPER_EDIT_ORDER, DEFAULT_PAPER_EDIT_ORDER);
|
||||||
|
|
||||||
if (nbSet > 0) {
|
if (nbSet > 0) {
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,10 @@ class AnvilResultListener : Listener {
|
||||||
val lore = ArrayList<String>(meta.lore!!)
|
val lore = ArrayList<String>(meta.lore!!)
|
||||||
if (lore.isEmpty()) return false
|
if (lore.isEmpty()) return false
|
||||||
|
|
||||||
|
val rightCopy : ItemStack?
|
||||||
|
if (LoreEditType.APPEND_PAPER.doConsume) {
|
||||||
|
rightCopy = null
|
||||||
|
} else {
|
||||||
// Uncolor the page
|
// Uncolor the page
|
||||||
AnvilLoreEditUtil.uncolorLines(player, lore, LoreEditType.REMOVE_BOOK)
|
AnvilLoreEditUtil.uncolorLines(player, lore, LoreEditType.REMOVE_BOOK)
|
||||||
|
|
||||||
|
|
@ -364,9 +368,10 @@ class AnvilResultListener : Listener {
|
||||||
val resultPage = bookPage.toString()
|
val resultPage = bookPage.toString()
|
||||||
//TODO maybe check page size ? bc it may be too big ???
|
//TODO maybe check page size ? bc it may be too big ???
|
||||||
|
|
||||||
val rightCopy = rightItem.clone()
|
rightCopy = rightItem.clone()
|
||||||
bookMeta.setPages(resultPage)
|
bookMeta.setPages(resultPage)
|
||||||
rightCopy.itemMeta = bookMeta
|
rightCopy.itemMeta = bookMeta
|
||||||
|
}
|
||||||
|
|
||||||
return extractAnvilResult(
|
return extractAnvilResult(
|
||||||
event, player, inventory,
|
event, player, inventory,
|
||||||
|
|
@ -428,6 +433,11 @@ class AnvilResultListener : Listener {
|
||||||
val lore = leftMeta.lore!!
|
val lore = leftMeta.lore!!
|
||||||
if (lore.isEmpty()) return false
|
if (lore.isEmpty()) return false
|
||||||
|
|
||||||
|
// Create result item
|
||||||
|
val rightClone: ItemStack?
|
||||||
|
if(LoreEditType.REMOVE_PAPER.doConsume){
|
||||||
|
rightClone = null
|
||||||
|
}else{
|
||||||
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
||||||
var line = if (removeEnd) lore[lore.size - 1]
|
var line = if (removeEnd) lore[lore.size - 1]
|
||||||
else lore[0]
|
else lore[0]
|
||||||
|
|
@ -438,13 +448,13 @@ class AnvilResultListener : Listener {
|
||||||
AnvilLoreEditUtil.uncolorLines(player, tempList, LoreEditType.REMOVE_PAPER)
|
AnvilLoreEditUtil.uncolorLines(player, tempList, LoreEditType.REMOVE_PAPER)
|
||||||
line = tempList[0]
|
line = tempList[0]
|
||||||
|
|
||||||
// Create result item
|
rightClone = rightItem.clone()
|
||||||
val rightClone = rightItem.clone()
|
|
||||||
rightClone.amount = 1
|
rightClone.amount = 1
|
||||||
|
|
||||||
val resultMeta = rightClone.itemMeta ?: return false
|
val resultMeta = rightClone.itemMeta ?: return false
|
||||||
resultMeta.setDisplayName(line)
|
resultMeta.setDisplayName(line)
|
||||||
rightClone.itemMeta = resultMeta
|
rightClone.itemMeta = resultMeta
|
||||||
|
}
|
||||||
|
|
||||||
return if (rightItem.amount > 1) {
|
return if (rightItem.amount > 1) {
|
||||||
extractAnvilResult(
|
extractAnvilResult(
|
||||||
|
|
|
||||||
|
|
@ -227,21 +227,10 @@ object AnvilLoreEditUtil {
|
||||||
return xpCost
|
return xpCost
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun colorLines(player: Permissible, lines: ArrayList<String>, useType: LoreEditType): Int {
|
private fun colorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
||||||
val canUseHex: Boolean
|
val canUseHex = editType.allowHexColor
|
||||||
val canUseColorCode: Boolean
|
val canUseColorCode = editType.allowColorCode
|
||||||
val colorCost: Int
|
val colorCost = editType.useColorCost
|
||||||
// If is book
|
|
||||||
if (useType == LoreEditType.REMOVE_BOOK || useType == LoreEditType.APPEND_BOOK) {
|
|
||||||
canUseHex = LoreEditConfigUtil.bookAllowHexColor
|
|
||||||
canUseColorCode = LoreEditConfigUtil.bookAllowColorCode
|
|
||||||
colorCost = LoreEditConfigUtil.bookUseColorCost
|
|
||||||
} // Else if is paper
|
|
||||||
else {
|
|
||||||
canUseHex = LoreEditConfigUtil.paperAllowHexColor
|
|
||||||
canUseColorCode = LoreEditConfigUtil.paperAllowColorCode
|
|
||||||
colorCost = LoreEditConfigUtil.paperUseColorCost
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now handle color of each lines
|
// Now handle color of each lines
|
||||||
var hasUsedColor = false
|
var hasUsedColor = false
|
||||||
|
|
@ -268,21 +257,8 @@ object AnvilLoreEditUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uncolorLines(player: Permissible, lines: ArrayList<String>, useType: LoreEditType): Int {
|
fun uncolorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
||||||
val canUseHex: Boolean
|
if(!editType.shouldRemoveColorOnLoreRemoval) return 0
|
||||||
val canUseColorCode: Boolean
|
|
||||||
val colorCost: Int
|
|
||||||
// If is book
|
|
||||||
if (useType == LoreEditType.REMOVE_BOOK || useType == LoreEditType.APPEND_BOOK) {
|
|
||||||
canUseHex = LoreEditConfigUtil.bookAllowHexColor
|
|
||||||
canUseColorCode = LoreEditConfigUtil.bookAllowColorCode
|
|
||||||
colorCost = LoreEditConfigUtil.bookUseColorCost
|
|
||||||
} // Else if is paper
|
|
||||||
else {
|
|
||||||
canUseHex = LoreEditConfigUtil.paperAllowHexColor
|
|
||||||
canUseColorCode = LoreEditConfigUtil.paperAllowColorCode
|
|
||||||
colorCost = LoreEditConfigUtil.paperUseColorCost
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now handle color of each lines
|
// Now handle color of each lines
|
||||||
var hasUndidColor = false
|
var hasUndidColor = false
|
||||||
|
|
@ -292,7 +268,7 @@ object AnvilLoreEditUtil {
|
||||||
val lineUndidColor = AnvilColorUtil.revertColor(
|
val lineUndidColor = AnvilColorUtil.revertColor(
|
||||||
uncoloredLine,
|
uncoloredLine,
|
||||||
player,
|
player,
|
||||||
false, canUseColorCode, canUseHex,
|
false, true, true,
|
||||||
AnvilColorUtil.ColorUseType.LORE_EDIT
|
AnvilColorUtil.ColorUseType.LORE_EDIT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -303,7 +279,7 @@ object AnvilLoreEditUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (hasUndidColor) {
|
return if (hasUndidColor) {
|
||||||
colorCost
|
editType.removeColorCost
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,12 @@ object LoreEditConfigUtil {
|
||||||
const val PAPER_PERMISSION_NEEDED = "lore_edit.paper.use_permission"
|
const val PAPER_PERMISSION_NEEDED = "lore_edit.paper.use_permission"
|
||||||
|
|
||||||
// Color configs path
|
// Color configs path
|
||||||
const val COLOR_BOOK_COLOR_CODE = "lore_edit.book_and_quil.color.allow_color_code"
|
const val ALLOW_COLOR_CODE = "allow_color_code"
|
||||||
const val COLOR_BOOK_HEX = "lore_edit.book_and_quil.color.allow_hexadecimal_color"
|
const val ALLOW_HEX_COLOR = "allow_hexadecimal_color"
|
||||||
const val COLOR_BOOK_COST = "lore_edit.book_and_quil.color.use_cost"
|
const val USE_COLOR_COST = "use_cost"
|
||||||
|
|
||||||
const val COLOR_PAPER_COLOR_CODE = "lore_edit.paper.color.allow_color_code"
|
const val REMOVE_COLOR_ON_LORE_REMOVE = "remove_color_on_remove"
|
||||||
const val COLOR_PAPER_HEX = "lore_edit.paper.color.allow_hexadecimal_color"
|
const val REMOVE_COLOR_COST = "remove_color_cost"
|
||||||
const val COLOR_PAPER_COST = "lore_edit.paper.color.use_cost"
|
|
||||||
|
|
||||||
// Lore order config path
|
// Lore order config path
|
||||||
const val PAPER_EDIT_ORDER = "lore_edit.paper.order"
|
const val PAPER_EDIT_ORDER = "lore_edit.paper.order"
|
||||||
|
|
@ -41,13 +40,12 @@ object LoreEditConfigUtil {
|
||||||
const val DEFAULT_PAPER_PERMISSION_NEEDED = true
|
const val DEFAULT_PAPER_PERMISSION_NEEDED = true
|
||||||
|
|
||||||
// Color configs defaults
|
// Color configs defaults
|
||||||
const val DEFAULT_COLOR_BOOK_COLOR_CODE = true
|
const val DEFAULT_ALLOW_COLOR_CODE = true
|
||||||
const val DEFAULT_COLOR_BOOK_HEX = true
|
const val DEFAULT_ALLOW_HEX_COLOR = true
|
||||||
const val DEFAULT_COLOR_BOOK_COST = 0
|
const val DEFAULT_USE_COLOR_COST = 0
|
||||||
|
|
||||||
const val DEFAULT_COLOR_PAPER_COLOR_CODE = true
|
const val DEFAULT_REMOVE_COLOR_ON_LORE_REMOVE = false
|
||||||
const val DEFAULT_COLOR_PAPER_HEX = true
|
const val DEFAULT_REMOVE_COLOR_COST = 0
|
||||||
const val DEFAULT_COLOR_PAPER_COST = 0
|
|
||||||
|
|
||||||
// Lore order config default
|
// Lore order config default
|
||||||
const val DEFAULT_PAPER_EDIT_ORDER = "end"
|
const val DEFAULT_PAPER_EDIT_ORDER = "end"
|
||||||
|
|
@ -59,8 +57,8 @@ object LoreEditConfigUtil {
|
||||||
val FIXED_COST_RANGE = 0..1000
|
val FIXED_COST_RANGE = 0..1000
|
||||||
val PER_LINE_COST_RANGE = 0..1000
|
val PER_LINE_COST_RANGE = 0..1000
|
||||||
|
|
||||||
private val COLOR_BOOK_COST_RANGE = 0..1000
|
val USE_COLOR_COST_RANGE = 0..1000
|
||||||
private val COLOR_PAPER_COST_RANGE = 0..1000
|
val REMOVE_COLOR_COST_RANGE = 0..1000
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
// Generic Get methods
|
// Generic Get methods
|
||||||
|
|
@ -102,72 +100,4 @@ object LoreEditConfigUtil {
|
||||||
// Color Get methods
|
// Color Get methods
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
// book edit functions
|
|
||||||
/**
|
|
||||||
* Allow usage of color code on book lore edit
|
|
||||||
*/
|
|
||||||
val bookAllowColorCode: Boolean
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getBoolean(COLOR_BOOK_COLOR_CODE, DEFAULT_COLOR_BOOK_COLOR_CODE)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow usage of hexadecimal color on book lore edit
|
|
||||||
*/
|
|
||||||
val bookAllowHexColor: Boolean
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getBoolean(COLOR_BOOK_HEX, DEFAULT_COLOR_BOOK_HEX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cost when using either color code and hex color on book edit
|
|
||||||
*/
|
|
||||||
val bookUseColorCost: Int
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getInt(COLOR_BOOK_COST, DEFAULT_COLOR_BOOK_COST)
|
|
||||||
.takeIf { it in COLOR_BOOK_COST_RANGE }
|
|
||||||
?: DEFAULT_COLOR_BOOK_COST
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// paper edit functions
|
|
||||||
/**
|
|
||||||
* Allow usage of color code on paper lore edit
|
|
||||||
*/
|
|
||||||
val paperAllowColorCode: Boolean
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getBoolean(COLOR_PAPER_COLOR_CODE, DEFAULT_COLOR_PAPER_COLOR_CODE)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow usage of hexadecimal color on paper lore edit
|
|
||||||
*/
|
|
||||||
val paperAllowHexColor: Boolean
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getBoolean(COLOR_PAPER_HEX, DEFAULT_COLOR_PAPER_HEX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cost when using either color code and hex color on paper edit
|
|
||||||
*/
|
|
||||||
val paperUseColorCost: Int
|
|
||||||
get() {
|
|
||||||
return CONFIG
|
|
||||||
.config
|
|
||||||
.getInt(COLOR_PAPER_COST, DEFAULT_COLOR_PAPER_COST)
|
|
||||||
.takeIf { it in COLOR_PAPER_COST_RANGE }
|
|
||||||
?: DEFAULT_COLOR_PAPER_COST
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,18 @@
|
||||||
package xyz.alexcrea.cuanvil.util.config
|
package xyz.alexcrea.cuanvil.util.config
|
||||||
|
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilUseType
|
import xyz.alexcrea.cuanvil.util.AnvilUseType
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.ALLOW_COLOR_CODE
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.ALLOW_HEX_COLOR
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.DEFAULT_ALLOW_COLOR_CODE
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.DEFAULT_ALLOW_HEX_COLOR
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.DEFAULT_REMOVE_COLOR_COST
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.DEFAULT_REMOVE_COLOR_ON_LORE_REMOVE
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.DEFAULT_USE_COLOR_COST
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.REMOVE_COLOR_COST
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.REMOVE_COLOR_COST_RANGE
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.REMOVE_COLOR_ON_LORE_REMOVE
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.USE_COLOR_COST
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.USE_COLOR_COST_RANGE
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder.DEFAULT_CONFIG as CONFIG
|
import xyz.alexcrea.cuanvil.config.ConfigHolder.DEFAULT_CONFIG as CONFIG
|
||||||
|
|
||||||
enum class LoreEditType(
|
enum class LoreEditType(
|
||||||
|
|
@ -55,10 +67,70 @@ enum class LoreEditType(
|
||||||
*/
|
*/
|
||||||
val doConsume: Boolean
|
val doConsume: Boolean
|
||||||
get() {
|
get() {
|
||||||
if (!isAppend) throw IllegalStateException("Lore edit Consume test should not happen on append")
|
|
||||||
return CONFIG
|
return CONFIG
|
||||||
.config
|
.config
|
||||||
.getBoolean("${rootPath}.${LoreEditConfigUtil.DO_CONSUME}", LoreEditConfigUtil.DEFAULT_DO_CONSUME)
|
.getBoolean("${rootPath}.${LoreEditConfigUtil.DO_CONSUME}", LoreEditConfigUtil.DEFAULT_DO_CONSUME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow usage of color code on lore add
|
||||||
|
*/
|
||||||
|
val allowColorCode: Boolean
|
||||||
|
get() {
|
||||||
|
if (!isAppend) throw IllegalStateException("Can only call with an append edit type")
|
||||||
|
return CONFIG
|
||||||
|
.config
|
||||||
|
.getBoolean("$rootPath.$ALLOW_COLOR_CODE", DEFAULT_ALLOW_COLOR_CODE)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow usage of hexadecimal color on lore add
|
||||||
|
*/
|
||||||
|
val allowHexColor: Boolean
|
||||||
|
get() {
|
||||||
|
if (!isAppend) throw IllegalStateException("Can only call with an append edit type")
|
||||||
|
return CONFIG
|
||||||
|
.config
|
||||||
|
.getBoolean("${rootPath}.$ALLOW_HEX_COLOR", DEFAULT_ALLOW_HEX_COLOR)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cost when using either color code and hex color on lore add
|
||||||
|
*/
|
||||||
|
val useColorCost: Int
|
||||||
|
get() {
|
||||||
|
if (!isAppend) throw IllegalStateException("Can only call with an append edit type")
|
||||||
|
return CONFIG
|
||||||
|
.config
|
||||||
|
.getInt("${rootPath}.$USE_COLOR_COST", DEFAULT_USE_COLOR_COST)
|
||||||
|
.takeIf { it in USE_COLOR_COST_RANGE }
|
||||||
|
?: DEFAULT_USE_COLOR_COST
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the color code & hex color should get removed on lore remove
|
||||||
|
*/
|
||||||
|
val shouldRemoveColorOnLoreRemoval: Boolean
|
||||||
|
get() {
|
||||||
|
if (isAppend) throw IllegalStateException("Can only call with a remove edit type")
|
||||||
|
return CONFIG
|
||||||
|
.config
|
||||||
|
.getBoolean("${rootPath}.$REMOVE_COLOR_ON_LORE_REMOVE", DEFAULT_REMOVE_COLOR_ON_LORE_REMOVE)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cost when using either color code and hex color on lore remove
|
||||||
|
*/
|
||||||
|
val removeColorCost: Int
|
||||||
|
get() {
|
||||||
|
if (isAppend) throw IllegalStateException("Can only call with a remove edit type")
|
||||||
|
return CONFIG
|
||||||
|
.config
|
||||||
|
.getInt("${rootPath}.$REMOVE_COLOR_COST", DEFAULT_REMOVE_COLOR_COST)
|
||||||
|
.takeIf { it in REMOVE_COLOR_COST_RANGE }
|
||||||
|
?: DEFAULT_REMOVE_COLOR_COST
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -288,6 +288,13 @@ lore_edit:
|
||||||
shared_additive: false
|
shared_additive: false
|
||||||
# If adding the lore consume the book & quil
|
# If adding the lore consume the book & quil
|
||||||
do_consume: false
|
do_consume: false
|
||||||
|
# Allow using color code and hexadecimal color when editing lore via book & quil
|
||||||
|
#
|
||||||
|
# Color code are prefixed by "&" and hexadecimal color by "#"
|
||||||
|
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
|
||||||
|
allow_color_code: true
|
||||||
|
allow_hexadecimal_color: true
|
||||||
|
use_cost: 0
|
||||||
|
|
||||||
remove:
|
remove:
|
||||||
# If removing lore using book & quil is enabled
|
# If removing lore using book & quil is enabled
|
||||||
|
|
@ -300,15 +307,12 @@ lore_edit:
|
||||||
shared_increase: false
|
shared_increase: false
|
||||||
# Increase shared left item cost penalty
|
# Increase shared left item cost penalty
|
||||||
shared_additive: false
|
shared_additive: false
|
||||||
|
# If removing the lore consume the book & quil
|
||||||
# Allow using color code and hexadecimal color when editing lore via book & quil
|
do_consume: false
|
||||||
#
|
# If the color should get back to color code or hex format
|
||||||
# Color code are prefixed by "&" and hexadecimal color by "#"
|
remove_color_on_remove: true
|
||||||
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
|
# Cost of replacing colors
|
||||||
color:
|
remove_color_cost: 0
|
||||||
allow_color_code: true
|
|
||||||
allow_hexadecimal_color: true
|
|
||||||
use_cost: 0
|
|
||||||
|
|
||||||
paper:
|
paper:
|
||||||
# Permission is ca.lore_edit.paper
|
# Permission is ca.lore_edit.paper
|
||||||
|
|
@ -327,6 +331,13 @@ lore_edit:
|
||||||
shared_additive: false
|
shared_additive: false
|
||||||
# If adding the lore line consume the paper
|
# If adding the lore line consume the paper
|
||||||
do_consume: false
|
do_consume: false
|
||||||
|
# Allow using color code and hexadecimal color when editing lore via book & quil
|
||||||
|
#
|
||||||
|
# Color code are prefixed by "&" and hexadecimal color by "#"
|
||||||
|
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
|
||||||
|
allow_color_code: true
|
||||||
|
allow_hexadecimal_color: true
|
||||||
|
color_use_cost: 0
|
||||||
|
|
||||||
remove_line:
|
remove_line:
|
||||||
# If removing lore line using paper is enabled
|
# If removing lore line using paper is enabled
|
||||||
|
|
@ -337,15 +348,12 @@ lore_edit:
|
||||||
shared_increase: false
|
shared_increase: false
|
||||||
# Increase shared left item cost penalty
|
# Increase shared left item cost penalty
|
||||||
shared_additive: false
|
shared_additive: false
|
||||||
|
# If removing the lore line consume the paper
|
||||||
# Allow using color code and hexadecimal color when editing lore via book & quil
|
do_consume: false
|
||||||
#
|
# If the color should get back to color code or hex format
|
||||||
# Color code are prefixed by "&" and hexadecimal color by "#"
|
remove_color_on_remove: true
|
||||||
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
|
# Cost of replacing colors
|
||||||
color:
|
remove_color_cost: 0
|
||||||
allow_color_code: true
|
|
||||||
allow_hexadecimal_color: true
|
|
||||||
use_cost: 0
|
|
||||||
|
|
||||||
# Whether to show debug logging
|
# Whether to show debug logging
|
||||||
debug_log: false
|
debug_log: false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue