Files
src
build.gradle
manifest.kod
settings.gradle
Code
28 1,329
src/main/java/com/serverpulse/ServerPulse.java
package com.serverpulse;
import com.serverpulse.alerts.AlertManager;
import com.serverpulse.analysis.PerformanceAnalyzer;
import com.serverpulse.chunks.ChunkAnalyzer;
import com.serverpulse.command.ServerPulseCommand;
import com.serverpulse.config.ServerPulseConfig;
import com.serverpulse.database.HistoricalDataRepository;
import com.serverpulse.database.JdbcStorageProvider;
import com.serverpulse.entities.EntityAnalyzer;
import com.serverpulse.entities.MobAIAnalyzer;
import com.serverpulse.hoppers.HopperAnalyzer;
import com.serverpulse.incidents.IncidentManager;
import com.serverpulse.metrics.MetricsCollector;
import com.serverpulse.monitoring.TickMonitor;
import com.serverpulse.profiling.PluginPerformanceAnalyzer;
import com.serverpulse.redstone.RedstoneAnalyzer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class ServerPulse extends JavaPlugin {
private ServerPulseConfig config;
private HistoricalDataRepository repository;
private TickMonitor tickMonitor;
private ChunkAnalyzer chunkAnalyzer;
private EntityAnalyzer entities;
private IncidentManager incidents;
private MetricsCollector metrics;
private PluginPerformanceAnalyzer pluginPerformance;
@Override public void onEnable() {
config = new ServerPulseConfig(this);
repository = new HistoricalDataRepository(new JdbcStorageProvider(this, config));
repository.start();
tickMonitor = new TickMonitor(this);
chunkAnalyzer = new ChunkAnalyzer();
entities = new EntityAnalyzer(this, config.entityAnalysisSeconds(), config.maxChunksPerAnalysis(), config.entityChunksPerTick(), chunkAnalyzer);
HopperAnalyzer hopperAnalyzer = new HopperAnalyzer();
PerformanceAnalyzer analyzer = new PerformanceAnalyzer(config, chunkAnalyzer, hopperAnalyzer, new RedstoneAnalyzer(), new MobAIAnalyzer());
incidents = new IncidentManager(repository, config);
AlertManager alerts = new AlertManager(config);
metrics = new MetricsCollector(this, config, tickMonitor, entities, analyzer, incidents, alerts, repository);
pluginPerformance = new PluginPerformanceAnalyzer();
tickMonitor.start();
entities.start();
metrics.start();
ServerPulseCommand command = new ServerPulseCommand(this);
if (getCommand("serverpulse") != null) {
getCommand("serverpulse").setExecutor(command);
getCommand("serverpulse").setTabCompleter(command);
}
getLogger().info("ServerPulse enabled in diagnostic-only mode.");
}
@Override public void onDisable() {
if (metrics != null) metrics.stop();
if (entities != null) entities.stop();
if (tickMonitor != null) tickMonitor.stop();
if (repository != null) repository.stop();
}
public void reloadPluginConfig() {
config.reload();
}
public ServerPulseConfig config() { return config; }
public HistoricalDataRepository repository() { return repository; }
public EntityAnalyzer entities() { return entities; }
public ChunkAnalyzer chunkAnalyzer() { return chunkAnalyzer; }
public IncidentManager incidents() { return incidents; }
public MetricsCollector metrics() { return metrics; }
public PluginPerformanceAnalyzer pluginPerformance() { return pluginPerformance; }
}