mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
error logging and bstats simple pie
This commit is contained in:
parent
3e68af06ea
commit
48f0cab15d
9 changed files with 37 additions and 9 deletions
|
|
@ -165,8 +165,8 @@ tasks {
|
|||
archiveFileName.set(name)
|
||||
|
||||
// Shadow necessary dependency
|
||||
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.customanvil.inventoryframework")
|
||||
relocate("dev.faststats", "xyz.alexcrea.customanvil.faststats")
|
||||
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.cuanvil.inventoryframework")
|
||||
relocate("dev.faststats", "xyz.alexcrea.cuanvil.faststats")
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand(
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import xyz.alexcrea.cuanvil.group.EnchantConflictManager;
|
||||
import xyz.alexcrea.cuanvil.group.ItemGroupManager;
|
||||
import xyz.alexcrea.cuanvil.recipe.CustomAnvilRecipeManager;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -145,6 +146,7 @@ public abstract class ConfigHolder {
|
|||
sufficientSuccess = true;
|
||||
} catch (IOException e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "Could not copy backup saving config " + base.getName(), e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
}
|
||||
}
|
||||
// save last backup
|
||||
|
|
@ -275,6 +277,7 @@ public abstract class ConfigHolder {
|
|||
this.deletedConfigFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "Could not create " + this.deletedConfigFile.getPath(), e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
}
|
||||
loadDeletedListFile(false);
|
||||
|
||||
|
|
@ -312,6 +315,7 @@ public abstract class ConfigHolder {
|
|||
this.deletedListConfig.save(this.deletedConfigFile);
|
||||
} catch (IOException e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "Could not save " + this.deletedConfigFile.getPath(), e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import xyz.alexcrea.cuanvil.enchant.bulk.BukkitEnchantBulkOperation;
|
|||
import xyz.alexcrea.cuanvil.enchant.bulk.BulkCleanEnchantOperation;
|
||||
import xyz.alexcrea.cuanvil.enchant.bulk.BulkGetEnchantOperation;
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CABukkitEnchantment;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -85,11 +86,13 @@ public class CAEnchantmentRegistry {
|
|||
return false;
|
||||
}
|
||||
|
||||
var error = new IllegalStateException("enchantment " + enchantment.getKey() + " was already registered");
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING,
|
||||
"Duplicate distinct registered enchantment. This should NOT happen any time.\n" +
|
||||
"If you are a custom anvil developer: Maybe custom anvil detected your enchantment as a bukkit enchantment. " +
|
||||
"you should maybe remove enchantment with the same key before registering yours",
|
||||
new IllegalStateException("enchantment " + enchantment.getKey() + " was already registered"));
|
||||
error);
|
||||
MetricsUtil.INSTANCE.trackError(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
|
@ -41,6 +42,7 @@ public class ConfirmActionGui extends AbstractAskGui {
|
|||
success = onConfirm.get();
|
||||
} catch (Exception e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "Could not process confirmation supplier.", e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
|
@ -264,6 +265,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
|
|||
updateGuiValues();
|
||||
} catch (Exception e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "An error occurred while updating enchants for " + this.enchantConflict, e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
}
|
||||
|
||||
// Save file configuration to disk
|
||||
|
|
@ -308,6 +310,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
|
|||
updateGuiValues();
|
||||
} catch (Exception e) {
|
||||
CustomAnvil.instance.getLogger().log(Level.WARNING, "An error occurred while updating group for " + this.enchantConflict, e);
|
||||
MetricsUtil.INSTANCE.trackError(e);
|
||||
}
|
||||
|
||||
// Save file configuration to disk
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
|||
import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker
|
||||
import xyz.alexcrea.cuanvil.update.PluginSetDefault
|
||||
import xyz.alexcrea.cuanvil.update.UpdateHandler
|
||||
import xyz.alexcrea.cuanvil.util.Metrics
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
|
|
@ -119,6 +118,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
legacyCheck()
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error trying to check for legacy system", e)
|
||||
MetricsUtil.trackError(e)
|
||||
if(trySafeStart()) return
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +127,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
prepareCommand()
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error trying to register commands", e)
|
||||
MetricsUtil.trackError(e)
|
||||
if(trySafeStart()) return
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +137,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
throw RuntimeException("Error loading configuration file")
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error occurred loading default configuration", e)
|
||||
MetricsUtil.trackError(e)
|
||||
if(tryDirtyStart()) return
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +146,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
DependencyManager.loadDependency()
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error loading dependency compatibility", e)
|
||||
MetricsUtil.trackError(e)
|
||||
if(tryDirtyStart()) return
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +155,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
registerListeners()
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error registering listeners", e)
|
||||
MetricsUtil.trackError(e)
|
||||
if(tryDirtyStart()) return
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +175,8 @@ open class CustomAnvil : JavaPlugin() {
|
|||
try {
|
||||
loadEnchantmentSystem()
|
||||
} catch (e: Exception) {
|
||||
logger.log(Level.SEVERE, "error initializing enchantment ssytem", e)
|
||||
logger.log(Level.SEVERE, "error initializing enchantment system", e)
|
||||
MetricsUtil.trackError(e)
|
||||
tryDirtyStart()
|
||||
}
|
||||
}
|
||||
|
|
@ -198,7 +203,10 @@ open class CustomAnvil : JavaPlugin() {
|
|||
|
||||
ModrinthUpdateChecker(modrinthPluginID, loader, null)
|
||||
.setFeatured(featured)
|
||||
.setOnError { logger.log(Level.WARNING, "error trying to fetch latest update", it) }
|
||||
.setOnError {
|
||||
logger.log(Level.WARNING, "error trying to fetch latest update", it)
|
||||
MetricsUtil.trackError(it)
|
||||
}
|
||||
.checkVersion { latestVer: String? ->
|
||||
CustomAnvil.latestVer = latestVer
|
||||
if(latestVer == null || version.contains(latestVer)) return@checkVersion
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
|||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
||||
import xyz.alexcrea.cuanvil.util.AnvilUseType
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||
import java.util.logging.Level
|
||||
|
||||
object DependencyManager {
|
||||
|
|
@ -141,6 +142,7 @@ object DependencyManager {
|
|||
"Error while trying to handle custom anvil supported plugin: ",
|
||||
e
|
||||
)
|
||||
trackError(e)
|
||||
|
||||
// Just in case to avoid illegal items
|
||||
event.inventory.setItem(ANVIL_OUTPUT_SLOT, null)
|
||||
|
|
@ -180,6 +182,7 @@ object DependencyManager {
|
|||
"Error while trying to handle custom anvil supported plugin: ",
|
||||
e
|
||||
)
|
||||
trackError(e)
|
||||
|
||||
// Just in case to avoid illegal items
|
||||
event.inventory.setItem(ANVIL_OUTPUT_SLOT, null)
|
||||
|
|
@ -233,6 +236,7 @@ object DependencyManager {
|
|||
"Error while trying to handle custom anvil supported plugin: ",
|
||||
e
|
||||
)
|
||||
trackError(e)
|
||||
|
||||
// Just in case to avoid illegal items
|
||||
event.inventory.setItem(ANVIL_OUTPUT_SLOT, null)
|
||||
|
|
@ -262,6 +266,7 @@ object DependencyManager {
|
|||
"Error while trying to handle custom anvil supported plugin: ",
|
||||
e
|
||||
)
|
||||
trackError(e)
|
||||
|
||||
// Just in case to avoid illegal items
|
||||
event.inventory.setItem(ANVIL_OUTPUT_SLOT, null)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.bukkit.inventory.AnvilInventory
|
|||
import org.bukkit.inventory.ItemStack
|
||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||
import xyz.alexcrea.cuanvil.util.AnvilXpUtil
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||
import java.util.logging.Level
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
|
@ -38,6 +39,7 @@ class DisenchantmentDependency {
|
|||
Level.SEVERE, "Could not initialize disenchantment support" +
|
||||
"please report this bug to the developer", e
|
||||
)
|
||||
trackError(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ object MetricsUtil {
|
|||
if(metricType.allowBStats) {
|
||||
try {
|
||||
val metric = Metrics(plugin, BSTATS_PLUGIN_ID)
|
||||
//TODO nms type custom chart
|
||||
metric.addCustomChart(Metrics.SimplePie("nms_type") { nmsType })
|
||||
metric.addCustomChart(Metrics.SimplePie("using_alpha") { isAlpha.toString() })
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue