mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
common, fancynpcs, fancyholograms-v2, fancyholograms-v3, ci: Add channel and platform to version config
This commit is contained in:
@@ -28,6 +28,9 @@ jobs:
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Build FancyNpcs
|
||||
env:
|
||||
RELEASE_CHANNEL: 'snapshot'
|
||||
RELEASE_PLATFORM: 'modrinth'
|
||||
run: ./gradlew :plugins:fancynpcs:shadowJar
|
||||
|
||||
- name: Build deployment tool
|
||||
|
||||
@@ -12,8 +12,9 @@ public class VersionConfig {
|
||||
private final Plugin plugin;
|
||||
private final VersionFetcher fetcher;
|
||||
private String version;
|
||||
private String build;
|
||||
private String hash;
|
||||
private String commitHash;
|
||||
private String channel;
|
||||
private String platform;
|
||||
|
||||
public VersionConfig(Plugin plugin, VersionFetcher fetcher) {
|
||||
this.plugin = plugin;
|
||||
@@ -29,8 +30,13 @@ public class VersionConfig {
|
||||
}
|
||||
|
||||
version = config.getString("version", "undefined");
|
||||
build = config.getString("build", "undefined");
|
||||
hash = config.getString("hash", "undefined");
|
||||
commitHash = config.getString("commit_hash", "undefined");
|
||||
channel = config.getString("channel", "undefined");
|
||||
platform = config.getString("platform", "undefined");
|
||||
}
|
||||
|
||||
public boolean isDevelopmentBuild() {
|
||||
return !channel.equalsIgnoreCase("release");
|
||||
}
|
||||
|
||||
public void checkVersionAndDisplay(CommandSender sender, boolean displayOnlyIfOutdated) {
|
||||
@@ -70,13 +76,11 @@ public class VersionConfig {
|
||||
|
||||
private String latestVersion() {
|
||||
String result = "This server is using the latest version of {plugin}!\n" +
|
||||
"Version: {version} (Git: {hash})" +
|
||||
"{build}";
|
||||
"Version: {version} (Git: {hash})";
|
||||
|
||||
result = result.replace("{plugin}", plugin.getName())
|
||||
.replace("{version}", version)
|
||||
.replace("{hash}", hash.substring(0, 7))
|
||||
.replace("{build}", build.equalsIgnoreCase("undefined") ? "" : "\nBuild: " + build);
|
||||
.replace("{hash}", commitHash.substring(0, 7));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -99,11 +103,15 @@ public class VersionConfig {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getBuild() {
|
||||
return build;
|
||||
public String getCommitHash() {
|
||||
return commitHash;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,9 @@ tasks {
|
||||
val props = mapOf(
|
||||
"description" to project.description,
|
||||
"version" to getFHVersion(),
|
||||
"hash" to gitCommitHash.get(),
|
||||
"build" to (System.getenv("BUILD_ID") ?: "").ifEmpty { "undefined" }
|
||||
"commit_hash" to gitCommitHash.get(),
|
||||
"channel" to (System.getenv("RELEASE_CHANNEL") ?: "").ifEmpty { "undefined" },
|
||||
"platform" to (System.getenv("RELEASE_PLATFORM") ?: "").ifEmpty { "undefined" }
|
||||
)
|
||||
|
||||
inputs.properties(props)
|
||||
|
||||
@@ -319,17 +319,15 @@ public final class FancyHolograms extends JavaPlugin implements FancyHologramsPl
|
||||
}
|
||||
|
||||
private void registerMetrics() {
|
||||
boolean isDevelopmentBuild = !versionConfig.getBuild().equalsIgnoreCase("undefined");
|
||||
|
||||
Metrics metrics = new Metrics(this, 17990);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("total_holograms", () -> hologramsManager.getHolograms().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("update_notifications", () -> configuration.areVersionNotificationsEnabled() ? "Yes" : "No"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_development_build", () -> isDevelopmentBuild ? "Yes" : "No"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_development_build", () -> versionConfig.isDevelopmentBuild() ? "Yes" : "No"));
|
||||
|
||||
fancyAnalytics = new FancyAnalyticsAPI("3b77bd59-2b01-46f2-b3aa-a9584401797f", "E2gW5zc2ZTk1OGFkNGY2ZDQ0ODlM6San");
|
||||
fancyAnalytics.getConfig().setDisableLogging(true);
|
||||
|
||||
if (!isDevelopmentBuild) {
|
||||
if (!versionConfig.isDevelopmentBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,7 +336,7 @@ public final class FancyHolograms extends JavaPlugin implements FancyHologramsPl
|
||||
fancyAnalytics.getExceptionHandler().registerLogger(Bukkit.getLogger());
|
||||
fancyAnalytics.getExceptionHandler().registerLogger(fancyLogger);
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> versionConfig.getHash().substring(0, 7)));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> versionConfig.getCommitHash().substring(0, 7)));
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("server_size", () -> {
|
||||
long onlinePlayers = Bukkit.getOnlinePlayers().size();
|
||||
@@ -365,7 +363,7 @@ public final class FancyHolograms extends JavaPlugin implements FancyHologramsPl
|
||||
fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_holograms", () -> (double) hologramsManager.getHolograms().size()));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("enabled_update_notifications", () -> configuration.areVersionNotificationsEnabled() ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("fflag_disable_holograms_for_bedrock_players", () -> FHFeatureFlags.DISABLE_HOLOGRAMS_FOR_BEDROCK_PLAYERS.isEnabled() ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("using_development_build", () -> isDevelopmentBuild ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("using_development_build", () -> versionConfig.isDevelopmentBuild() ? "true" : "false"));
|
||||
|
||||
fancyAnalytics.registerStringArrayMetric(new MetricSupplier<>("hologram_type", () -> {
|
||||
if (hologramsManager == null) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
version: $version
|
||||
build: $build
|
||||
hash: $hash
|
||||
commit_hash: $commit_hash
|
||||
platform: $platform
|
||||
channel: $channel
|
||||
@@ -150,7 +150,9 @@ tasks {
|
||||
val props = mapOf(
|
||||
"description" to project.description,
|
||||
"version" to getFHVersion(),
|
||||
"hash" to getCurrentCommitHash(),
|
||||
"commit_hash" to getCurrentCommitHash(),
|
||||
"channel" to (System.getenv("RELEASE_CHANNEL") ?: "").ifEmpty { "undefined" },
|
||||
"platform" to (System.getenv("RELEASE_PLATFORM") ?: "").ifEmpty { "undefined" }
|
||||
)
|
||||
|
||||
inputs.properties(props)
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FHMetrics {
|
||||
|
||||
HologramRegistry registry = FancyHologramsPlugin.get().getRegistry();
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> FancyHologramsPlugin.get().getVersionConfig().getHash().substring(0, 7)));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> FancyHologramsPlugin.get().getVersionConfig().getCommitHash().substring(0, 7)));
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("server_size", () -> {
|
||||
long onlinePlayers = Bukkit.getOnlinePlayers().size();
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
version: $version
|
||||
hash: $hash
|
||||
commit_hash: $commit_hash
|
||||
platform: $platform
|
||||
channel: $channel
|
||||
@@ -178,8 +178,9 @@ tasks {
|
||||
val props = mapOf(
|
||||
"description" to project.description,
|
||||
"version" to getFNVersion(),
|
||||
"hash" to gitCommitHash.get(),
|
||||
"build" to (System.getenv("BUILD_ID") ?: "").ifEmpty { "undefined" }
|
||||
"commit_hash" to gitCommitHash.get(),
|
||||
"channel" to (System.getenv("RELEASE_CHANNEL") ?: "").ifEmpty { "undefined" },
|
||||
"platform" to (System.getenv("RELEASE_PLATFORM") ?: "").ifEmpty { "undefined" }
|
||||
)
|
||||
|
||||
inputs.properties(props)
|
||||
|
||||
@@ -353,19 +353,17 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
|
||||
}
|
||||
|
||||
private void registerMetrics() {
|
||||
boolean isDevelopmentBuild = !versionConfig.getBuild().equalsIgnoreCase("undefined");
|
||||
|
||||
Metrics metrics = new Metrics(this, 17543);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("total_npcs", () -> npcManager.getAllNpcs().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("update_notifications", () -> config.isMuteVersionNotification() ? "No" : "Yes"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_development_build", () -> isDevelopmentBuild ? "Yes" : "No"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_development_build", () -> versionConfig.isDevelopmentBuild() ? "Yes" : "No"));
|
||||
|
||||
fancyAnalytics.registerMinecraftPluginMetrics(instance);
|
||||
fancyAnalytics.getExceptionHandler().registerLogger(getLogger());
|
||||
fancyAnalytics.getExceptionHandler().registerLogger(Bukkit.getLogger());
|
||||
fancyAnalytics.getExceptionHandler().registerLogger(fancyLogger);
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> versionConfig.getHash().substring(0, 7)));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> versionConfig.getCommitHash().substring(0, 7)));
|
||||
|
||||
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("server_size", () -> {
|
||||
@@ -393,7 +391,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
|
||||
fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_npcs", () -> (double) npcManager.getAllNpcs().size()));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("enabled_update_notifications", () -> config.isMuteVersionNotification() ? "false" : "true"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("enabled_player_npcs_fflag", () -> PLAYER_NPCS_FEATURE_FLAG.isEnabled() ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("using_development_build", () -> isDevelopmentBuild ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("using_development_build", () -> versionConfig.isDevelopmentBuild() ? "true" : "false"));
|
||||
fancyAnalytics.registerStringMetric(new MetricSupplier<>("language", () -> translator.getSelectedLanguage().getLanguageCode()));
|
||||
|
||||
fancyAnalytics.registerNumberMetric(new MetricSupplier<>("avg_interaction_cooldown", () -> {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
version: $version
|
||||
build: $build
|
||||
hash: $hash
|
||||
commit_hash: $commit_hash
|
||||
platform: $platform
|
||||
channel: $channel
|
||||
Reference in New Issue
Block a user