93 lines
3.9 KiB
Java
93 lines
3.9 KiB
Java
package net.t2code.autoresponse.Spigot;
|
|
|
|
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
|
import net.t2code.autoresponse.Spigot.system.Load;
|
|
import net.t2code.autoresponse.Util;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.logging.Level;
|
|
|
|
public final class Main extends JavaPlugin {
|
|
|
|
public static File getPath() {
|
|
return plugin.getDataFolder();
|
|
}
|
|
|
|
private static String version;
|
|
private static List<String> autor;
|
|
|
|
private static Main plugin;
|
|
|
|
public static ArrayList<ResponsesObject> allResponses = new ArrayList<>();
|
|
public static ArrayList<String> allResponse = new ArrayList<>();
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Plugin startup logic
|
|
plugin = this;
|
|
autor = plugin.getDescription().getAuthors();
|
|
version = plugin.getDescription().getVersion();
|
|
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
|
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Plugin shutdown logic
|
|
allResponses.clear();
|
|
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return;
|
|
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
|
}
|
|
|
|
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 String getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public static List<String> getAutor() {
|
|
return autor;
|
|
}
|
|
|
|
public static Main getPlugin() {
|
|
return plugin;
|
|
}
|
|
}
|