Files
src
pom.xml
README.md
Code
11 1,028
src/main/java/com/kodari/fantasyweapons/FantasyWeaponsPlugin.java
package com.kodari.fantasyweapons;

import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class FantasyWeaponsPlugin extends JavaPlugin {
    private WeaponService weaponService;
    private RecipeManager recipeManager;
    private AbilityManager abilityManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("recipes.yml", false);
        weaponService = new WeaponService(this);
        recipeManager = new RecipeManager(this, weaponService);
        abilityManager = new AbilityManager(this, weaponService);
        Bukkit.getPluginManager().registerEvents(new WeaponListener(this, weaponService, abilityManager), this);
        FantasyWeaponsCommand command = new FantasyWeaponsCommand(this, weaponService, recipeManager);
        PluginCommand pluginCommand = getCommand("fantasyweapons");
        if (pluginCommand == null) {
            getLogger().severe("Command fantasyweapons is missing from plugin.yml");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        pluginCommand.setExecutor(command);
        pluginCommand.setTabCompleter(command);
        recipeManager.registerRecipes();
    }

    @Override
    public void onDisable() {
        Bukkit.getScheduler().cancelTasks(this);
    }

    public NamespacedKey key(String name) {
        return new NamespacedKey(this, name);
    }

    public void reloadPlugin() {
        reloadConfig();
        recipeManager.reloadRecipes();
    }
}