190 lines
7.0 KiB
Java
190 lines
7.0 KiB
Java
package net.t2code.lib.Spigot.system;
|
|
|
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
|
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.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 T2CodeMain extends JavaPlugin {
|
|
|
|
public static File getPath() {
|
|
return plugin.getDataFolder();
|
|
}
|
|
|
|
public static BukkitAudiences adventure;
|
|
|
|
|
|
private static T2CodeMain plugin;
|
|
private static Economy eco = null;
|
|
private static Permission perm = null;
|
|
|
|
private static List<String> autor;
|
|
private static String version;
|
|
|
|
private static String prefix = Util.getPrefix();
|
|
private static Integer spigotID = Util.getSpigotID();
|
|
private static Integer bstatsID = Util.getBstatsID();
|
|
private static String spigot = Util.getSpigot();
|
|
private static String discord = Util.getDiscord();
|
|
|
|
private static Boolean load = false;
|
|
|
|
public static String getDiscord() {
|
|
return discord;
|
|
}
|
|
|
|
public static T2CodeMain getPlugin() {
|
|
return plugin;
|
|
}
|
|
|
|
public static Economy getEco() {
|
|
return eco;
|
|
}
|
|
|
|
static void setEco(Economy eco) {
|
|
T2CodeMain.eco = eco;
|
|
}
|
|
public static Permission getPerm() {
|
|
return perm;
|
|
}
|
|
|
|
public static List<String> getAutor() {
|
|
return autor;
|
|
}
|
|
|
|
public static String getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public static String getPrefix() {
|
|
return prefix;
|
|
}
|
|
|
|
public static Integer getSpigotID() {
|
|
return spigotID;
|
|
}
|
|
|
|
public static Integer getBstatsID() {
|
|
return bstatsID;
|
|
}
|
|
|
|
public static String getSpigot() {
|
|
return spigot;
|
|
}
|
|
|
|
public static Boolean getLoad() {
|
|
return load;
|
|
}
|
|
|
|
public static void setPerm(Permission perm) {
|
|
T2CodeMain.perm = perm;
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Plugin startup logic
|
|
plugin = this;
|
|
autor = plugin.getDescription().getAuthors();
|
|
version = plugin.getDescription().getVersion();
|
|
this.adventure = BukkitAudiences.create(this);
|
|
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();
|
|
}
|
|
}
|
|
|
|
try {
|
|
Vault.loadVault();
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
NMSVersion.onCheck();
|
|
MCVersion.onCheck();
|
|
if (MCVersion.minecraft1_19) {
|
|
send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
send.console(prefix );
|
|
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");
|
|
send.console(prefix);
|
|
send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
try {
|
|
Thread.sleep(5000);
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
ItemVersion.scan();
|
|
send.console(T2CodeMain.prefix + " §3Server run on: §6" + MCVersion.isVersion + " / " + NMSVersion.isNMS);
|
|
if (eco != null) {
|
|
String st = eco.getName();
|
|
if (eco.getName().equals("CMIEconomy")) st = "CMI";
|
|
if (Bukkit.getPluginManager().getPlugin(st) != null) {
|
|
send.console(T2CodeMain.prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
|
|
(System.currentTimeMillis() - long_) + "ms");
|
|
} else send.console(T2CodeMain.prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
} else send.console(T2CodeMain.prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
|
|
if (perm != null) {
|
|
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
|
|
send.console(T2CodeMain.prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
|
|
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
} else send.console(T2CodeMain.prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
} else send.console(T2CodeMain.prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
|
|
if (PluginCheck.papi()) {
|
|
send.console(T2CodeMain.prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
}
|
|
|
|
T2CodeMain.plugin.getCommand("t2code").setExecutor(new CmdExecuter());
|
|
ConfigCreate.configCreate();
|
|
LanguagesCreate.langCreate();
|
|
SelectLibConfig.onSelect();
|
|
SelectLibMsg.onSelect(prefix);
|
|
if (!Util.getSnapshot() || version.toLowerCase().contains("dev")) {
|
|
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.getInventoriesCloseByServerStop()) {
|
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
player.closeInventory();
|
|
}
|
|
}
|
|
if(this.adventure != null) {
|
|
this.adventure.close();
|
|
this.adventure = null;
|
|
}
|
|
Vault.vaultDisable();
|
|
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
|
|
}
|
|
}
|