Files
src
build.gradle
Code
15 1,324
src/main/java/com/example/tapbankapi/TapBankAPI.java
package com.example.tapbankapi;
import com.example.tapbankapi.api.APIServer;
import com.example.tapbankapi.command.StockCommand;
import com.example.tapbankapi.command.TapAPICommand;
import com.example.tapbankapi.config.ConfigManager;
import com.example.tapbankapi.data.DataStorage;
import com.example.tapbankapi.economy.EconomyManager;
import com.example.tapbankapi.stock.StockManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class TapBankAPI extends JavaPlugin {
private ConfigManager configManager;
private EconomyManager economyManager;
private StockManager stockManager;
private DataStorage dataStorage;
private APIServer apiServer;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.configManager.loadConfig();
this.economyManager = new EconomyManager(this);
if (!this.economyManager.setupEconomy()) {
getLogger().severe("Vault not found! Disabling plugin.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.dataStorage = new DataStorage(this);
this.dataStorage.loadData();
this.stockManager = new StockManager(this);
this.stockManager.initialize();
this.stockManager.startPriceUpdates();
getCommand("tapi").setExecutor(new TapAPICommand(this));
getCommand("stock").setExecutor(new StockCommand(this));
if (this.configManager.isApiEnabled()) {
this.apiServer = new APIServer(this);
this.apiServer.start();
}
getLogger().info("TapBankAPI has been enabled!");
}
@Override
public void onDisable() {
if (this.stockManager != null) {
this.stockManager.stopPriceUpdates();
}
if (this.dataStorage != null) {
this.dataStorage.saveData();
}
if (this.apiServer != null) {
this.apiServer.stop();
}
getLogger().info("TapBankAPI has been disabled!");
}
}