Files
src
build.gradle
manifest.kod
Code
28 2,362
src/main/java/com/staffmonitor/StaffMonitor.java
package com.staffmonitor;
import com.staffmonitor.commands.*;
import com.staffmonitor.database.DatabaseManager;
import com.staffmonitor.listeners.*;
import com.staffmonitor.managers.*;
import com.staffmonitor.api.WebServer;
import com.staffmonitor.integrations.PunishmentIntegration;
import com.staffmonitor.integrations.LiteBansIntegration;
import com.staffmonitor.integrations.AdvancedBanIntegration;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.concurrent.TimeUnit;
@Getter
public class StaffMonitor extends JavaPlugin {
private DatabaseManager databaseManager;
private SessionManager sessionManager;
private PunishmentManager punishmentManager;
private LogManager logManager;
private ActivityManager activityManager;
private ReportManager reportManager;
private WebServer webServer;
private PunishmentIntegration punishmentIntegration;
@Override
public void onEnable() {
saveDefaultConfig();
databaseManager = new DatabaseManager(this);
databaseManager.initialize();
sessionManager = new SessionManager(this);
punishmentManager = new PunishmentManager(this);
logManager = new LogManager(this);
activityManager = new ActivityManager(this);
reportManager = new ReportManager(this);
setupPunishmentIntegration();
registerListeners();
registerCommands();
sessionManager.startTracking();
activityManager.startScheduler();
if (getConfig().getBoolean("api.enabled")) {
webServer = new WebServer(this);
getServer().getScheduler().runTaskAsynchronously(this, () -> webServer.start());
}
if (getConfig().getBoolean("discord.enabled")) {
reportManager.scheduleReports();
}
getLogger().info("StaffMonitor has been enabled successfully!");
}
@Override
public void onDisable() {
if (sessionManager != null) {
sessionManager.stopTracking();
}
if (webServer != null) {
webServer.stop();
}
if (databaseManager != null) {
databaseManager.shutdown();
}
getLogger().info("StaffMonitor has been disabled!");
}
private void setupPunishmentIntegration() {
String integration = getConfig().getString("punishments.integration", "LITEBANS");
if (integration.equalsIgnoreCase("LITEBANS") && Bukkit.getPluginManager().getPlugin("LiteBans") != null) {
punishmentIntegration = new LiteBansIntegration(this);
getLogger().info("Hooked into LiteBans for punishment tracking");
} else if (integration.equalsIgnoreCase("ADVANCEDBAN") && Bukkit.getPluginManager().getPlugin("AdvancedBan") != null) {
punishmentIntegration = new AdvancedBanIntegration(this);
getLogger().info("Hooked into AdvancedBan for punishment tracking");
} else {
getLogger().warning("No punishment plugin integration found. Manual logging only.");
}
}
private void registerListeners() {
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerQuitListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerMoveListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerChatListener(this), this);
}
private void registerCommands() {
getCommand("staffstats").setExecutor(new StaffStatsCommand(this));
getCommand("stafftop").setExecutor(new StaffTopCommand(this));
getCommand("staffreload").setExecutor(new StaffReloadCommand(this));
getCommand("stafflogs").setExecutor(new StaffLogsCommand(this));
getCommand("staffsession").setExecutor(new StaffSessionCommand(this));
}
public void reload() {
reloadConfig();
if (webServer != null && !getConfig().getBoolean("api.enabled")) {
webServer.stop();
webServer = null;
} else if (webServer == null && getConfig().getBoolean("api.enabled")) {
webServer = new WebServer(this);
getServer().getScheduler().runTaskAsynchronously(this, () -> webServer.start());
}
reportManager.cancelReports();
if (getConfig().getBoolean("discord.enabled")) {
reportManager.scheduleReports();
}
}
}