Files
src
build.gradle
settings.gradle
Code
11 835
src/main/java/com/kodari/shadoweconomy/ShadowEconomy.java
package com.kodari.shadoweconomy;
import com.kodari.shadoweconomy.account.AccountStore;
import com.kodari.shadoweconomy.command.EconomyCommand;
import com.kodari.shadoweconomy.economy.ShadowEconomyProvider;
import com.kodari.shadoweconomy.listener.PlayerJoinListener;
import com.kodari.shadoweconomy.placeholder.ShadowEconomyExpansion;
import com.kodari.shadoweconomy.util.CurrencyFormatter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
public final class ShadowEconomy extends JavaPlugin {
private AccountStore accountStore;
private ShadowEconomyProvider economyProvider;
private CurrencyFormatter currencyFormatter;
@Override
public void onEnable() {
saveDefaultConfig();
currencyFormatter = new CurrencyFormatter(this);
accountStore = new AccountStore(this);
economyProvider = new ShadowEconomyProvider(this, accountStore);
getServer().getServicesManager().register(Economy.class, economyProvider, this, ServicePriority.Highest);
getServer().getPluginManager().registerEvents(new PlayerJoinListener(accountStore), this);
EconomyCommand commandExecutor = new EconomyCommand(this, accountStore, economyProvider);
getCommand("bal").setExecutor(commandExecutor);
getCommand("pay").setExecutor(commandExecutor);
getCommand("eco").setExecutor(commandExecutor);
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
new ShadowEconomyExpansion(this).register();
getLogger().info("PlaceholderAPI expansion registered.");
}
getLogger().info("ShadowEconomyCore enabled and registered as the Vault economy provider.");
}
@Override
public void onDisable() {
if (accountStore != null) {
accountStore.save();
}
getServer().getServicesManager().unregisterAll(this);
}
public AccountStore getAccountStore() {
return accountStore;
}
public String formatBalance(double amount) {
return currencyFormatter.format(amount);
}
}