add verbose log

This commit is contained in:
alexcrea 2024-03-25 02:09:09 +01:00
parent 27b949d1e5
commit 4b5ecf301a
7 changed files with 47 additions and 4 deletions

View file

@ -64,6 +64,7 @@ class AnvilEventListener : Listener {
// Test/stop if nothing changed.
if(first == resultItem){
CustomAnvil.log("no right item, But input is same as output")
event.result = null
return
}
@ -95,6 +96,7 @@ class AnvilEventListener : Listener {
// Test/stop if nothing changed.
if(first == resultItem){
CustomAnvil.log("Mergable with second, But input is same as output")
event.result = null
return
}
@ -125,6 +127,7 @@ class AnvilEventListener : Listener {
// Test/stop if nothing changed.
if(first == resultItem){
CustomAnvil.log("unit repair, But input is same as output")
event.result = null
return
}
@ -132,6 +135,7 @@ class AnvilEventListener : Listener {
handleAnvilXp(inventory, event, anvilCost)
}else{
CustomAnvil.log("no anvil fuse type found")
event.result = null
}
}

View file

@ -49,6 +49,15 @@ class CustomAnvil : JavaPlugin() {
instance.logger.info(message)
}
}
/**
* Vebose Logging handler
*/
fun verboseLog(message: String) {
if (ConfigOptions.verboseDebugLog) {
instance.logger.info(message)
}
}
}
/**

View file

@ -35,6 +35,8 @@ object ConfigOptions {
private const val KEY_ITEM = "item"
// Debug logging toggle path
private const val DEBUG_LOGGING = "debug_log"
// Debug verbose logging toggle path
private const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose"
// Default value for enchantment limits
private const val DEFAULT_ENCHANT_LIMIT = 5
@ -71,6 +73,8 @@ object ConfigOptions {
private const val DEFAULT_ENCHANT_VALUE = 0
// Default value for debug logging
private const val DEFAULT_DEBUG_LOG = false
// Default value for debug logging
private const val DEFAULT_VERBOSE_DEBUG_LOG = false
/**
* Default enchantment limit
@ -171,6 +175,16 @@ object ConfigOptions {
.getBoolean(DEBUG_LOGGING, DEFAULT_DEBUG_LOG)
}
/**
* Whether to show verbose debug logging
*/
val verboseDebugLog: Boolean
get() {
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(VERBOSE_DEBUG_LOGGING, DEFAULT_VERBOSE_DEBUG_LOG)
}
/**
* Get the given [enchantment]'s limit
*/

View file

@ -32,10 +32,12 @@ object EnchantmentUtil {
other.forEach { (enchantment, level) ->
// Enchantment not yet in result list
if (!containsKey(enchantment)) {
// Add the enchantment if it doesn't have conflicts, or, if player is allowed to bypass enchantment restrictions
// Add the enchantment if it doesn't have conflicts, or if player is allowed to bypass enchantment restrictions
this[enchantment] = level
val conflictType = ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this.keys,mat,enchantment);
if(!player.hasPermission(CustomAnvil.bypassFusePermission) &&
(ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)){
(conflictType != ConflictType.NO_CONFLICT)){
CustomAnvil.verboseLog("Enchantment not yet in result list, but there is conflict (${enchantment.key}, conflict: $conflictType)")
this.remove(enchantment)
}
@ -43,8 +45,10 @@ object EnchantmentUtil {
// Enchantment already in result list
else{
// ... and they are conflicting
if((ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)
val conflictType = ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this.keys,mat,enchantment)
if((conflictType != ConflictType.NO_CONFLICT)
&& !player.hasPermission(CustomAnvil.bypassFusePermission)){
CustomAnvil.verboseLog("Enchantment already in result list, and they are conflicting (${enchantment.key}, conflict: $conflictType)")
return@forEach
}
@ -52,6 +56,7 @@ object EnchantmentUtil {
if(this[enchantment] != other[enchantment]){
val newLevel = max(this[enchantment] ?: 0, other[enchantment] ?: 0)
// apply the greater of the two if non-zero
if (newLevel > 0) { this[enchantment] = newLevel }
}
// ... and they're the same level