Files
src
build.gradle
Code
14 2,571
src/main/java/com/example/thaishop/ThaiShop.java
package com.example.thaishop;
import com.example.thaishop.command.ShopCommand;
import com.example.thaishop.gui.GUIListener;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class ThaiShop extends JavaPlugin {
@Getter private ShopManager shopManager;
@Getter private Economy economy;
@Override
public void onEnable() {
if (!setupEconomy()) {
getLogger().severe("ไม่พบ Vault หรือปลั๊กอินเศรษฐกิจ! ปิดการทำงาน...");
getServer().getPluginManager().disablePlugin(this);
return;
}
saveResource("price.yml", false);
shopManager = new ShopManager(this);
shopManager.load();
getServer().getPluginManager().registerEvents(new GUIListener(this), this);
getCommand("shop").setExecutor(new ShopCommand(this));
getLogger().info("§aThaiShop เปิดใช้งานแล้ว! พิมพ์ /shop เพื่อเปิดร้านค้า");
}
@Override
public void onDisable() {
getLogger().info("ThaiShop ปิดการทำงาน");
}
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;
}
}