Files
src
build.gradle
Code
21 1,330
src/main/java/com/example/pmcworth/PmcWorth.java
package com.example.pmcworth;
import com.example.pmcworth.inventory.gui.GUIListener;
import com.example.pmcworth.inventory.gui.GUIManager;
import com.example.pmcworth.inventory.impl.WorthGUI;
import com.example.pmcworth.listener.ChatListener;
import com.example.pmcworth.listener.CommandProtectionListener;
import com.example.pmcworth.listener.ItemListener;
import com.example.pmcworth.listener.ShopLoadListener;
import com.example.pmcworth.manager.ConfigManager;
import com.example.pmcworth.manager.EconomyShopGUIManager;
import com.example.pmcworth.manager.LoreManager;
import com.example.pmcworth.manager.WorthManager;
import lombok.Getter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class PmcWorth extends JavaPlugin {
private ConfigManager configManager;
private WorthManager worthManager;
private LoreManager loreManager;
private GUIManager guiManager;
private EconomyShopGUIManager economyShopGUIManager;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.worthManager = new WorthManager(this);
this.loreManager = new LoreManager(this);
this.guiManager = new GUIManager();
this.economyShopGUIManager = new EconomyShopGUIManager(this);
getServer().getPluginManager().registerEvents(new ItemListener(this), this);
getServer().getPluginManager().registerEvents(new ChatListener(), this);
getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
getServer().getPluginManager().registerEvents(new CommandProtectionListener(), this);
if (economyShopGUIManager.isEconomyShopGUIEnabled()) {
getServer().getPluginManager().registerEvents(new ShopLoadListener(this), this);
}
getLogger().info("PmcWorth has been enabled!");
}
public FileConfiguration getWorthGuiConfig() {
return configManager.getWorthGuiConfig();
}
@Override
public void onDisable() {
getLogger().info("PmcWorth has been disabled!");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("pmcworth")) {
if (args.length == 0) {
sender.sendMessage("§ePmcWorth §7v" + getDescription().getVersion());
sender.sendMessage("§7Use §e/pmcworth reload §7to reload configurations");
return true;
}
if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("pmcworth.admin")) {
sender.sendMessage("§cYou don't have permission to use this command!");
return true;
}
configManager.reload();
worthManager.reload();
sender.sendMessage("§aPmcWorth configuration reloaded!");
return true;
}
if (args[0].equalsIgnoreCase("import")) {
if (!sender.hasPermission("pmcworth.admin")) {
sender.sendMessage("§cYou don't have permission to use this command!");
return true;
}
if (!economyShopGUIManager.isEconomyShopGUIEnabled()) {
sender.sendMessage("§cEconomyShopGUI is not installed!");
return true;
}
sender.sendMessage("§eImporting prices from EconomyShopGUI...");
economyShopGUIManager.loadShopPrices();
sender.sendMessage("§aPrice import completed!");
return true;
}
}
if (command.getName().equalsIgnoreCase("worth")) {
if (!(sender instanceof Player)) {
sender.sendMessage("§cThis command can only be used by players!");
return true;
}
Player player = (Player) sender;
WorthGUI gui = new WorthGUI(this, 0);
guiManager.openGUI(gui, player);
return true;
}
return false;
}
}