Files
src
build.gradle
manifest.kod
Code
34 2,907
src/main/java/com/example/altdetector/AltDetector.java
package com.example.altdetector;
import com.example.altdetector.alert.AlertManager;
import com.example.altdetector.cache.CacheManager;
import com.example.altdetector.command.*;
import com.example.altdetector.config.ConfigManager;
import com.example.altdetector.database.DatabaseManager;
import com.example.altdetector.detection.DetectionManager;
import com.example.altdetector.inventory.gui.GUIListener;
import com.example.altdetector.inventory.gui.GUIManager;
import com.example.altdetector.listener.PlayerJoinListener;
import com.example.altdetector.listener.PlayerQuitListener;
import com.example.altdetector.punishment.PunishmentManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class AltDetector extends JavaPlugin {
private ConfigManager configManager;
private DatabaseManager databaseManager;
private CacheManager cacheManager;
private DetectionManager detectionManager;
private PunishmentManager punishmentManager;
private AlertManager alertManager;
private GUIManager guiManager;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.configManager.loadConfig();
this.cacheManager = new CacheManager(this);
this.databaseManager = new DatabaseManager(this);
this.databaseManager.initialize().thenRun(() -> {
this.getLogger().info("Database initialized successfully");
}).exceptionally(ex -> {
this.getLogger().severe("Failed to initialize database: " + ex.getMessage());
this.getServer().getPluginManager().disablePlugin(this);
return null;
});
this.detectionManager = new DetectionManager(this);
this.punishmentManager = new PunishmentManager(this);
this.alertManager = new AlertManager(this);
this.guiManager = new GUIManager();
this.registerCommands();
this.registerListeners();
this.getLogger().info("AltDetector v" + this.getDescription().getVersion() + " enabled!");
}
@Override
public void onDisable() {
if (this.databaseManager != null) {
this.databaseManager.shutdown();
}
if (this.cacheManager != null) {
this.cacheManager.clear();
}
this.getLogger().info("AltDetector disabled!");
}
private void registerCommands() {
this.getCommand("altcheck").setExecutor(new AltCheckCommand(this));
this.getCommand("altreload").setExecutor(new AltReloadCommand(this));
this.getCommand("altstats").setExecutor(new AltStatsCommand(this));
this.getCommand("altlink").setExecutor(new AltLinkCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerQuitListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
}
}