143 lines
6.3 KiB
Java
143 lines
6.3 KiB
Java
package net.t2code.commandguiv2.Spigot;
|
|
|
|
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
|
import net.t2code.commandguiv2.Spigot.system.Load;
|
|
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
|
import net.t2code.commandguiv2.Spigot.database.MySQL;
|
|
import net.t2code.commandguiv2.Util;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.io.File;
|
|
import java.util.*;
|
|
import java.util.logging.Level;
|
|
|
|
public final class Main extends JavaPlugin {
|
|
|
|
public static ArrayList<String> bungeejoinplayers = new ArrayList<>();
|
|
|
|
public static File getPath() {
|
|
return plugin.getDataFolder();
|
|
}
|
|
|
|
private static Boolean enable = false;
|
|
public static Boolean legacy = false;
|
|
|
|
public static String version;
|
|
|
|
public static List<String> autor;
|
|
|
|
private static Main plugin;
|
|
|
|
public static Boolean PaPi = false;
|
|
public static Boolean PlotSquaredGUI = false;
|
|
public static Boolean LuckyBox = false;
|
|
public static Boolean PlugManGUI = false;
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Plugin startup logic
|
|
plugin = this;
|
|
autor = this.getDescription().getAuthors();
|
|
version = this.getDescription().getVersion();
|
|
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
|
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12() || T2CmcVersion.isMc1_13() ||
|
|
T2CmcVersion.isMc1_14() || T2CmcVersion.isMc1_15() || T2CmcVersion.isNms1_16_R1()) {
|
|
legacy = true;
|
|
}
|
|
|
|
if (T2CpluginCheck.pluginCheck("CommandGUI")) {
|
|
T2Csend.error( plugin, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
T2Csend.error( plugin,"");
|
|
T2Csend.error( plugin,"An older version of the plugin T2C-CommandGUI was found!");
|
|
T2Csend.error( plugin,"This plugin is now called T2C-CommandGUI and no longer CommandGUI!");
|
|
T2Csend.error( plugin,"Please remove the older version (CommandGUI)!");
|
|
T2Csend.error( plugin,this.getName() + " version: " + this.getDescription().getVersion() + " could not be loaded!");
|
|
T2Csend.error( plugin,"");
|
|
T2Csend.error( plugin,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
|
return;
|
|
}
|
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
|
if (T2CpluginCheck.papi()) {
|
|
PaPi = true;
|
|
}
|
|
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
|
enable = true;
|
|
}
|
|
|
|
public static void addonLoad() {
|
|
if (T2CpluginCheck.plotSquaredGUI()) {
|
|
PlotSquaredGUI = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
|
|
}
|
|
|
|
if (T2CpluginCheck.luckyBox()) {
|
|
LuckyBox = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
|
|
}
|
|
|
|
if (T2CpluginCheck.plugManGUI()) {
|
|
PlugManGUI = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("PlugManGUI"));
|
|
}
|
|
}
|
|
|
|
public static void addonEnable(Plugin plugin) {
|
|
T2Csend.console(Util.getPrefix() + " §aAddon for: §e" + plugin.getName() + "§7 - Version: " + plugin.getDescription().getVersion() + " §aloaded successfully!");
|
|
}
|
|
|
|
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
|
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
|
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
Bukkit.getConsoleSender().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.getPluginLoader().disablePlugin(Main.plugin);
|
|
return true;
|
|
} else {
|
|
String plVer = Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion();
|
|
if (ver.contains("_")) {
|
|
if (!plVer.equals(ver)) {
|
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
Bukkit.getConsoleSender().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");
|
|
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
|
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!");
|
|
Bukkit.getConsoleSender().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.getPluginLoader().disablePlugin(Main.plugin);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void sendTryCatch(Class c, StackTraceElement line) {
|
|
T2Csend.error(plugin,c.getName() + " Line: " + line.getLineNumber());
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Plugin shutdown logic
|
|
if (enable) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
|
MySQL.close();
|
|
}
|
|
|
|
public static Main getPlugin() {
|
|
return plugin;
|
|
}
|
|
}
|