T2C-CommandGUI/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Bungee/BMain.java

101 lines
5.4 KiB
Java

package de.jatitv.commandguiv2.Bungee;
import de.jatitv.commandguiv2.Util;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.util.logging.Level;
public final class BMain extends Plugin {
private boolean enable = false;
public static Plugin plugin;
public static String update_version = null;
public static String prefix = "§8[§4C§9GUI§8]";
public static String version;
public static String autor;
public static Integer spigotID = 90671;
public static Integer bstatsID = 10840;
public static String spigot = "https://www.spigotmc.org/resources/" + spigotID;
public static String discord = "http://dc.t2code.net";
@Override
public void onEnable() {
// Plugin startup logic
Long long_ = Long.valueOf(System.currentTimeMillis());
plugin = this;
autor = plugin.getDescription().getAuthor();
version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
Bsend.console(prefix + "§4============================= §8[§4Command§9GUI§5BUNGEE§8] §4=============================");
Bsend.console(prefix + "§4 _____ §9_____ _ _ _____ §e ___ ");
Bsend.console(prefix + "§4 / ____§9/ ____| | | |_ _|§e |__ \\ ");
Bsend.console(prefix + "§4 | | §9| | __| | | | | |§e_ __ ) |");
Bsend.console(prefix + "§4 | | §9| | |_ | | | | | §e\\ \\ / // / ");
Bsend.console(prefix + "§4 | |___§9| |__| | |__| |_| |§e\\ V // /_ ");
Bsend.console(prefix + "§4 \\_____§9\\_____|\\____/|_____§e\\_/|____|");
Bsend.console(prefix);
Bsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
plugin.getProxy().registerChannel("cgui:bungee");
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
BListener.sendToSpigotDeleteAll();
BMetrics.Bstats();
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.console(prefix + "§4==============================================================================");
BUpdateChecker.onUpdateCheck();
BUpdateChecker.onUpdateCheckTimer();
enable = true;
}
@Override
public void onDisable() {
// Plugin shutdown logic
if (!enable) {
return;
}
Bsend.console(prefix + "§4============================= §8[§4Command§9GUI§5BUNGEE§8] §4=============================");
Bsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
Bsend.console(prefix + " §4Plugin successfully disabled.");
Bsend.console(prefix + "§4==============================================================================");
}
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
if (ProxyServer.getInstance().getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
// BMain.plugin.getPluginLoader().disablePlugin(BMain.plugin);
BMain.plugin.onDisable();
return true;
} else {
String plVer = ProxyServer.getInstance().getPluginManager().getPlugin(pl).getDescription().getVersion();
if (ver.contains("_")) {
if (!plVer.equals(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 the version §2" + ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net");
return true;
}
return false;
}
String[] split = plVer.split("_");
if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §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() + ".");
BMain.plugin.onDisable();
return true;
}
return false;
}
}
}