mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 16:35:57 +02:00
multiples config related add
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
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:
parent
7ea708ec14
commit
447859848b
9 changed files with 74 additions and 19 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<out String>, list: MutableList<String>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue