Files
src
build.gradle
Code
10 699
src/main/java/com/bountysystem/BountySystem.java
package com.bountysystem;
import com.bountysystem.command.BountyCommand;
import com.bountysystem.command.EndBountyCommand;
import com.bountysystem.listener.BountyListener;
import com.bountysystem.manager.BossBarManager;
import com.bountysystem.manager.BountyManager;
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 BountySystem extends JavaPlugin {
private Economy economy;
private BountyManager bountyManager;
private BossBarManager bossBarManager;
@Override
public void onEnable() {
saveDefaultConfig();
if (!setupEconomy()) {
getLogger().severe("Vault not found! Disabling plugin...");
getServer().getPluginManager().disablePlugin(this);
return;
}
bountyManager = new BountyManager(this);
bossBarManager = new BossBarManager(this);
getCommand("bounty").setExecutor(new BountyCommand(this));
getCommand("endbounty").setExecutor(new EndBountyCommand(this));
Bukkit.getPluginManager().registerEvents(new BountyListener(this), this);
bountyManager.loadBounties();
bossBarManager.startUpdateTask();
getLogger().info("BountySystem has been enabled!");
}
@Override
public void onDisable() {
if (bossBarManager != null) {
bossBarManager.stopUpdateTask();
bossBarManager.removeAllBossBars();
}
if (bountyManager != null) {
bountyManager.saveBounties();
}
getLogger().info("BountySystem has been 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;
}
}