Files
src
Code
3 203
src/main/java/com/kodari/bountyhunters/BountyHunters.java
package com.kodari.bountyhunters;
import com.kodari.bountyhunters.commands.BountyAdminCommand;
import com.kodari.bountyhunters.commands.BountyCommand;
import com.kodari.bountyhunters.listeners.BountyListener;
import com.kodari.bountyhunters.managers.BountyManager;
import com.kodari.bountyhunters.managers.KillStreakManager;
import com.kodari.bountyhunters.placeholders.BountyPlaceholders;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class BountyHunters extends JavaPlugin {
@Getter private static BountyHunters instance;
@Getter private BountyManager bountyManager;
@Getter private KillStreakManager killStreakManager;
@Getter private Economy economy;
@Override
public void onEnable() {
instance = this;
saveDefaultConfig();
if (!setupEconomy()) {
getLogger().severe("Vault economy not found — disabling.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
bountyManager = new BountyManager(this);
killStreakManager = new KillStreakManager(this);
getServer().getPluginManager().registerEvents(new BountyListener(this), this);
BountyCommand bountyCmd = new BountyCommand(this);
getCommand("bounty").setExecutor(bountyCmd);
getCommand("bounty").setTabCompleter(bountyCmd);
BountyAdminCommand adminCmd = new BountyAdminCommand(this);
getCommand("bountyadmin").setExecutor(adminCmd);
getCommand("bountyadmin").setTabCompleter(adminCmd);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new BountyPlaceholders(this).register();
getLogger().info("PlaceholderAPI hooked successfully.");
}
getLogger().info("BountyHunters enabled.");
}
@Override
public void onDisable() {
if (bountyManager != null) bountyManager.saveBounties();
getLogger().info("BountyHunters disabled.");
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) return false;
economy = rsp.getProvider();
return economy != null;
}
}