When joining the server, it could happen that an error occurred, because the UpdateChecker had not yet checked the public version.
131 lines
6.1 KiB
Java
131 lines
6.1 KiB
Java
package net.t2code.lib.Spigot.system;
|
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
import net.milkbowl.vault.permission.Permission;
|
|
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
|
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
|
|
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
|
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
|
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
import net.t2code.lib.Spigot.Lib.vault.Vault;
|
|
import net.t2code.lib.Spigot.system.config.ConfigCreate;
|
|
import net.t2code.lib.Spigot.system.languages.LanguagesCreate;
|
|
import net.t2code.lib.Util;
|
|
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
|
|
import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.io.File;
|
|
import java.util.List;
|
|
|
|
public final class Main extends JavaPlugin {
|
|
|
|
public static File getPath() {
|
|
return plugin.getDataFolder();
|
|
}
|
|
|
|
public static Main plugin;
|
|
public static Economy eco = null;
|
|
public static Permission perm = null;
|
|
|
|
public static List<String> autor;
|
|
public static String version;
|
|
|
|
public static String prefix = Util.getPrefix();
|
|
public static Integer spigotID = Util.getSpigotID();
|
|
public static Integer bstatsID = Util.getBstatsID();
|
|
public static String spigot = Util.getSpigot();
|
|
public static String discord = Util.getDiscord();
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Plugin startup logic
|
|
plugin = this;
|
|
autor = plugin.getDescription().getAuthors();
|
|
version = plugin.getDescription().getVersion();
|
|
Long long_;
|
|
long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
|
if (Util.getSnapshot()){
|
|
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
|
|
send.console(prefix + " §4 §e-------------------");
|
|
try {
|
|
Thread.sleep(5000);
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
//send.console("§4 _|_|_|_|_| _|_| _|_|_| _| ");
|
|
//send.console("§4 _| _| _| _| _|_| _|_|_| _|_| ");
|
|
//send.console("§4 _| _| _| _| _| _| _| _|_|_|_| ");
|
|
//send.console("§4 _| _| _| _| _| _| _| _| ");
|
|
//send.console("§4 _| _|_|_|_| _|_|_| _|_| _|_|_| _|_|_| ");
|
|
//T2CodeTemplate.onLoadSeparateStroke(prefix);
|
|
try {
|
|
Vault.loadVault();
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
NMSVersion.onCheck();
|
|
MCVersion.onCheck();
|
|
if (MCVersion.minecraft1_19){
|
|
send.warning(this, "The 1.19 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
|
|
try {
|
|
Thread.sleep(5000);
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
ItemVersion.scan();
|
|
send.console(Main.prefix + " §3Server run on: §6" + MCVersion.isVersion + " / " + NMSVersion.isNMS);
|
|
if (eco != null) {
|
|
String st;
|
|
st = eco.getName();
|
|
if (eco.getName().equals("CMIEconomy")) st = "CMI";
|
|
if (Bukkit.getPluginManager().getPlugin(st) != null){
|
|
send.console(Main.prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
} else send.console(Main.prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
} else send.console(Main.prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
|
|
if (perm != null) {
|
|
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null){
|
|
send.console(Main.prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
} else send.console(Main.prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
} else send.console(Main.prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
if (PluginCheck.pluginCheck("PlaceholderAPI")) {
|
|
send.console(Main.prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
|
|
}
|
|
|
|
|
|
Main.plugin.getCommand("t2code").setExecutor(new CmdExecuter());
|
|
ConfigCreate.configCreate();
|
|
LanguagesCreate.langCreate();
|
|
SelectLibConfig.onSelect();
|
|
SelectLibMsg.onSelect(prefix);
|
|
if (!Util.getSnapshot()){
|
|
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
|
Metrics.Bstats(plugin, bstatsID);
|
|
}
|
|
|
|
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
|
T2CodeTemplate.onLoadFooter(prefix, long_);
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Plugin shutdown logic
|
|
if (SelectLibConfig.InventoriesCloseByServerStop){
|
|
for (Player player : Bukkit.getOnlinePlayers()){
|
|
player.closeInventory();
|
|
}
|
|
}
|
|
Vault.vaultDisable();
|
|
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
|
|
}
|
|
}
|