97 lines
4.2 KiB
Java
97 lines
4.2 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.lib.Spigot.Lib.plugins.PluginCheck;
|
|
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.logging.Level;
|
|
|
|
public final class Main extends JavaPlugin {
|
|
|
|
public static Main plugin;
|
|
public static String version;
|
|
public static List<String> autor;
|
|
|
|
public static Main getPlugin() {
|
|
return plugin;
|
|
}
|
|
|
|
public static Plugin thisp() {
|
|
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...");
|
|
|
|
UpdateAPI.onUpdateCheck(Main.plugin, Util.getPrefix(), Util.getSpigot(), 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 (PluginCheck.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, 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.");
|
|
plugin.getPluginLoader().disablePlugin(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() + ".");
|
|
plugin.getPluginLoader().disablePlugin(plugin);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|