Skip to content

Commit

Permalink
compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Dec 27, 2024
1 parent 87f9197 commit a19d95a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src/main/java/de/oliver/fancyholograms/metrics/FHMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.oliver.fancyanalytics.api.FancyAnalyticsAPI;
import de.oliver.fancyanalytics.api.metrics.MetricSupplier;
import de.oliver.fancyanalytics.logger.ExtendedFancyLogger;
import de.oliver.fancyholograms.api.HologramRegistry;
import de.oliver.fancyholograms.config.FHFeatureFlags;
import de.oliver.fancyholograms.main.FancyHologramsPlugin;
import de.oliver.fancylib.Metrics;
Expand All @@ -29,7 +30,7 @@ public void register() {
fancyAnalytics.getExceptionHandler().registerLogger(Bukkit.getLogger());
fancyAnalytics.getExceptionHandler().registerLogger(logger);

HologramManager manager = FancyHologramsPlugin.get().getHologramManager();
HologramRegistry registry = FancyHologramsPlugin.get().getRegistry();

fancyAnalytics.registerStringMetric(new MetricSupplier<>("commit_hash", () -> FancyHologramsPlugin.get().getVersionConfig().getHash().substring(0, 7)));

Expand All @@ -55,17 +56,17 @@ public void register() {
return "very_large";
}));

fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_holograms", () -> (double) manager.getHolograms().size()));
fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_holograms", () -> (double) registry.getAll().size()));
fancyAnalytics.registerStringMetric(new MetricSupplier<>("enabled_update_notifications", () -> FancyHologramsPlugin.get().getFHConfiguration().areVersionNotificationsMuted() ? "false" : "true"));
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.registerStringArrayMetric(new MetricSupplier<>("hologram_type", () -> {
if (manager == null) {
if (registry == null) {
return new String[0];
}

return manager.getHolograms().stream()
return registry.getAll().stream()
.map(h -> h.getData().getType().name())
.toArray(String[]::new);
}));
Expand All @@ -76,7 +77,7 @@ public void register() {

public void registerLegacy() {
Metrics metrics = new Metrics(FancyHologramsPlugin.get(), 17990);
metrics.addCustomChart(new Metrics.SingleLineChart("total_holograms", () -> FancyHologramsPlugin.get().getHologramManager().getHolograms().size()));
metrics.addCustomChart(new Metrics.SingleLineChart("total_holograms", () -> FancyHologramsPlugin.get().getRegistry().getAll().size()));
metrics.addCustomChart(new Metrics.SimplePie("update_notifications", () -> FancyHologramsPlugin.get().getFHConfiguration().areVersionNotificationsMuted() ? "No" : "Yes"));
metrics.addCustomChart(new Metrics.SimplePie("using_development_build", () -> isDevelopmentBuild ? "Yes" : "No"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public void saveBatch(Collection<HologramData> holograms) {
@Override
public void save(HologramData hologram) {
try {
jdb.set("worlds/" + hologram.getLocation().getWorld().getName() + "/" + hologram.getType() + "/" + hologram.getData().getName(), hologram);
jdb.set("worlds/" + hologram.getLocation().getWorld().getName() + "/" + hologram.getType() + "/" + hologram.getName(), hologram);
} catch (IOException e) {
FancyHolograms.get().getFancyLogger().error("Failed to save hologram " + hologram.getData().getName());
FancyHolograms.get().getFancyLogger().error("Failed to save hologram " + hologram.getName());
FancyHolograms.get().getFancyLogger().error(e);
}
}

@Override
public void delete(HologramData hologram) {
jdb.delete("worlds/" + hologram.getLocation().getWorld().getName() + "/" + hologram.getData().getName());
jdb.delete("worlds/" + hologram.getLocation().getWorld().getName() + "/" + hologram.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void save(HologramData hologram) {
}
}

FancyHologramsPlugin.get().getFancyLogger().debug("Saved hologram " + hologram.getData().getName() + " to file");
FancyHologramsPlugin.get().getFancyLogger().debug("Saved hologram " + hologram.getName() + " to file");
}

public void delete(HologramData hologram) {
Expand All @@ -73,7 +73,7 @@ public void delete(HologramData hologram) {
YamlConfiguration config = null;
try {
config = YamlConfiguration.loadConfiguration(HOLOGRAMS_CONFIG_FILE);
config.set("holograms." + hologram.getData().getName(), null);
config.set("holograms." + hologram.getName(), null);

success = true;
} finally {
Expand All @@ -83,7 +83,7 @@ public void delete(HologramData hologram) {
}
}

FancyHologramsPlugin.get().getFancyLogger().debug("Deleted hologram " + hologram.getData().getName() + " from file");
FancyHologramsPlugin.get().getFancyLogger().debug("Deleted hologram " + hologram.getName() + " from file");
}

public Collection<HologramData> loadAll() {
Expand Down Expand Up @@ -174,7 +174,7 @@ private void writeHologram(YamlConfiguration config, HologramData hologram) {
section = Objects.requireNonNull(config.getConfigurationSection("holograms"));
}

String holoName = hologram.getData().getName();
String holoName = hologram.getName();

ConfigurationSection holoSection = section.getConfigurationSection(holoName);
if (holoSection == null) {
Expand Down

0 comments on commit a19d95a

Please sign in to comment.