Files
src
build.gradle
Code
22 1,628
src/main/java/com/aethel/lands/AethelLands.java
package com.aethel.lands;
import com.aethel.lands.commands.LandCommand;
import com.aethel.lands.config.ConfigManager;
import com.aethel.lands.config.MessageManager;
import com.aethel.lands.inventory.gui.GUIListener;
import com.aethel.lands.inventory.gui.GUIManager;
import com.aethel.lands.listeners.BlockListener;
import com.aethel.lands.listeners.InteractListener;
import com.aethel.lands.listeners.MovementListener;
import com.aethel.lands.listeners.PlayerListener;
import com.aethel.lands.managers.LandManager;
import com.aethel.lands.managers.SelectionManager;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class AethelLands extends JavaPlugin {
private ConfigManager configManager;
private MessageManager messageManager;
private LandManager landManager;
private SelectionManager selectionManager;
private GUIManager guiManager;
private Economy economy;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.messageManager = new MessageManager(this);
this.landManager = new LandManager(this);
this.selectionManager = new SelectionManager();
this.guiManager = new GUIManager();
if (!setupEconomy()) {
getLogger().warning("Vault non trovato! Sistema economia disabilitato.");
}
registerCommands();
registerListeners();
landManager.loadLands();
getLogger().info("AethelLands abilitato con successo!");
}
@Override
public void onDisable() {
if (landManager != null) {
landManager.saveLands();
}
getLogger().info("AethelLands disabilitato.");
}
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;
}
private void registerCommands() {
LandCommand landCommand = new LandCommand(this);
getCommand("land").setExecutor(landCommand);
getCommand("land").setTabCompleter(landCommand);
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new BlockListener(this), this);
Bukkit.getPluginManager().registerEvents(new InteractListener(this), this);
Bukkit.getPluginManager().registerEvents(new MovementListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
}
}