package net.crankedpvp.tournaments; import lombok.Getter; import net.crankedpvp.tournaments.listeners.PlayerJoinListener; import net.crankedpvp.tournaments.listeners.PlayerQuitListener; import net.crankedpvp.tournaments.listeners.TournamentDeathListener; import net.crankedpvp.tournaments.listeners.TournamentLogicListener; import net.crankedpvp.tournaments.managers.TournamentManager; import net.crankedpvp.tournaments.utils.Queue; import net.crankedpvp.tournaments.utils.Utils; import me.mattstudios.mf.base.CommandManager; import net.crankedpvp.tournaments.commands.TournamentCommand; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class CrankedTournaments extends JavaPlugin { @Getter public static CrankedTournaments instance; @Getter private TournamentManager tournamentManager; @Getter private ArenaRegister arenaRegister; public void onEnable() { instance = this; this.tournamentManager = new TournamentManager(this); this.tournamentManager.setPlayerQueue(new Queue<>()); this.tournamentManager.setWaitingRoomLocation(Utils.getLocationFromString(this.getConfig().getString("Tournament.WaitingRoom.Location"))); getTournamentManager().loadAll(); this.arenaRegister = new ArenaRegister(this); this.arenaRegister.registerArenas(); CommandManager commandManager = new CommandManager(this); commandManager.register(new TournamentCommand(this)); this.registerListeners(); Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, ()-> { getTournamentManager().saveAll(); },60L, 20L*10); } public void onDisable() { if(getTournamentManager().isActive()) { getTournamentManager().end(); System.out.println("[Tournaments] Force ended an active tournament"); } getTournamentManager().saveAll(); } public void registerListeners() { PluginManager pluginManager = this.getServer().getPluginManager(); pluginManager.registerEvents(new TournamentDeathListener(this), this); pluginManager.registerEvents(new PlayerQuitListener(this), this); pluginManager.registerEvents(new TournamentLogicListener(), this); pluginManager.registerEvents(new PlayerJoinListener(), this); } }