package net.t2code.alias.Bungee; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Plugin; import net.t2code.alias.Bungee.objects.Alias_Objekt; import net.t2code.alias.Bungee.system.Load; import net.t2code.alias.Util; import net.t2code.lib.Bungee.Lib.messages.BT2CodeTemplate; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Objects; import java.util.logging.Level; public final class Main extends Plugin { public static File getPath() { return plugin.getDataFolder(); } public static String prefix = Util.Prefix; public static Integer spigotID = Util.SpigotID; public static Integer bstatsID = Util.BstatsID; public static String spigot = Util.Spigot; public static String discord = Util.Discord; public static String version; public static String autor; public static Main plugin; public static HashMap aliasHashMap = new HashMap<>(); public static ArrayList allAliases = new ArrayList<>(); private static Boolean enable= false; @Override public void onEnable() { // Plugin startup logic plugin = this; autor = plugin.getDescription().getAuthor(); version = plugin.getDescription().getVersion(); if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; Load.onLoad(prefix, autor, version, spigot, spigotID, discord, bstatsID); enable = true; } @Override public void onDisable() { // Plugin shutdown logic aliasHashMap.clear(); allAliases.clear(); if (enable) return; BT2CodeTemplate.onDisable(prefix, autor, version, spigot, discord); } public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { if (ProxyServer.getInstance().getPluginManager().getPlugin(pl) == null) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); Main.plugin.onDisable(); return true; } else { if (Double.parseDouble(Objects.requireNonNull(ProxyServer.getInstance().getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + "."); Main.plugin.onDisable(); return true; } return false; } } }