Files
src
build.gradle
settings.gradle
Code
15 867
src/main/java/com/grimwar/GrimwarPlugin.java
package com.grimwar;
import com.grimwar.command.GrimCommand;
import com.grimwar.grimoire.GrimoireListener;
import com.grimwar.grimoire.GrimoireManager;
import com.grimwar.grimoire.GrimoireMenu;
import com.grimwar.spell.SpellService;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;
public final class GrimwarPlugin extends JavaPlugin {
private GrimoireManager grimoireManager;
private SpellService spellService;
private NamespacedKey grimoireItemKey;
@Override
public void onEnable() {
this.grimoireItemKey = new NamespacedKey(this, "grimoire");
this.grimoireManager = new GrimoireManager(this);
this.spellService = new SpellService(this, grimoireManager);
GrimoireMenu grimoireMenu = new GrimoireMenu(this, grimoireManager);
GrimCommand command = new GrimCommand(this, grimoireManager, spellService, grimoireMenu);
getCommand("grim").setExecutor(command);
getCommand("grim").setTabCompleter(command);
getCommand("cast").setExecutor(command);
Bukkit.getPluginManager().registerEvents(grimoireMenu, this);
Bukkit.getPluginManager().registerEvents(new GrimoireListener(this, grimoireManager, spellService), this);
Bukkit.getOnlinePlayers().forEach(player -> grimoireManager.getOrCreate(player));
}
@Override
public void onDisable() {
if (grimoireManager != null) {
grimoireManager.saveAll();
}
}
public NamespacedKey getGrimoireItemKey() {
return grimoireItemKey;
}
}