Files
src
build.gradle
Code
17 925
src/main/java/com/cryptoinvest/CryptoInvest.java
package com.cryptoinvest;
import com.cryptoinvest.command.InvestCommand;
import com.cryptoinvest.inventory.gui.GUIListener;
import com.cryptoinvest.inventory.gui.GUIManager;
import com.cryptoinvest.manager.CryptoManager;
import com.cryptoinvest.manager.InvestmentManager;
import com.cryptoinvest.task.PriceUpdateTask;
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 CryptoInvest extends JavaPlugin {
private GUIManager guiManager;
private CryptoManager cryptoManager;
private InvestmentManager investmentManager;
private Economy economy;
@Override
public void onEnable() {
saveDefaultConfig();
if (!setupEconomy()) {
getLogger().severe("Vault not found! This plugin requires Vault and an economy plugin.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.guiManager = new GUIManager();
this.cryptoManager = new CryptoManager(this);
this.investmentManager = new InvestmentManager(this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
getCommand("invest").setExecutor(new InvestCommand(this));
long updateInterval = getConfig().getLong("update-interval", 60) * 20L;
new PriceUpdateTask(this).runTaskTimer(this, updateInterval, updateInterval);
getLogger().info("CryptoInvest has been enabled!");
}
@Override
public void onDisable() {
getLogger().info("CryptoInvest has been disabled!");
}
private boolean setupEconomy() {
if (Bukkit.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;
}
}