mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Add fancyanalytics integration
This commit is contained in:
@@ -2,13 +2,6 @@ Commit hash: %COMMIT_HASH%
|
||||
|
||||
Commit message: %COMMIT_MESSAGE%
|
||||
|
||||
Changes:
|
||||
- Removed close action
|
||||
- Added console_command, player_command and send_to_server actions
|
||||
- Made dialog registry and action registry accessible from the API
|
||||
- Added confirmation dialogs to certain commands
|
||||
- Removed html encoding for default dialogs
|
||||
|
||||
*(The last commit message does not always directly reflect the changes related to this version.)*
|
||||
|
||||
Keep in mind that this is a snapshot version. Snapshot versions are **not** meant to be used in production. They are for **testing purposes only** and may contain bugs or incomplete features. Use at your own risk.
|
||||
@@ -1 +1 @@
|
||||
0.0.3
|
||||
0.0.4
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.fancyinnovations.fancydialogs;
|
||||
|
||||
import com.fancyinnovations.fancydialogs.actions.ActionRegistryImpl;
|
||||
import com.fancyinnovations.fancydialogs.analytics.Analytics;
|
||||
import com.fancyinnovations.fancydialogs.api.Dialog;
|
||||
import com.fancyinnovations.fancydialogs.api.DialogActionRegistry;
|
||||
import com.fancyinnovations.fancydialogs.api.FancyDialogs;
|
||||
@@ -153,6 +154,10 @@ public class FancyDialogsPlugin extends JavaPlugin implements FancyDialogs {
|
||||
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
Analytics analytics = new Analytics();
|
||||
analytics.registerMetrics();
|
||||
analytics.start();
|
||||
|
||||
fancyLogger.info("Successfully enabled FancyDialogs version %s".formatted(getDescription().getVersion()));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.fancyinnovations.fancydialogs.analytics;
|
||||
|
||||
import com.fancyinnovations.fancydialogs.FancyDialogsPlugin;
|
||||
import de.oliver.fancyanalytics.api.FancyAnalyticsAPI;
|
||||
import de.oliver.fancyanalytics.api.metrics.MetricSupplier;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class Analytics {
|
||||
|
||||
private final FancyAnalyticsAPI api;
|
||||
|
||||
public Analytics() {
|
||||
api = new FancyAnalyticsAPI("ebed5533-b25e-44b3-894c-6898f64f5033", "2DNDnGE0NmQwYWE5ZTYzMDQzYTZJNoFa");
|
||||
api.getConfig().setDisableLogging(true);
|
||||
}
|
||||
|
||||
public void registerMetrics() {
|
||||
api.registerMinecraftPluginMetrics(FancyDialogsPlugin.get());
|
||||
api.getExceptionHandler().registerLogger(FancyDialogsPlugin.get().getLogger());
|
||||
api.getExceptionHandler().registerLogger(Bukkit.getLogger());
|
||||
api.getExceptionHandler().registerLogger(FancyDialogsPlugin.get().getFancyLogger());
|
||||
|
||||
api.registerStringMetric(new MetricSupplier<>("server_size", () -> {
|
||||
long onlinePlayers = Bukkit.getOnlinePlayers().size();
|
||||
|
||||
if (onlinePlayers == 0) {
|
||||
return "empty";
|
||||
}
|
||||
|
||||
if (onlinePlayers <= 25) {
|
||||
return "small";
|
||||
}
|
||||
|
||||
if (onlinePlayers <= 100) {
|
||||
return "medium";
|
||||
}
|
||||
|
||||
if (onlinePlayers <= 500) {
|
||||
return "large";
|
||||
}
|
||||
|
||||
return "very_large";
|
||||
}));
|
||||
|
||||
api.registerNumberMetric(new MetricSupplier<>("amount_dialogs", () -> (double) FancyDialogsPlugin.get().getDialogRegistry().getAll().size()));
|
||||
}
|
||||
|
||||
public void start() {
|
||||
api.initialize();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user