multiples config related add
Some checks are pending
Java CI with Gradle / build (push) Waiting to run

- Disable console debug by default
- Display log on get to console and not "click to copy"
This commit is contained in:
alexcrea 2026-06-29 13:40:03 +02:00
parent 7ea708ec14
commit 447859848b
Signed by: alexcrea
GPG key ID: E346CD16413450E3
9 changed files with 74 additions and 19 deletions

View file

@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false
# For practical reason. this only work when dialog rename is enabled # For practical reason. this only work when dialog rename is enabled
dialog_rename_keep_user_text: true dialog_rename_keep_user_text: true
# Also count left item enchantments for the final price
include_left_enchantment_for_cost: false
# Override limits for specific enchants # Override limits for specific enchants
# #
# Enchantments not listed here will use the value of default_limit # Enchantments not listed here will use the value of default_limit
@ -169,8 +172,8 @@ enchant_limits:
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
# Values here are pulled from the fandom wiki: # Values here are pulled from the minecraft wiki:
# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments # https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
# #
# If an enchantment is missing values here, or is less than 0, it will default to 0 # If an enchantment is missing values here, or is less than 0, it will default to 0
# #
@ -463,4 +466,7 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.11.0 configVersion: 1.11.0

View file

@ -119,6 +119,9 @@ permission_needed_for_dialog_rename: false
# For practical reason. this only work when dialog rename is enabled # For practical reason. this only work when dialog rename is enabled
dialog_rename_keep_user_text: true dialog_rename_keep_user_text: true
# Also count left item enchantments for the final price
include_left_enchantment_for_cost: false
# Override limits for specific enchants # Override limits for specific enchants
# #
# Enchantments not listed here will use the value of default_limit # Enchantments not listed here will use the value of default_limit
@ -175,8 +178,8 @@ enchant_limits:
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
# Values here are pulled from the fandom wiki: # Values here are pulled from the minecraft wiki:
# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments # https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
# #
# If an enchantment is missing values here, or is less than 0, it will default to 0 # If an enchantment is missing values here, or is less than 0, it will default to 0
# #
@ -483,5 +486,8 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.15.5 configVersion: 1.15.5
lowMinecraftVersion: 1.21.11 lowMinecraftVersion: 1.21.11

View file

@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false
# For practical reason. this only work when dialog rename is enabled # For practical reason. this only work when dialog rename is enabled
dialog_rename_keep_user_text: true dialog_rename_keep_user_text: true
# Also count left item enchantments for the final price
include_left_enchantment_for_cost: false
# Override limits for specific enchants # Override limits for specific enchants
# #
# Enchantments not listed here will use the value of default_limit # Enchantments not listed here will use the value of default_limit
@ -172,8 +175,8 @@ enchant_limits:
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
# Values here are pulled from the fandom wiki: # Values here are pulled from the minecraft wiki:
# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments # https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
# #
# If an enchantment is missing values here, or is less than 0, it will default to 0 # If an enchantment is missing values here, or is less than 0, it will default to 0
# #
@ -475,5 +478,8 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.11.0 configVersion: 1.11.0
lowMinecraftVersion: 1.21.9 lowMinecraftVersion: 1.21.9

View file

@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false
# For practical reason. this only work when dialog rename is enabled # For practical reason. this only work when dialog rename is enabled
dialog_rename_keep_user_text: true dialog_rename_keep_user_text: true
# Also count left item enchantments for the final price
include_left_enchantment_for_cost: false
# Override limits for specific enchants # Override limits for specific enchants
# #
# Enchantments not listed here will use the value of default_limit # Enchantments not listed here will use the value of default_limit
@ -169,8 +172,8 @@ enchant_limits:
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
# Values here are pulled from the fandom wiki: # Values here are pulled from the minecraft wiki:
# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments # https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
# #
# If an enchantment is missing values here, or is less than 0, it will default to 0 # If an enchantment is missing values here, or is less than 0, it will default to 0
# #
@ -463,4 +466,7 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.11.0 configVersion: 1.11.0

View file

@ -66,6 +66,12 @@ public class PluginSetDefault {
nbSet += trySetDefault(config, DIALOG_RENAME_USE_PERMISSION, DEFAULT_DIALOG_RENAME_USE_PERMISSION); nbSet += trySetDefault(config, DIALOG_RENAME_USE_PERMISSION, DEFAULT_DIALOG_RENAME_USE_PERMISSION);
nbSet += trySetDefault(config, DIALOG_KEEP_USER_TEXT, DEFAULT_DIALOG_KEEP_USER_TEXT); nbSet += trySetDefault(config, DIALOG_KEEP_USER_TEXT, DEFAULT_DIALOG_KEEP_USER_TEXT);
nbSet += trySetDefault(config, INCLUDE_LEFT_ENCHANTMENT_FOR_COST, DEFAULT_INCLUDE_LEFT_ENCHANTMENT_FOR_COST);
nbSet += trySetDefault(config, DEBUG_LOGGING, DEFAULT_DEBUG_LOG);
nbSet += trySetDefault(config, VERBOSE_DEBUG_LOGGING, DEFAULT_VERBOSE_DEBUG_LOG);
nbSet += trySetDefault(config, SHOW_CONSOLE_DEBUG_LOGGING, DEFAULT_SHOW_CONSOLE_DEBUG_LOGGING);
if (nbSet > 0) { if (nbSet > 0) {
CustomAnvil.instance.getLogger().info("Adding " + nbSet + " absent default config values."); CustomAnvil.instance.getLogger().info("Adding " + nbSet + " absent default config values.");
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);

View file

@ -76,7 +76,7 @@ open class CustomAnvil : JavaPlugin() {
private fun addToLogQueue(message: String) { private fun addToLogQueue(message: String) {
if(debugStorageQueue.size >= 200) { if(debugStorageQueue.size >= 200) {
// Let not store infinite debug logs lol // Let not store infinite debug logs
debugStorageQueue.removeFirst() debugStorageQueue.removeFirst()
} }
@ -88,6 +88,7 @@ open class CustomAnvil : JavaPlugin() {
*/ */
@JvmStatic fun log(message: String) { @JvmStatic fun log(message: String) {
if (ConfigOptions.debugLog) { if (ConfigOptions.debugLog) {
if(ConfigOptions.showDebugLogInConsole)
instance.logger.info(message) instance.logger.info(message)
addToLogQueue(message) addToLogQueue(message)
} }
@ -98,6 +99,7 @@ open class CustomAnvil : JavaPlugin() {
*/ */
@JvmStatic fun verboseLog(message: String) { @JvmStatic fun verboseLog(message: String) {
if (ConfigOptions.verboseDebugLog) { if (ConfigOptions.verboseDebugLog) {
if(ConfigOptions.showDebugLogInConsole)
instance.logger.info(message) instance.logger.info(message)
addToLogQueue(message) addToLogQueue(message)
} }

View file

@ -91,6 +91,7 @@ object ConfigOptions {
// Debug flag // Debug flag
const val DEBUG_LOGGING = "debug_log" const val DEBUG_LOGGING = "debug_log"
const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose" const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose"
const val SHOW_CONSOLE_DEBUG_LOGGING = "display_debug_in_console"
// ---------------------- // ----------------------
// Default config values // Default config values
@ -129,8 +130,9 @@ object ConfigOptions {
const val DEFAULT_MONEY_MULTIPLIER = 1.0 const val DEFAULT_MONEY_MULTIPLIER = 1.0
// Debug flag // Debug flag
private const val DEFAULT_DEBUG_LOG = false const val DEFAULT_DEBUG_LOG = false
private const val DEFAULT_VERBOSE_DEBUG_LOG = false const val DEFAULT_VERBOSE_DEBUG_LOG = false
const val DEFAULT_SHOW_CONSOLE_DEBUG_LOGGING = false
var OVERRIDE_DEBUG_LOG: Boolean? = null var OVERRIDE_DEBUG_LOG: Boolean? = null
var OVERRIDE_VERBOSE_DEBUG_LOG: Boolean? = null var OVERRIDE_VERBOSE_DEBUG_LOG: Boolean? = null
@ -471,6 +473,19 @@ object ConfigOptions {
.getBoolean(VERBOSE_DEBUG_LOGGING, DEFAULT_VERBOSE_DEBUG_LOG) .getBoolean(VERBOSE_DEBUG_LOGGING, DEFAULT_VERBOSE_DEBUG_LOG)
} }
/**
* Whether to show debug in console
*/
val showDebugLogInConsole: Boolean
get() {
val overrider = OVERRIDE_VERBOSE_DEBUG_LOG
if(overrider != null) return overrider
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(SHOW_CONSOLE_DEBUG_LOGGING, DEFAULT_SHOW_CONSOLE_DEBUG_LOGGING)
}
/** /**
* Is the dialog menu for rename enabled * Is the dialog menu for rename enabled
*/ */

View file

@ -9,6 +9,7 @@ import net.md_5.bungee.api.chat.hover.content.Text
import org.bukkit.ChatColor import org.bukkit.ChatColor
import org.bukkit.command.Command import org.bukkit.command.Command
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.command.DiagnosticExecutor.Companion.NO_DIAG_PERM import xyz.alexcrea.cuanvil.command.DiagnosticExecutor.Companion.NO_DIAG_PERM
class DebugToggleExecutor : CASubCommand() { class DebugToggleExecutor : CASubCommand() {
@ -87,12 +88,16 @@ class DebugToggleExecutor : CASubCommand() {
stb.append('\n').append(log) stb.append('\n').append(log)
} }
if (sender is Player) {
val message = TextComponent(ChatColor.GREEN.toString() + "Click to copy log data") val message = TextComponent(ChatColor.GREEN.toString() + "Click to copy log data")
message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString()) message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString())
message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy")) message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy"))
sender.spigot().sendMessage(message); sender.spigot().sendMessage(message);
} else {
sender.sendMessage(stb.toString())
}
} }
override fun tabCompleter(sender: CommandSender, args: Array<out String>, list: MutableList<String>) { override fun tabCompleter(sender: CommandSender, args: Array<out String>, list: MutableList<String>) {

View file

@ -174,8 +174,8 @@ enchant_limits:
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
# Values here are pulled from the fandom wiki: # Values here are pulled from the minecraft wiki:
# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments # https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
# #
# If an enchantment is missing values here, or is less than 0, it will default to 0 # If an enchantment is missing values here, or is less than 0, it will default to 0
# #
@ -469,4 +469,7 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.11.0 configVersion: 1.11.0