PaPiTest/src/main/java/de/jatitv/papitest/system/Main.java

102 lines
4.9 KiB
Java

// This claas was created by JaTiTV
package de.jatitv.papitest.system;
import de.jatitv.papitest.Util;
import de.jatitv.papitest.commands.CmdExecuter;
import de.jatitv.papitest.commands.TabComplete;
import de.jatitv.papitest.config.Config;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
import java.util.logging.Level;
public final class Main extends JavaPlugin {
private static Main plugin;
public static String version;
public static List<String> autor;
public static Main getPlugin() {
return plugin;
}
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Plugin load...");
T2CupdateAPI.onUpdateCheck(plugin,Util.getPrefix(),Util.getSpigotID(),Util.getDiscord());
Metrics.Bstats(Main.plugin, Util.getBstatsID());
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
Config.configCreate();
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
if (T2CpluginCheck.papi()) {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!");
} else {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§4\n" + Util.getPrefix() + " §4PlaceholderAPI could not be connected / found! " +
"§9Please download it here: §6https://www.spigotmc.org/resources/placeholderapi.6245/§4\n" + Util.getPrefix());
}
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Plugin loaded successfully.");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Plugin loaded successfully.");
getCommand("papitest").setExecutor(new CmdExecuter());
getCommand("papitest").setTabCompleter(new TabComplete());
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), this);
int pluginId = 10767; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics(this, pluginId);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
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;
}
}
}