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;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import io.delilaheve.util.ConfigOptions;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil;
|
||||
import xyz.alexcrea.cuanvil.util.config.LoreEditType;
|
||||
|
||||
import static io.delilaheve.util.ConfigOptions.*;
|
||||
|
|
@ -11,75 +13,74 @@ import static xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil.*;
|
|||
|
||||
public class PluginSetDefault {
|
||||
|
||||
public static void reAddMissingDefault(){
|
||||
public static void reAddMissingDefault() {
|
||||
FileConfiguration config = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||
|
||||
int nbSet = 0;
|
||||
|
||||
nbSet+= trySetDefault(config, CAP_ANVIL_COST, DEFAULT_CAP_ANVIL_COST);
|
||||
nbSet+= trySetDefault(config, MAX_ANVIL_COST, DEFAULT_MAX_ANVIL_COST);
|
||||
nbSet+= trySetDefault(config, REMOVE_ANVIL_COST_LIMIT, DEFAULT_REMOVE_ANVIL_COST_LIMIT);
|
||||
nbSet+= trySetDefault(config, REPLACE_TOO_EXPENSIVE, DEFAULT_REPLACE_TOO_EXPENSIVE);
|
||||
nbSet+= trySetDefault(config, ITEM_REPAIR_COST, DEFAULT_ITEM_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, SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST);
|
||||
nbSet+= trySetDefault(config, ALLOW_COLOR_CODE, DEFAULT_ALLOW_COLOR_CODE);
|
||||
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, USE_OF_COLOR_COST, DEFAULT_USE_OF_COLOR_COST);
|
||||
nbSet+= trySetDefault(config, DEFAULT_LIMIT_PATH, DEFAULT_ENCHANT_LIMIT);
|
||||
nbSet += trySetDefault(config, CAP_ANVIL_COST, DEFAULT_CAP_ANVIL_COST);
|
||||
nbSet += trySetDefault(config, MAX_ANVIL_COST, DEFAULT_MAX_ANVIL_COST);
|
||||
nbSet += trySetDefault(config, REMOVE_ANVIL_COST_LIMIT, DEFAULT_REMOVE_ANVIL_COST_LIMIT);
|
||||
nbSet += trySetDefault(config, REPLACE_TOO_EXPENSIVE, DEFAULT_REPLACE_TOO_EXPENSIVE);
|
||||
nbSet += trySetDefault(config, ITEM_REPAIR_COST, DEFAULT_ITEM_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, SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST);
|
||||
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, PERMISSION_NEEDED_FOR_COLOR, DEFAULT_PERMISSION_NEEDED_FOR_COLOR);
|
||||
nbSet += trySetDefault(config, USE_OF_COLOR_COST, DEFAULT_USE_OF_COLOR_COST);
|
||||
nbSet += trySetDefault(config, DEFAULT_LIMIT_PATH, DEFAULT_ENCHANT_LIMIT);
|
||||
|
||||
// Lore Edit defaults
|
||||
for (@NotNull LoreEditType value : LoreEditType.values()) {
|
||||
String path = value.getRootPath() + ".";
|
||||
|
||||
nbSet+= trySetDefault(config, path + IS_ENABLED, DEFAULT_IS_ENABLED);
|
||||
nbSet+= trySetDefault(config, path + FIXED_COST, DEFAULT_FIXED_COST);
|
||||
if(value.isMultiLine()){
|
||||
nbSet+= trySetDefault(config, path + PER_LINE_COST, DEFAULT_PER_LINE_COST);
|
||||
nbSet += trySetDefault(config, path + IS_ENABLED, DEFAULT_IS_ENABLED);
|
||||
nbSet += trySetDefault(config, path + FIXED_COST, DEFAULT_FIXED_COST);
|
||||
|
||||
nbSet += trySetDefault(config, path + DO_CONSUME, DEFAULT_DO_CONSUME);
|
||||
if (value.isMultiLine()) {
|
||||
nbSet += trySetDefault(config, path + PER_LINE_COST, DEFAULT_PER_LINE_COST);
|
||||
}
|
||||
if(value.isAppend()){
|
||||
nbSet+= trySetDefault(config, path + DO_CONSUME, DEFAULT_DO_CONSUME);
|
||||
if (value.isAppend()) {
|
||||
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, PAPER_PERMISSION_NEEDED, DEFAULT_PAPER_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, 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, PAPER_EDIT_ORDER, DEFAULT_PAPER_EDIT_ORDER);
|
||||
|
||||
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);
|
||||
|
||||
if(nbSet > 0){
|
||||
if (nbSet > 0) {
|
||||
CustomAnvil.instance.getLogger().info("Adding " + nbSet + " absent default config values.");
|
||||
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, @NotNull String value){
|
||||
if(config.isSet(path)) return 0;
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, @NotNull String value) {
|
||||
if (config.isSet(path)) return 0;
|
||||
|
||||
config.set(path, value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, int value){
|
||||
if(config.isSet(path)) return 0;
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, int value) {
|
||||
if (config.isSet(path)) return 0;
|
||||
|
||||
config.set(path, value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, boolean value){
|
||||
if(config.isSet(path)) return 0;
|
||||
private static int trySetDefault(@NotNull FileConfiguration config, @NotNull String path, boolean value) {
|
||||
if (config.isSet(path)) return 0;
|
||||
|
||||
config.set(path, value);
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -352,22 +352,27 @@ class AnvilResultListener : Listener {
|
|||
val lore = ArrayList<String>(meta.lore!!)
|
||||
if (lore.isEmpty()) return false
|
||||
|
||||
// Uncolor the page
|
||||
AnvilLoreEditUtil.uncolorLines(player, lore, LoreEditType.REMOVE_BOOK)
|
||||
val rightCopy : ItemStack?
|
||||
if (LoreEditType.APPEND_PAPER.doConsume) {
|
||||
rightCopy = null
|
||||
} else {
|
||||
// Uncolor the page
|
||||
AnvilLoreEditUtil.uncolorLines(player, lore, LoreEditType.REMOVE_BOOK)
|
||||
|
||||
val bookPage = StringBuilder()
|
||||
lore.forEach {
|
||||
if (bookPage.isNotEmpty()) bookPage.append('\n')
|
||||
bookPage.append(it)
|
||||
val bookPage = StringBuilder()
|
||||
lore.forEach {
|
||||
if (bookPage.isNotEmpty()) bookPage.append('\n')
|
||||
bookPage.append(it)
|
||||
}
|
||||
|
||||
val resultPage = bookPage.toString()
|
||||
//TODO maybe check page size ? bc it may be too big ???
|
||||
|
||||
rightCopy = rightItem.clone()
|
||||
bookMeta.setPages(resultPage)
|
||||
rightCopy.itemMeta = bookMeta
|
||||
}
|
||||
|
||||
val resultPage = bookPage.toString()
|
||||
//TODO maybe check page size ? bc it may be too big ???
|
||||
|
||||
val rightCopy = rightItem.clone()
|
||||
bookMeta.setPages(resultPage)
|
||||
rightCopy.itemMeta = bookMeta
|
||||
|
||||
return extractAnvilResult(
|
||||
event, player, inventory,
|
||||
null, 0,
|
||||
|
|
@ -428,23 +433,28 @@ class AnvilResultListener : Listener {
|
|||
val lore = leftMeta.lore!!
|
||||
if (lore.isEmpty()) return false
|
||||
|
||||
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
||||
var line = if (removeEnd) lore[lore.size - 1]
|
||||
else lore[0]
|
||||
|
||||
// Overkill but uncolor the line
|
||||
val tempList = ArrayList<String>(1)
|
||||
tempList.add(line)
|
||||
AnvilLoreEditUtil.uncolorLines(player, tempList, LoreEditType.REMOVE_PAPER)
|
||||
line = tempList[0]
|
||||
|
||||
// Create result item
|
||||
val rightClone = rightItem.clone()
|
||||
rightClone.amount = 1
|
||||
val rightClone: ItemStack?
|
||||
if(LoreEditType.REMOVE_PAPER.doConsume){
|
||||
rightClone = null
|
||||
}else{
|
||||
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
||||
var line = if (removeEnd) lore[lore.size - 1]
|
||||
else lore[0]
|
||||
|
||||
val resultMeta = rightClone.itemMeta ?: return false
|
||||
resultMeta.setDisplayName(line)
|
||||
rightClone.itemMeta = resultMeta
|
||||
// Overkill but uncolor the line
|
||||
val tempList = ArrayList<String>(1)
|
||||
tempList.add(line)
|
||||
AnvilLoreEditUtil.uncolorLines(player, tempList, LoreEditType.REMOVE_PAPER)
|
||||
line = tempList[0]
|
||||
|
||||
rightClone = rightItem.clone()
|
||||
rightClone.amount = 1
|
||||
|
||||
val resultMeta = rightClone.itemMeta ?: return false
|
||||
resultMeta.setDisplayName(line)
|
||||
rightClone.itemMeta = resultMeta
|
||||
}
|
||||
|
||||
return if (rightItem.amount > 1) {
|
||||
extractAnvilResult(
|
||||
|
|
|
|||
|
|
@ -227,21 +227,10 @@ object AnvilLoreEditUtil {
|
|||
return xpCost
|
||||
}
|
||||
|
||||
private fun colorLines(player: Permissible, lines: ArrayList<String>, useType: LoreEditType): Int {
|
||||
val canUseHex: Boolean
|
||||
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
|
||||
}
|
||||
private fun colorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
||||
val canUseHex = editType.allowHexColor
|
||||
val canUseColorCode = editType.allowColorCode
|
||||
val colorCost = editType.useColorCost
|
||||
|
||||
// Now handle color of each lines
|
||||
var hasUsedColor = false
|
||||
|
|
@ -268,21 +257,8 @@ object AnvilLoreEditUtil {
|
|||
}
|
||||
}
|
||||
|
||||
fun uncolorLines(player: Permissible, lines: ArrayList<String>, useType: LoreEditType): Int {
|
||||
val canUseHex: Boolean
|
||||
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
|
||||
}
|
||||
fun uncolorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
||||
if(!editType.shouldRemoveColorOnLoreRemoval) return 0
|
||||
|
||||
// Now handle color of each lines
|
||||
var hasUndidColor = false
|
||||
|
|
@ -292,7 +268,7 @@ object AnvilLoreEditUtil {
|
|||
val lineUndidColor = AnvilColorUtil.revertColor(
|
||||
uncoloredLine,
|
||||
player,
|
||||
false, canUseColorCode, canUseHex,
|
||||
false, true, true,
|
||||
AnvilColorUtil.ColorUseType.LORE_EDIT
|
||||
)
|
||||
|
||||
|
|
@ -303,7 +279,7 @@ object AnvilLoreEditUtil {
|
|||
}
|
||||
|
||||
return if (hasUndidColor) {
|
||||
colorCost
|
||||
editType.removeColorCost
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@ object LoreEditConfigUtil {
|
|||
const val PAPER_PERMISSION_NEEDED = "lore_edit.paper.use_permission"
|
||||
|
||||
// Color configs path
|
||||
const val COLOR_BOOK_COLOR_CODE = "lore_edit.book_and_quil.color.allow_color_code"
|
||||
const val COLOR_BOOK_HEX = "lore_edit.book_and_quil.color.allow_hexadecimal_color"
|
||||
const val COLOR_BOOK_COST = "lore_edit.book_and_quil.color.use_cost"
|
||||
const val ALLOW_COLOR_CODE = "allow_color_code"
|
||||
const val ALLOW_HEX_COLOR = "allow_hexadecimal_color"
|
||||
const val USE_COLOR_COST = "use_cost"
|
||||
|
||||
const val COLOR_PAPER_COLOR_CODE = "lore_edit.paper.color.allow_color_code"
|
||||
const val COLOR_PAPER_HEX = "lore_edit.paper.color.allow_hexadecimal_color"
|
||||
const val COLOR_PAPER_COST = "lore_edit.paper.color.use_cost"
|
||||
const val REMOVE_COLOR_ON_LORE_REMOVE = "remove_color_on_remove"
|
||||
const val REMOVE_COLOR_COST = "remove_color_cost"
|
||||
|
||||
// Lore order config path
|
||||
const val PAPER_EDIT_ORDER = "lore_edit.paper.order"
|
||||
|
|
@ -41,13 +40,12 @@ object LoreEditConfigUtil {
|
|||
const val DEFAULT_PAPER_PERMISSION_NEEDED = true
|
||||
|
||||
// Color configs defaults
|
||||
const val DEFAULT_COLOR_BOOK_COLOR_CODE = true
|
||||
const val DEFAULT_COLOR_BOOK_HEX = true
|
||||
const val DEFAULT_COLOR_BOOK_COST = 0
|
||||
const val DEFAULT_ALLOW_COLOR_CODE = true
|
||||
const val DEFAULT_ALLOW_HEX_COLOR = true
|
||||
const val DEFAULT_USE_COLOR_COST = 0
|
||||
|
||||
const val DEFAULT_COLOR_PAPER_COLOR_CODE = true
|
||||
const val DEFAULT_COLOR_PAPER_HEX = true
|
||||
const val DEFAULT_COLOR_PAPER_COST = 0
|
||||
const val DEFAULT_REMOVE_COLOR_ON_LORE_REMOVE = false
|
||||
const val DEFAULT_REMOVE_COLOR_COST = 0
|
||||
|
||||
// Lore order config default
|
||||
const val DEFAULT_PAPER_EDIT_ORDER = "end"
|
||||
|
|
@ -59,8 +57,8 @@ object LoreEditConfigUtil {
|
|||
val FIXED_COST_RANGE = 0..1000
|
||||
val PER_LINE_COST_RANGE = 0..1000
|
||||
|
||||
private val COLOR_BOOK_COST_RANGE = 0..1000
|
||||
private val COLOR_PAPER_COST_RANGE = 0..1000
|
||||
val USE_COLOR_COST_RANGE = 0..1000
|
||||
val REMOVE_COLOR_COST_RANGE = 0..1000
|
||||
|
||||
// -------------------
|
||||
// Generic Get methods
|
||||
|
|
@ -102,72 +100,4 @@ object LoreEditConfigUtil {
|
|||
// 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
|
||||
|
||||
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
|
||||
|
||||
enum class LoreEditType(
|
||||
|
|
@ -10,9 +22,9 @@ enum class LoreEditType(
|
|||
val isMultiLine: Boolean,
|
||||
) {
|
||||
APPEND_BOOK("lore_edit.book_and_quil.append", AnvilUseType.LORE_EDIT_BOOK_APPEND, true, true),
|
||||
REMOVE_BOOK("lore_edit.book_and_quil.remove", AnvilUseType.LORE_EDIT_BOOK_REMOVE,false, true),
|
||||
APPEND_PAPER("lore_edit.paper.append_line", AnvilUseType.LORE_EDIT_PAPER_APPEND,true, false),
|
||||
REMOVE_PAPER("lore_edit.paper.remove_line", AnvilUseType.LORE_EDIT_PAPER_REMOVE,false, false),
|
||||
REMOVE_BOOK("lore_edit.book_and_quil.remove", AnvilUseType.LORE_EDIT_BOOK_REMOVE, false, true),
|
||||
APPEND_PAPER("lore_edit.paper.append_line", AnvilUseType.LORE_EDIT_PAPER_APPEND, true, false),
|
||||
REMOVE_PAPER("lore_edit.paper.remove_line", AnvilUseType.LORE_EDIT_PAPER_REMOVE, false, false),
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -55,10 +67,70 @@ enum class LoreEditType(
|
|||
*/
|
||||
val doConsume: Boolean
|
||||
get() {
|
||||
if (!isAppend) throw IllegalStateException("Lore edit Consume test should not happen on append")
|
||||
return CONFIG
|
||||
.config
|
||||
.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
|
||||
# If adding the lore consume the book & quil
|
||||
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:
|
||||
# If removing lore using book & quil is enabled
|
||||
|
|
@ -300,15 +307,12 @@ lore_edit:
|
|||
shared_increase: false
|
||||
# Increase shared left item cost penalty
|
||||
shared_additive: 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 "&"
|
||||
color:
|
||||
allow_color_code: true
|
||||
allow_hexadecimal_color: true
|
||||
use_cost: 0
|
||||
# If removing the lore consume the book & quil
|
||||
do_consume: false
|
||||
# If the color should get back to color code or hex format
|
||||
remove_color_on_remove: true
|
||||
# Cost of replacing colors
|
||||
remove_color_cost: 0
|
||||
|
||||
paper:
|
||||
# Permission is ca.lore_edit.paper
|
||||
|
|
@ -327,6 +331,13 @@ lore_edit:
|
|||
shared_additive: false
|
||||
# If adding the lore line consume the paper
|
||||
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:
|
||||
# If removing lore line using paper is enabled
|
||||
|
|
@ -337,15 +348,12 @@ lore_edit:
|
|||
shared_increase: false
|
||||
# Increase shared left item cost penalty
|
||||
shared_additive: 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 "&"
|
||||
color:
|
||||
allow_color_code: true
|
||||
allow_hexadecimal_color: true
|
||||
use_cost: 0
|
||||
# If removing the lore line consume the paper
|
||||
do_consume: false
|
||||
# If the color should get back to color code or hex format
|
||||
remove_color_on_remove: true
|
||||
# Cost of replacing colors
|
||||
remove_color_cost: 0
|
||||
|
||||
# Whether to show debug logging
|
||||
debug_log: false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue