Files
src
build.gradle
Code
29 1,949
src/main/java/com/lucksmp/plugin/LuckSMP.java
package com.lucksmp.plugin;
import com.lucksmp.plugin.commands.LuckCommand;
import com.lucksmp.plugin.commands.LuckSMPCommand;
import com.lucksmp.plugin.inventory.gui.GUIListener;
import com.lucksmp.plugin.inventory.gui.GUIManager;
import com.lucksmp.plugin.listeners.LuckEventListener;
import com.lucksmp.plugin.listeners.RuneListener;
import com.lucksmp.plugin.managers.DatabaseManager;
import com.lucksmp.plugin.managers.EventManager;
import com.lucksmp.plugin.managers.LuckManager;
import com.lucksmp.plugin.managers.RuneManager;
import com.lucksmp.plugin.placeholders.LuckPlaceholder;
import com.lucksmp.plugin.runes.impl.BlindRune;
import com.lucksmp.plugin.runes.impl.DashRune;
import com.lucksmp.plugin.runes.impl.FreezeRune;
import com.lucksmp.plugin.runes.impl.TeleportRune;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class LuckSMP extends JavaPlugin {
private DatabaseManager databaseManager;
private LuckManager luckManager;
private RuneManager runeManager;
private EventManager eventManager;
private GUIManager guiManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.databaseManager = new DatabaseManager(this);
this.luckManager = new LuckManager(this);
this.runeManager = new RuneManager(this);
this.eventManager = new EventManager(this);
this.guiManager = new GUIManager();
this.databaseManager.loadAllData();
this.registerRunes();
this.registerCommands();
this.registerListeners();
this.eventManager.startEventTask();
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new LuckPlaceholder(this).register();
getLogger().info("PlaceholderAPI hook enabled!");
}
getLogger().info("LuckSMP S2 has been enabled!");
}
@Override
public void onDisable() {
if (this.eventManager != null) {
this.eventManager.stopEventTask();
}
if (this.databaseManager != null) {
this.databaseManager.saveAllData();
}
getLogger().info("LuckSMP S2 has been disabled!");
}
private void registerRunes() {
this.runeManager.registerRune(new FreezeRune(this));
this.runeManager.registerRune(new BlindRune(this));
this.runeManager.registerRune(new DashRune(this));
this.runeManager.registerRune(new TeleportRune(this));
}
private void registerCommands() {
getCommand("luck").setExecutor(new LuckCommand(this));
getCommand("lucksmp").setExecutor(new LuckSMPCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
Bukkit.getPluginManager().registerEvents(new RuneListener(this), this);
Bukkit.getPluginManager().registerEvents(new LuckEventListener(this), this);
}
public void reloadPlugin() {
reloadConfig();
this.eventManager.stopEventTask();
this.eventManager.startEventTask();
}
}