NametagEdit DEV

NametagEdit DEV

10.5k Downloads

Do not create new Metrics instances on every reload

Bastian opened this issue ยท 0 comments

commented

Bug Report

I've noticed the following log messages on my bStats backend:
image

I've taken a look at your code and currently you create a new Metrics instance on every config reload:

public void reload() {
config.reload(true);
applyConfig();
nametagManager.reset();
abstractConfig.reload();
}
private void applyConfig() {
this.debug = config.getBoolean("Debug");
this.tabListEnabled = config.getBoolean("Tablist.Enabled");
this.longNametagsEnabled = config.getBoolean("Tablist.LongTags");
this.refreshTagOnWorldChange = config.getBoolean("RefreshTagOnWorldChange");
DISABLE_PUSH_ALL_TAGS = config.getBoolean("DisablePush");
if (config.getBoolean("MetricsEnabled")) {
Metrics m = new Metrics(NametagEdit.getPlugin(NametagEdit.class));
m.addCustomChart(new Metrics.SimplePie("using_spigot", () -> PlaceholderAPIPlugin.getServerVersion().isSpigot() ? "yes" : "no"));
}

Once loaded, you cannot unload bStats. When you are creating more then one instance, you just send your data twice.

It's not urgent, but I would appreciate if you could change your code to just create a Metrics instance once :-)