Files
src
build.gradle
IMPORTANT.txt
Code
25 2,130
src/main/java/com/unstablesmp/UnstableSMP.java
package com.unstablesmp;
import com.unstablesmp.commands.AdminCommand;
import com.unstablesmp.commands.ElectionCommand;
import com.unstablesmp.commands.KingCommand;
import com.unstablesmp.integrations.GriefPreventionIntegration;
import com.unstablesmp.integrations.LuckPermsIntegration;
import com.unstablesmp.integrations.PlaceholderIntegration;
import com.unstablesmp.listeners.OutlawDeathListener;
import com.unstablesmp.managers.*;
import com.unstablesmp.tasks.ElectionScheduler;
import com.unstablesmp.tasks.OutlawExpiryTask;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class UnstableSMP extends JavaPlugin {
private DataManager dataManager;
private ElectionManager electionManager;
private KingManager kingManager;
private OutlawManager outlawManager;
private RewardManager rewardManager;
private IntegrationManager integrationManager;
private LuckPermsIntegration luckPermsIntegration;
private GriefPreventionIntegration griefPreventionIntegration;
private PlaceholderIntegration placeholderIntegration;
private ElectionScheduler electionScheduler;
private OutlawExpiryTask outlawExpiryTask;
@Override
public void onEnable() {
saveDefaultConfig();
initializeManagers();
initializeIntegrations();
initializeTasks();
registerCommands();
registerListeners();
getLogger().info("UnstableSMP has been enabled!");
}
@Override
public void onDisable() {
if (electionScheduler != null) {
electionScheduler.cancel();
}
if (outlawExpiryTask != null) {
outlawExpiryTask.cancel();
}
if (dataManager != null) {
dataManager.saveAll();
}
getLogger().info("UnstableSMP has been disabled!");
}
private void initializeManagers() {
this.dataManager = new DataManager(this);
this.electionManager = new ElectionManager(this);
this.kingManager = new KingManager(this);
this.outlawManager = new OutlawManager(this);
this.rewardManager = new RewardManager(this);
this.integrationManager = new IntegrationManager(this);
dataManager.loadAll();
}
private void initializeIntegrations() {
this.luckPermsIntegration = new LuckPermsIntegration(this);
this.griefPreventionIntegration = new GriefPreventionIntegration(this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
this.placeholderIntegration = new PlaceholderIntegration(this);
placeholderIntegration.register();
getLogger().info("PlaceholderAPI integration enabled!");
}
}
private void initializeTasks() {
this.electionScheduler = new ElectionScheduler(this);
this.outlawExpiryTask = new OutlawExpiryTask(this);
electionScheduler.start();
outlawExpiryTask.start();
}
private void registerCommands() {
ElectionCommand electionCommand = new ElectionCommand(this);
getCommand("election").setExecutor(electionCommand);
getCommand("nominate").setExecutor(electionCommand);
getCommand("vote").setExecutor(electionCommand);
KingCommand kingCommand = new KingCommand(this);
getCommand("king").setExecutor(kingCommand);
getCommand("kingappoint").setExecutor(kingCommand);
getCommand("kingdismiss").setExecutor(kingCommand);
getCommand("kingoutlaw").setExecutor(kingCommand);
getCommand("kinginfo").setExecutor(kingCommand);
AdminCommand adminCommand = new AdminCommand(this);
getCommand("listoutlaws").setExecutor(adminCommand);
getCommand("listguards").setExecutor(adminCommand);
getCommand("revert-claim-backup").setExecutor(adminCommand);
getCommand("unstablesmp").setExecutor(adminCommand);
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new OutlawDeathListener(this), this);
}
public void reload() {
reloadConfig();
dataManager.loadAll();
getLogger().info("Configuration and data reloaded!");
}
}