diff --git a/defaultconfigs/1.18/config.yml b/defaultconfigs/1.18/config.yml index b5ad3b01..4e08ca20 100644 --- a/defaultconfigs/1.18/config.yml +++ b/defaultconfigs/1.18/config.yml @@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false # For practical reason. this only work when dialog rename is enabled 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 # # 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 # -# Values here are pulled from the fandom wiki: -# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# Values here are pulled from the minecraft wiki: +# 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 # @@ -463,4 +466,7 @@ debug_log: false # Whether to show verbose debug logging 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 diff --git a/defaultconfigs/1.21.11/config.yml b/defaultconfigs/1.21.11/config.yml index 44885b74..98f9a94d 100644 --- a/defaultconfigs/1.21.11/config.yml +++ b/defaultconfigs/1.21.11/config.yml @@ -119,6 +119,9 @@ permission_needed_for_dialog_rename: false # For practical reason. this only work when dialog rename is enabled 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 # # 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 # -# Values here are pulled from the fandom wiki: -# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# Values here are pulled from the minecraft wiki: +# 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 # @@ -483,5 +486,8 @@ debug_log: false # Whether to show verbose debug logging 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 lowMinecraftVersion: 1.21.11 diff --git a/defaultconfigs/1.21.9/config.yml b/defaultconfigs/1.21.9/config.yml index 4df58766..7b3afce1 100644 --- a/defaultconfigs/1.21.9/config.yml +++ b/defaultconfigs/1.21.9/config.yml @@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false # For practical reason. this only work when dialog rename is enabled 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 # # 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 # -# Values here are pulled from the fandom wiki: -# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# Values here are pulled from the minecraft wiki: +# 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 # @@ -475,5 +478,8 @@ debug_log: false # Whether to show verbose debug logging 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 lowMinecraftVersion: 1.21.9 diff --git a/defaultconfigs/1.21/config.yml b/defaultconfigs/1.21/config.yml index 5d59e5a6..cb7e382b 100644 --- a/defaultconfigs/1.21/config.yml +++ b/defaultconfigs/1.21/config.yml @@ -117,6 +117,9 @@ permission_needed_for_dialog_rename: false # For practical reason. this only work when dialog rename is enabled 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 # # 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 # -# Values here are pulled from the fandom wiki: -# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# Values here are pulled from the minecraft wiki: +# 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 # @@ -463,4 +466,7 @@ debug_log: false # Whether to show verbose debug logging 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 \ No newline at end of file diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/PluginSetDefault.java b/src/main/java/xyz/alexcrea/cuanvil/update/PluginSetDefault.java index 707a218c..dd70295a 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/PluginSetDefault.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/PluginSetDefault.java @@ -66,6 +66,12 @@ public class PluginSetDefault { 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, 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) { CustomAnvil.instance.getLogger().info("Adding " + nbSet + " absent default config values."); ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); diff --git a/src/main/kotlin/io/delilaheve/CustomAnvil.kt b/src/main/kotlin/io/delilaheve/CustomAnvil.kt index e12ba4d6..321165e5 100644 --- a/src/main/kotlin/io/delilaheve/CustomAnvil.kt +++ b/src/main/kotlin/io/delilaheve/CustomAnvil.kt @@ -76,7 +76,7 @@ open class CustomAnvil : JavaPlugin() { private fun addToLogQueue(message: String) { if(debugStorageQueue.size >= 200) { - // Let not store infinite debug logs lol + // Let not store infinite debug logs debugStorageQueue.removeFirst() } @@ -88,7 +88,8 @@ open class CustomAnvil : JavaPlugin() { */ @JvmStatic fun log(message: String) { if (ConfigOptions.debugLog) { - instance.logger.info(message) + if(ConfigOptions.showDebugLogInConsole) + instance.logger.info(message) addToLogQueue(message) } } @@ -98,7 +99,8 @@ open class CustomAnvil : JavaPlugin() { */ @JvmStatic fun verboseLog(message: String) { if (ConfigOptions.verboseDebugLog) { - instance.logger.info(message) + if(ConfigOptions.showDebugLogInConsole) + instance.logger.info(message) addToLogQueue(message) } } diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index 7552f1c4..fc8a53a9 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -91,6 +91,7 @@ object ConfigOptions { // Debug flag const val DEBUG_LOGGING = "debug_log" const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose" + const val SHOW_CONSOLE_DEBUG_LOGGING = "display_debug_in_console" // ---------------------- // Default config values @@ -129,8 +130,9 @@ object ConfigOptions { const val DEFAULT_MONEY_MULTIPLIER = 1.0 // Debug flag - private const val DEFAULT_DEBUG_LOG = false - private const val DEFAULT_VERBOSE_DEBUG_LOG = false + const val DEFAULT_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_VERBOSE_DEBUG_LOG: Boolean? = null @@ -471,6 +473,19 @@ object ConfigOptions { .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 */ diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/command/DebugToggleExecutor.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/command/DebugToggleExecutor.kt index 9959d269..c668e6e0 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/command/DebugToggleExecutor.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/command/DebugToggleExecutor.kt @@ -9,6 +9,7 @@ import net.md_5.bungee.api.chat.hover.content.Text import org.bukkit.ChatColor import org.bukkit.command.Command import org.bukkit.command.CommandSender +import org.bukkit.entity.Player import xyz.alexcrea.cuanvil.command.DiagnosticExecutor.Companion.NO_DIAG_PERM class DebugToggleExecutor : CASubCommand() { @@ -87,12 +88,16 @@ class DebugToggleExecutor : CASubCommand() { stb.append('\n').append(log) } - val message = TextComponent(ChatColor.GREEN.toString() + "Click to copy log data") + if (sender is Player) { + val message = TextComponent(ChatColor.GREEN.toString() + "Click to copy log data") - message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString()) - message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy")) + message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString()) + 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, list: MutableList) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index fff78b29..c8fefb53 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -174,8 +174,8 @@ enchant_limits: # Multipliers used to calculate the enchantment's value in repair/combining # -# Values here are pulled from the fandom wiki: -# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# Values here are pulled from the minecraft wiki: +# 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 # @@ -469,4 +469,7 @@ debug_log: false # Whether to show verbose debug logging 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