123 lines
5.0 KiB
Java
123 lines
5.0 KiB
Java
package de.jatitv.commandguiv2.Spigot;
|
|
//s<ds
|
|
|
|
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
|
import de.jatitv.commandguiv2.Spigot.system.Load;
|
|
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
|
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
|
|
import de.jatitv.commandguiv2.Util;
|
|
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
|
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;
|
|
import java.util.logging.Logger;
|
|
|
|
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 String prefix = "§8[§4C§9GUI§8]";
|
|
|
|
public static String version;
|
|
|
|
public static List<String> autor;
|
|
|
|
public static Main plugin;
|
|
public static List plugins;
|
|
|
|
public static String update_version = null;
|
|
public static Boolean PaPi = false;
|
|
public static Boolean PlotSquaredGUI = false;
|
|
public static Boolean LuckyBox = false;
|
|
public static Boolean PlugManGUI = false;
|
|
|
|
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
|
|
public static ArrayList<String> allAliases = new ArrayList<>();
|
|
|
|
public static HashMap<String, Function> functionHashMap = new HashMap<>();
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
plugins = Arrays.asList(getServer().getPluginManager().getPlugins());
|
|
// Plugin startup logic
|
|
// Plugin startup logic
|
|
Logger logger = this.getLogger();
|
|
plugin = this;
|
|
autor = plugin.getDescription().getAuthors();
|
|
version = plugin.getDescription().getVersion();
|
|
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
|
if (PluginCheck.papi()) {
|
|
PaPi = true;
|
|
}
|
|
Load.onLoad(prefix, autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
|
enable = true;
|
|
|
|
}
|
|
|
|
public static void addonLoad() {
|
|
if (PluginCheck.plotSquaredGUI()) {
|
|
PlotSquaredGUI = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
|
|
}if (PluginCheck.luckyBox()) {
|
|
LuckyBox = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
|
|
}
|
|
if (PluginCheck.plugManGUI()) {
|
|
PlugManGUI = true;
|
|
addonEnable(Bukkit.getPluginManager().getPlugin("PlugManGUI"));
|
|
}
|
|
}
|
|
|
|
public static void addonEnable(Plugin plugin) {
|
|
send.console(prefix + " §aAddon for: §e" + plugin.getName() + "§7 - Version: " + plugin.getDescription().getVersion() + " §aloaded successfully!");
|
|
}
|
|
|
|
public static Boolean pluginNotFound(String pl, Integer spigotID) {
|
|
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
|
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
Bukkit.getConsoleSender().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.");
|
|
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
|
return true;
|
|
} else return false;
|
|
}
|
|
|
|
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) {
|
|
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
|
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
Bukkit.getConsoleSender().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.");
|
|
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
|
return true;
|
|
} else {
|
|
if (Double.parseDouble(Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion()) < ver) {
|
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
Bukkit.getConsoleSender().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() + ".");
|
|
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Plugin shutdown logic
|
|
if (enable) T2CodeTemplate.onDisable(prefix, autor, version, Util.getSpigot(), Util.getDiscord());
|
|
MySQL.close();
|
|
}
|
|
}
|