mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Re-implement Metrics with custom pie charts
This commit is contained in:
1 parent
9296a68637
commit
e5bca1dad0
3 files changed
+56
-11
No files matched your search
@@ -36,6 +36,7 @@ import net.william278.huskhomes.request.RequestManager;
|
||||
import net.william278.huskhomes.teleport.TeleportManager;
|
||||
import net.william278.huskhomes.util.*;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@@ -246,11 +247,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
//todo EssentialsX
|
||||
|
||||
// Hook into bStats metrics
|
||||
try {
|
||||
new Metrics(this, METRICS_ID);
|
||||
} catch (final Exception e) {
|
||||
getLoggingAdapter().log(Level.WARNING, "Skipped bStats metrics initialization.");
|
||||
}
|
||||
registerMetrics(METRICS_ID);
|
||||
|
||||
// Check for updates
|
||||
if (settings.checkForUpdates) {
|
||||
@@ -505,6 +502,26 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetrics(int metricsId) {
|
||||
try {
|
||||
final Metrics metrics = new Metrics(this, metricsId);
|
||||
metrics.addCustomChart(new SimplePie("bungee_mode", () -> Boolean.toString(getSettings().crossServer)));
|
||||
if (getSettings().crossServer) {
|
||||
metrics.addCustomChart(new SimplePie("messenger_type", () -> getSettings().messengerType.displayName));
|
||||
}
|
||||
metrics.addCustomChart(new SimplePie("language", () -> getSettings().language.toLowerCase()));
|
||||
metrics.addCustomChart(new SimplePie("database_type", () -> getSettings().databaseType.displayName));
|
||||
metrics.addCustomChart(new SimplePie("using_economy", () -> Boolean.toString(getSettings().economy)));
|
||||
metrics.addCustomChart(new SimplePie("using_map", () -> Boolean.toString(getSettings().doMapHook)));
|
||||
if (getSettings().doMapHook) {
|
||||
metrics.addCustomChart(new SimplePie("map_type", () -> getSettings().mappingPlugin.displayName));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLoggingAdapter().log(Level.WARNING, "Failed to register metrics", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Default constructor
|
||||
@SuppressWarnings("unused")
|
||||
public BukkitHuskHomes() {
|
||||
|
||||
@@ -337,4 +337,11 @@ public interface HuskHomes {
|
||||
*/
|
||||
CompletableFuture<Boolean> reload();
|
||||
|
||||
/**
|
||||
* Registers the plugin with bStats metrics
|
||||
*
|
||||
* @param metricsId the bStats id for the plugin
|
||||
*/
|
||||
void registerMetrics(int metricsId);
|
||||
|
||||
}
|
||||
@@ -321,24 +321,45 @@ public class Settings {
|
||||
* Identifies types of databases
|
||||
*/
|
||||
public enum DatabaseType {
|
||||
MYSQL,
|
||||
SQLITE
|
||||
MYSQL("MySQL"),
|
||||
SQLITE("SQLite");
|
||||
|
||||
@NotNull
|
||||
public final String displayName;
|
||||
|
||||
DatabaseType(@NotNull String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies types of network messenger
|
||||
*/
|
||||
public enum MessengerType {
|
||||
PLUGIN_MESSAGE,
|
||||
REDIS
|
||||
PLUGIN_MESSAGE("Plugin Messages"),
|
||||
REDIS("Redis");
|
||||
|
||||
@NotNull
|
||||
public final String displayName;
|
||||
|
||||
MessengerType(@NotNull String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies types of supported Map plugins
|
||||
*/
|
||||
public enum MappingPlugin {
|
||||
DYNMAP,
|
||||
BLUEMAP
|
||||
DYNMAP("Dynmap"),
|
||||
BLUEMAP("BlueMap");
|
||||
|
||||
@NotNull
|
||||
public final String displayName;
|
||||
|
||||
MappingPlugin(@NotNull String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user