Files
src
pom.xml
Code
12 779
src/main/java/com/actualbuca/bucasafezone/BucaSafeZonePlugin.java
package com.actualbuca.bucasafezone;
import com.actualbuca.bucasafezone.command.BucaSafeZoneCommand;
import com.actualbuca.bucasafezone.listener.SafeZoneListener;
import com.actualbuca.bucasafezone.manager.MessageManager;
import com.actualbuca.bucasafezone.manager.SelectionManager;
import com.actualbuca.bucasafezone.manager.ZoneManager;
import com.actualbuca.bucasafezone.service.WandService;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
public class BucaSafeZonePlugin extends JavaPlugin {
private ZoneManager zoneManager;
private SelectionManager selectionManager;
private MessageManager messageManager;
private WandService wandService;
@Override
public void onEnable() {
this.saveDefaultConfig();
if (!this.isLicenseValid()) {
this.getLogger().severe("Invalid or missing license code. BucaSafeZone is disabling.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.zoneManager = new ZoneManager(this);
this.zoneManager.load();
this.selectionManager = new SelectionManager();
this.messageManager = new MessageManager(this);
this.wandService = new WandService(this);
BucaSafeZoneCommand command = new BucaSafeZoneCommand(this, this.messageManager, this.selectionManager, this.zoneManager, this.wandService);
PluginCommand pluginCommand = this.getCommand("bucasafezone");
if (pluginCommand != null) {
pluginCommand.setExecutor(command);
pluginCommand.setTabCompleter(command);
}
Bukkit.getPluginManager().registerEvents(new SafeZoneListener(this, this.zoneManager, this.selectionManager, this.messageManager, this.wandService), this);
}
public boolean reloadPlugin() {
this.reloadConfig();
if (!this.isLicenseValid()) {
Bukkit.getPluginManager().disablePlugin(this);
return false;
}
this.zoneManager.load();
return true;
}
private boolean isLicenseValid() {
return "A74J-908A-LLOK".equals(this.getConfig().getString("license", ""));
}
}