// Path: src/main/java/de/sldk/mc/MetricRegistry.java
// public class MetricRegistry {
// 
//     private static final MetricRegistry INSTANCE = new MetricRegistry();
//     
//     private final List<Metric> metrics = new ArrayList<>();
// 
//     private MetricRegistry() {
//         
//     }
//     
//     public static MetricRegistry getInstance() {
//         return INSTANCE;
//     }
//     
//     public void register(Metric metric) {
//         this.metrics.add(metric);
//     }
// 
//     void collectMetrics() {
//         this.metrics.forEach(Metric::collect);
//     }
// 
// }
// 
// Path: src/main/java/de/sldk/mc/PrometheusExporter.java
// public class PrometheusExporter extends JavaPlugin {
// 
//     private final PrometheusExporterConfig config = new PrometheusExporterConfig(this);
//     private MetricsServer server;
// 
//     @Override
//     public void onEnable() {
// 
//         config.loadDefaultsAndSave();
// 
//         config.enableConfiguredMetrics();
// 
//         startMetricsServer();
//     }
// 
//     private void startMetricsServer() {
//         String host = config.get(PrometheusExporterConfig.HOST);
//         Integer port = config.get(PrometheusExporterConfig.PORT);
// 
// 		server = new MetricsServer(host, port, this);
// 
//         try {
//             server.start();
//             getLogger().info("Started Prometheus metrics endpoint at: " + host + ":" + port);
//         } catch (Exception e) {
//             getLogger().severe("Could not start embedded Jetty server");
//         }
//     }
// 
//     @Override
//     public void onDisable() {
//         try {
//             server.stop();
//         } catch (Exception e) {
//             getLogger().log(Level.WARNING, "Failed to stop metrics server gracefully: " + e.getMessage());
//             getLogger().log(Level.FINE, "Failed to stop metrics server gracefully", e);
//         }
//     }
// 
// }


import de.sldk.mc.MetricRegistry;
import de.sldk.mc.PrometheusExporter;
import de.sldk.mc.metrics.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
package de.sldk.mc.config;



public class PrometheusExporterConfig {

    public static final PluginConfig<String> HOST = new PluginConfig<>("host", "localhost");
    public static final PluginConfig<Integer> PORT = new PluginConfig<>("port", 9225);
    public static final List<MetricConfig> METRICS = Arrays.asList(
            metricConfig("entities_total", true, Entities::new),
            metricConfig("villagers_total", true, Villagers::new),
            metricConfig("loaded_chunks_total", true, LoadedChunks::new),
            metricConfig("jvm_memory", true, Memory::new),
            metricConfig("players_online_total", true, PlayersOnlineTotal::new),
            metricConfig("players_total", true, PlayersTotal::new),
            metricConfig("tps", true, Tps::new),

            metricConfig("jvm_threads", true, ThreadsWrapper::new),
            metricConfig("jvm_gc", true, GarbageCollectorWrapper::new),

            metricConfig("tick_duration_median", true, TickDurationMedianCollector::new),
            metricConfig("tick_duration_average", true, TickDurationAverageCollector::new),
            metricConfig("tick_duration_min", false, TickDurationMinCollector::new),
            metricConfig("tick_duration_max", true, TickDurationMaxCollector::new),

            metricConfig("player_online", false, PlayerOnline::new),
            metricConfig("player_statistic", false, PlayerStatistics::new));

// Path: src/main/java/de/sldk/mc/MetricRegistry.java
// public class MetricRegistry {
// 
//     private static final MetricRegistry INSTANCE = new MetricRegistry();
//     
//     private final List<Metric> metrics = new ArrayList<>();
// 
//     private MetricRegistry() {
//         
//     }
//     
//     public static MetricRegistry getInstance() {
//         return INSTANCE;
//     }
//     
//     public void register(Metric metric) {
//         this.metrics.add(metric);
//     }
// 
//     void collectMetrics() {
//         this.metrics.forEach(Metric::collect);
//     }
// 
// }
// 
// Path: src/main/java/de/sldk/mc/PrometheusExporter.java
// public class PrometheusExporter extends JavaPlugin {
// 
//     private final PrometheusExporterConfig config = new PrometheusExporterConfig(this);
//     private MetricsServer server;
// 
//     @Override
//     public void onEnable() {
// 
//         config.loadDefaultsAndSave();
// 
//         config.enableConfiguredMetrics();
// 
//         startMetricsServer();
//     }
// 
//     private void startMetricsServer() {
//         String host = config.get(PrometheusExporterConfig.HOST);
//         Integer port = config.get(PrometheusExporterConfig.PORT);
// 
// 		server = new MetricsServer(host, port, this);
// 
//         try {
//             server.start();
//             getLogger().info("Started Prometheus metrics endpoint at: " + host + ":" + port);
//         } catch (Exception e) {
//             getLogger().severe("Could not start embedded Jetty server");
//         }
//     }
// 
//     @Override
//     public void onDisable() {
//         try {
//             server.stop();
//         } catch (Exception e) {
//             getLogger().log(Level.WARNING, "Failed to stop metrics server gracefully: " + e.getMessage());
//             getLogger().log(Level.FINE, "Failed to stop metrics server gracefully", e);
//         }
//     }
// 
// }


// Path: src/main/java/de/sldk/mc/config/PrometheusExporterConfig.java
import de.sldk.mc.MetricRegistry;
import de.sldk.mc.PrometheusExporter;
import de.sldk.mc.metrics.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

package de.sldk.mc.config;



public class PrometheusExporterConfig {

    public static final PluginConfig<String> HOST = new PluginConfig<>("host", "localhost");
    public static final PluginConfig<Integer> PORT = new PluginConfig<>("port", 9225);
    public static final List<MetricConfig> METRICS = Arrays.asList(
            metricConfig("entities_total", true, Entities::new),
            metricConfig("villagers_total", true, Villagers::new),
            metricConfig("loaded_chunks_total", true, LoadedChunks::new),
            metricConfig("jvm_memory", true, Memory::new),
            metricConfig("players_online_total", true, PlayersOnlineTotal::new),
            metricConfig("players_total", true, PlayersTotal::new),
            metricConfig("tps", true, Tps::new),

            metricConfig("jvm_threads", true, ThreadsWrapper::new),
            metricConfig("jvm_gc", true, GarbageCollectorWrapper::new),

            metricConfig("tick_duration_median", true, TickDurationMedianCollector::new),
            metricConfig("tick_duration_average", true, TickDurationAverageCollector::new),
            metricConfig("tick_duration_min", false, TickDurationMinCollector::new),
            metricConfig("tick_duration_max", true, TickDurationMaxCollector::new),

            metricConfig("player_online", false, PlayerOnline::new),
            metricConfig("player_statistic", false, PlayerStatistics::new));

    private final PrometheusExporter prometheusExporter;