Files
src
build.gradle
manifest.kod
settings.gradle
Code
21 1,404
src/main/java/com/kodari/merchantshops/MerchantShops.java
package com.kodari.merchantshops;
import com.kodari.merchantshops.command.MerchantShopsCommand;
import com.kodari.merchantshops.economy.DisabledEconomyProvider;
import com.kodari.merchantshops.economy.EconomyProvider;
import com.kodari.merchantshops.economy.VaultEconomyProvider;
import com.kodari.merchantshops.gui.GuiManager;
import com.kodari.merchantshops.listener.ShopListener;
import com.kodari.merchantshops.service.ShopService;
import com.kodari.merchantshops.storage.ShopStorage;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class MerchantShops extends JavaPlugin {
private ShopService shopService;
private GuiManager guiManager;
@Override
public void onEnable() {
saveDefaultConfig();
ShopStorage storage = new ShopStorage(this);
EconomyProvider economy;
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
economy = new VaultEconomyProvider(this);
} else {
economy = new DisabledEconomyProvider();
getLogger().warning("Vault was not found. Shop transactions are disabled.");
}
shopService = new ShopService(this, storage, economy);
shopService.load();
guiManager = new GuiManager(this, shopService);
Bukkit.getPluginManager().registerEvents(new ShopListener(this, shopService, guiManager), this);
MerchantShopsCommand command = new MerchantShopsCommand(this, shopService, guiManager);
getCommand("merchantshops").setExecutor(command);
getCommand("merchantshops").setTabCompleter(command);
long period = Math.max(20L, getConfig().getLong("settings.restock-period-seconds", 300L) * 20L);
Bukkit.getScheduler().runTaskTimer(this, () -> shopService.restock(), period, period);
}
@Override
public void onDisable() {
if (shopService != null) {
shopService.save();
}
}
public ShopService getShopService() {
return shopService;
}
public GuiManager getGuiManager() {
return guiManager;
}
}