mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 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.teleport.TeleportManager;
|
||||||
import net.william278.huskhomes.util.*;
|
import net.william278.huskhomes.util.*;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
@@ -246,11 +247,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
//todo EssentialsX
|
//todo EssentialsX
|
||||||
|
|
||||||
// Hook into bStats metrics
|
// Hook into bStats metrics
|
||||||
try {
|
registerMetrics(METRICS_ID);
|
||||||
new Metrics(this, METRICS_ID);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
getLoggingAdapter().log(Level.WARNING, "Skipped bStats metrics initialization.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
if (settings.checkForUpdates) {
|
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
|
// Default constructor
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public BukkitHuskHomes() {
|
public BukkitHuskHomes() {
|
||||||
|
|||||||
@@ -337,4 +337,11 @@ public interface HuskHomes {
|
|||||||
*/
|
*/
|
||||||
CompletableFuture<Boolean> reload();
|
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
|
* Identifies types of databases
|
||||||
*/
|
*/
|
||||||
public enum DatabaseType {
|
public enum DatabaseType {
|
||||||
MYSQL,
|
MYSQL("MySQL"),
|
||||||
SQLITE
|
SQLITE("SQLite");
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final String displayName;
|
||||||
|
|
||||||
|
DatabaseType(@NotNull String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies types of network messenger
|
* Identifies types of network messenger
|
||||||
*/
|
*/
|
||||||
public enum MessengerType {
|
public enum MessengerType {
|
||||||
PLUGIN_MESSAGE,
|
PLUGIN_MESSAGE("Plugin Messages"),
|
||||||
REDIS
|
REDIS("Redis");
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final String displayName;
|
||||||
|
|
||||||
|
MessengerType(@NotNull String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies types of supported Map plugins
|
* Identifies types of supported Map plugins
|
||||||
*/
|
*/
|
||||||
public enum MappingPlugin {
|
public enum MappingPlugin {
|
||||||
DYNMAP,
|
DYNMAP("Dynmap"),
|
||||||
BLUEMAP
|
BLUEMAP("BlueMap");
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final String displayName;
|
||||||
|
|
||||||
|
MappingPlugin(@NotNull String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user