package net.knarcraft.minstrel; import net.citizensnpcs.api.CitizensAPI; import net.knarcraft.minstrel.command.MinstrelCommand; import net.knarcraft.minstrel.command.MinstrelTabCompleter; import net.knarcraft.minstrel.listener.MinstrelListener; import net.knarcraft.minstrel.manager.QueueManager; import net.knarcraft.minstrel.trait.MinstrelTrait; import org.bukkit.Bukkit; import org.bukkit.command.PluginCommand; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import java.util.ArrayList; import java.util.List; /** * The main class of this plugin */ public final class MinstrelPlugin extends JavaPlugin { private static MinstrelPlugin instance; private final List knownMinstrels = new ArrayList<>(); @Override public void onEnable() { // Plugin startup logic instance = this; //Register the blacksmith trait with Citizens CitizensAPI.getTraitFactory().registerTrait( net.citizensnpcs.api.trait.TraitInfo.create(MinstrelTrait.class).withName("minstrel")); PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new MinstrelListener(), this); PluginCommand minstrelCommand = this.getCommand("minstrel"); if (minstrelCommand != null) { minstrelCommand.setExecutor(new MinstrelCommand()); minstrelCommand.setTabCompleter(new MinstrelTabCompleter()); } Bukkit.getScheduler().scheduleSyncRepeatingTask(this, QueueManager::handleQueue, 20, 10); } @Override public void onDisable() { for (MinstrelTrait minstrelTrait : knownMinstrels) { minstrelTrait.getPlaylist().stop(); } } /** * Adds the given minstrel to the list of known minstrels * * @param minstrelTrait

The minstrel to add

*/ public void addMinstrel(MinstrelTrait minstrelTrait) { knownMinstrels.add(minstrelTrait); } /** * Gets all currently known minstrels * * @return

All currently known minstrels

*/ public List getMinstrels() { return new ArrayList<>(knownMinstrels); } /** * Gets an instance of this plugin * * @return

An instance of this plugin

*/ public static MinstrelPlugin getInstance() { return instance; } }