initial
This commit is contained in:
66
src/main/java/net/t2code/autoresponse/Spigot/Main.java
Normal file
66
src/main/java/net/t2code/autoresponse/Spigot/Main.java
Normal file
@@ -0,0 +1,66 @@
|
||||
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.lib.Spigot.Lib.messages.T2CodeTemplate;
|
||||
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.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
public static File getPath() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
public static String version;
|
||||
public static List<String> autor;
|
||||
|
||||
public 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;
|
||||
T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
}
|
||||
|
||||
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(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 {
|
||||
if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user