Files
src
build.gradle
SETUP_GUIDE.md
Code
27 2,593
src/main/java/com/thronesmp/ThroneSMP.java
package com.thronesmp;
import com.thronesmp.antixray.MiningListener;
import com.thronesmp.antixray.XrayMonitor;
import com.thronesmp.bounty.BountyListener;
import com.thronesmp.bounty.BountyManager;
import com.thronesmp.command.BountyCommand;
import com.thronesmp.command.KingdomCommand;
import com.thronesmp.command.ThroneCommand;
import com.thronesmp.command.WarCommand;
import com.thronesmp.config.ConfigManager;
import com.thronesmp.king.KingPerksManager;
import com.thronesmp.king.KingRewardTask;
import com.thronesmp.listener.PlayerDeathListener;
import com.thronesmp.listener.PlayerJoinListener;
import com.thronesmp.listener.PvPListener;
import com.thronesmp.team.TeamManager;
import com.thronesmp.throne.ThroneManager;
import com.thronesmp.throne.ThroneRegionListener;
import com.thronesmp.war.WarManager;
import com.thronesmp.war.WarScheduler;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class ThroneSMP extends JavaPlugin {
private ConfigManager configManager;
private TeamManager teamManager;
private ThroneManager throneManager;
private WarManager warManager;
private WarScheduler warScheduler;
private KingPerksManager kingPerksManager;
private KingRewardTask kingRewardTask;
private BountyManager bountyManager;
private XrayMonitor xrayMonitor;
private Economy economy;
@Override
public void onEnable() {
if (!setupDependencies()) {
getLogger().severe("Missing required dependencies! Disabling plugin...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.configManager = new ConfigManager(this);
this.teamManager = new TeamManager(this);
this.warManager = new WarManager(this);
this.throneManager = new ThroneManager(this);
this.kingPerksManager = new KingPerksManager(this);
this.bountyManager = new BountyManager(this);
this.xrayMonitor = new XrayMonitor(this);
this.kingRewardTask = new KingRewardTask(this);
this.kingRewardTask.start();
this.warScheduler = new WarScheduler(this);
this.warScheduler.start();
registerCommands();
registerListeners();
Bukkit.getScheduler().runTaskLater(this, () -> {
if (teamManager.getKingTeam() != null) {
kingPerksManager.applyKingPerks();
}
}, 40L);
getLogger().info("ThroneSMP enabled successfully!");
}
@Override
public void onDisable() {
if (kingRewardTask != null) {
kingRewardTask.stop();
}
if (warScheduler != null) {
warScheduler.stop();
}
if (teamManager != null) {
teamManager.saveData();
}
if (bountyManager != null) {
bountyManager.saveData();
}
if (xrayMonitor != null) {
xrayMonitor.saveData();
}
getLogger().info("ThroneSMP disabled.");
}
private boolean setupDependencies() {
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) {
getLogger().severe("WorldGuard not found!");
return false;
}
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
getLogger().severe("Vault not found!");
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
getLogger().severe("No economy plugin found!");
return false;
}
economy = rsp.getProvider();
return true;
}
private void registerCommands() {
getCommand("throne").setExecutor(new ThroneCommand(this));
getCommand("kingdom").setExecutor(new KingdomCommand(this));
getCommand("war").setExecutor(new WarCommand(this));
getCommand("bounty").setExecutor(new BountyCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new PvPListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerDeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new ThroneRegionListener(this), this);
Bukkit.getPluginManager().registerEvents(new BountyListener(this), this);
Bukkit.getPluginManager().registerEvents(new MiningListener(this), this);
}
}