package net.t2code.t2codelib.BUNGEE.system; import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.md_5.bungee.api.plugin.Plugin; import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers; import net.t2code.t2codelib.Util; public class T2CodeBMain extends Plugin { private static Plugin plugin; public static Plugin getPlugin() { return plugin; } private static String version; private static String orgVersion; private static String autor; private static Boolean mmIsLoad = true; private static BungeeAudiences adventure; public static BungeeAudiences getAdventure() { if(adventure == null) { throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled"); } return adventure; } @Override public void onEnable() { // Plugin startup logic plugin = this; orgVersion = plugin.getDescription().getVersion(); autor = plugin.getDescription().getAuthor(); try { adventure = BungeeAudiences.create(this); T2CBsend.info(this,"Adventure load!"); } catch (Exception e){ T2CBsend.error(this,"Adventure can not be load!"); mmIsLoad = false; } T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit()); version = plugin.getDescription().getVersion(); } @Override public void onDisable() { // Plugin shutdown logic T2CBbungeePlayers.sendToSpigotDeleteAll(); if (mmIsLoad){ if(adventure != null) { adventure.close(); adventure = null; } } T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); T2CBsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", "")); T2CBsend.console(Util.getPrefix() + " §2Version: §6" + version); T2CBsend.console(Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot()); T2CBsend.console(Util.getPrefix() + " §2Discord: §6" + Util.getDiscord()); T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled."); T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); } public static Boolean getMmIsLoad() { return mmIsLoad; } }