Merge pull request 'NewDebugZip' (#11) from NewDebugZip into 13.3

Reviewed-on: #11
This commit is contained in:
JaTiTV 2022-11-13 15:31:20 +00:00
commit ed16dc160b
11 changed files with 274 additions and 43 deletions

20
pom.xml
View File

@ -147,5 +147,25 @@
<artifactId>adventure-platform-bukkit</artifactId> <artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,5 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.messages; package net.t2code.t2codelib.SPIGOT.api.messages;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
@ -8,17 +9,18 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class T2CminiMessage { public class T2CminiMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void miniMessage(String msg, CommandSender sender) { public static void miniMessage(String msg, CommandSender sender) {
T2CodeLibMain.adventure().sender(sender).sendMessage(replace(msg)); bukkitAudiences.sender(sender).sendMessage(replace(msg));
} }
public static void sendMiniMessage(String msg) { public static void sendMiniMessage(String msg) {
T2CodeLibMain.adventure().console().sendMessage(replace(msg)); bukkitAudiences.console().sendMessage(replace(msg));
} }
public static void miniMessage(String msg, Player player) { public static void miniMessage(String msg, Player player) {
T2CodeLibMain.adventure().player(player).sendMessage(replace(msg)); bukkitAudiences.player(player).sendMessage(replace(msg));
} }
protected static Component replace(String text) { protected static Component replace(String text) {

View File

@ -82,7 +82,7 @@ public class T2Ctemplate {
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) { public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).publicVersion; String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getTagName();
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion); boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
boolean player = sender instanceof Player; boolean player = sender instanceof Player;

View File

@ -29,19 +29,19 @@ public class T2CupdateAPI {
}.runTaskLaterAsynchronously(plugin, 20L); }.runTaskLaterAsynchronously(plugin, 20L);
return; return;
} }
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion; T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
if (pluginVersion.equals(publicVersion)) return; if (pluginVersion.equals(webData.getTagName())) return;
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
sendUpdateMsg(prefix, spigotID, discord, plugin, player); sendUpdateMsg(prefix, webData, discord, plugin, player);
} }
}.runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), 200L); }.runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), 200L);
} }
public static void sendUpdateMsg(String prefix, Integer spigotID, String discord, Plugin plugin, Player player) { public static void sendUpdateMsg(String prefix, T2CupdateWebData webData, String discord, Plugin plugin, Player player) {
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion; String publicVersion = webData.getTagName();
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
if (publicVersion.equals("§4No public version found!")) { if (publicVersion.equals("§4No public version found!")) {
return; return;
@ -52,7 +52,9 @@ public class T2CupdateAPI {
"<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <gold>You can find more information on Discord.</gold></hover></click><br>" + "<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <gold>You can find more information on Discord.</gold></hover></click><br>" +
"[prefix]"; "[prefix]";
String value = ""; String value = "";
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
if (webData.isPreRelease()) {
value = "<light_purple>Pre-Release </light_purple>";
if (publicVersion.toLowerCase().contains("dev")) { if (publicVersion.toLowerCase().contains("dev")) {
value = "<dark_red>DEV </dark_red>"; value = "<dark_red>DEV </dark_red>";
} }
@ -63,19 +65,20 @@ public class T2CupdateAPI {
value = "<yellow>SNAPSHOT </yellow>"; value = "<yellow>SNAPSHOT </yellow>";
} }
} }
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", "https://www.spigotmc.org/resources/" + spigotID) T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", webData.getUpdateUrl())
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord)); .replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
} }
public static void sendUpdateMsg(String prefix, Integer spigot, String discord, Plugin plugin) { public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion; String publicVersion =webData.getTagName();
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
String h = "§4=========== " + prefix + " §4==========="; String h = "§4=========== " + prefix + " §4===========";
String s1 = ""; String s1 = "";
String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion; String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion;
String s3 = "§6You can download it here: §ehttps://www.spigotmc.org/resources/" + spigot; String s3 = "§6You can download it here: §e" + webData.getUpdateUrl();
String s4 = "§6You can find more information on Discord: §e" + discord; String s4 = "§6You can find more information on Discord: §e" + discord;
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { if (webData.isPreRelease()) {
s1 = "§6A new §4Pre-Release§6 version was found!§r";
if (publicVersion.toLowerCase().contains("dev")) { if (publicVersion.toLowerCase().contains("dev")) {
s1 = "§6A new §4DEV§6 version was found!§r"; s1 = "§6A new §4DEV§6 version was found!§r";
} }
@ -92,7 +95,7 @@ public class T2CupdateAPI {
T2Csend.console(text); T2Csend.console(text);
} }
public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) { public static void onUpdateCheck(Plugin plugin, String prefix, Integer spigotID, String discord) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -100,7 +103,8 @@ public class T2CupdateAPI {
T2CupdateObject update = new T2CupdateObject( T2CupdateObject update = new T2CupdateObject(
plugin.getName(), plugin.getName(),
plugin.getDescription().getVersion(), plugin.getDescription().getVersion(),
update_version, new T2CupdateWebData("OLD", update_version, "", "https://www.spigotmc.org/resources/" + spigotID, "",
"https://www.spigotmc.org/resources/" + spigotID, false),
false false
); );
pluginVersions.put(plugin.getName(), update); pluginVersions.put(plugin.getName(), update);
@ -110,12 +114,12 @@ public class T2CupdateAPI {
@Override @Override
public void run() { public void run() {
update.load = true; update.load = true;
sendUpdateMsg(prefix, spigotID, discord, plugin); sendUpdateMsg(prefix, discord, update.webData, plugin);
} }
}.runTaskLaterAsynchronously(plugin, 600L); }.runTaskLaterAsynchronously(plugin, 600L);
} else sendUpdateMsg(prefix, spigotID, discord, plugin); } else sendUpdateMsg(prefix, discord, update.webData, plugin);
} else { } else {
if (!update.load){ if (!update.load) {
T2Csend.console(prefix + " §2No update found."); T2Csend.console(prefix + " §2No update found.");
update.load = true; update.load = true;
} }
@ -124,4 +128,41 @@ public class T2CupdateAPI {
} }
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L); }.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
} }
public static void onUpdateCheck(Plugin plugin, String prefix, String RepoURL, Integer spigotID, String discord) {
if (!RepoURL.contains("?limit=1")) {
RepoURL = RepoURL + "?limit=1";
}
String finalRepoURL = RepoURL;
new BukkitRunnable() {
@Override
public void run() {
(new T2CupdateCheckerGit((JavaPlugin) plugin)).getVersion((webData) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
webData,
false
);
pluginVersions.put(plugin.getName(), update);
if (!plugin.getDescription().getVersion().equalsIgnoreCase(webData.getTagName())) {
if (!update.load) {
new BukkitRunnable() {
@Override
public void run() {
update.load = true;
sendUpdateMsg(prefix, discord, webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
} else sendUpdateMsg(prefix, discord, webData, plugin);
} else {
if (!update.load) {
T2Csend.console(prefix + " §2No update found.");
update.load = true;
}
}
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL);
}
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
}
} }

View File

@ -0,0 +1,80 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.function.Consumer;
public class T2CupdateCheckerGit {
private JavaPlugin plugin;
public T2CupdateCheckerGit(JavaPlugin plugin) {
this.plugin = plugin;
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL) {
if (!plugin.isEnabled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
URL url = new URL(URL);
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
String data = "";
while ((inputLine = in.readLine()) != null)
data = inputLine;
in.close();
data = data.substring(1, data.length() - 1);
if (data.isEmpty()) {
consumer.accept(null);
return;
}
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body");
String updateurl = obj.getString("url");
boolean prerelease = obj.getBoolean("prerelease");
String published_at = obj.getString("published_at");
JSONArray downloadArray = obj.getJSONArray("assets");
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
} else {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!prerelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, published_at, downloadURL, prerelease);
consumer.accept(webData);
} catch (Exception var10) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
}
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
pluginVersion,
null,
load
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@ -5,16 +5,16 @@ public class T2CupdateObject {
public String pluginName; public String pluginName;
public String pluginVersion; public String pluginVersion;
public String publicVersion; public T2CupdateWebData webData;
public Boolean load; public Boolean load;
public T2CupdateObject(String pluginName, public T2CupdateObject(String pluginName,
String pluginVersion, String pluginVersion,
String publicVersion, T2CupdateWebData webData,
Boolean load) { Boolean load) {
this.pluginName = pluginName; this.pluginName = pluginName;
this.pluginVersion = pluginVersion; this.pluginVersion = pluginVersion;
this.publicVersion = publicVersion; this.webData = webData;
this.load = load; this.load = load;
} }
} }

View File

@ -0,0 +1,31 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import lombok.Getter;
public class T2CupdateWebData {
@Getter
private String updateName;
@Getter
private String tagName;
@Getter
private String body;
@Getter
private String updateUrl;
@Getter
private String publishedAt;
@Getter
private String downloadURL;
@Getter
private boolean preRelease;
public T2CupdateWebData(String updateName, String tagName, String body, String updateUrl, String publishedAt, String downloadURL, boolean preRelease) {
this.updateName = updateName;
this.tagName = tagName;
this.body = body;
this.updateUrl = updateUrl;
this.publishedAt = publishedAt;
this.downloadURL = downloadURL;
this.preRelease = preRelease;
}
}

View File

@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -25,7 +26,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
return false; return false;
} }
if (args.length == 0) { if (args.length == 0) {
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText()); T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
return false; return false;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
@ -34,24 +35,44 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "pl": case "pl":
case "version": case "version":
case "ver": case "ver":
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText()); T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
return false; return false;
case "reloadconfig": case "reloadconfig":
SelectLibConfig.onSelect(); SelectLibConfig.onSelect();
return false; return false;
case "debug": case "debug":
if (args.length != 2) { if (args.length < 2) {
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog"); T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false; return false;
} }
if ("createreportlog".equals(args[1].toLowerCase())) { switch (args[1].toLowerCase()) {
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() { case "createreportlog":
@Override Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
public void run() { @Override
CreateReportLog.create(sender); public void run() {
try {
CreateReportLog.create(sender);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
break;
case "deleteReportLog":
if (args.length != 3) {
T2Csend.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
return false;
} }
}); try {
} else T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog"); CreateReportLog.delete(args[2]);
} catch (IOException e) {
throw new RuntimeException(e);
}
break;
default:
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
break;
}
return false; return false;
default: default:
@ -84,6 +105,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (sender.hasPermission("t2code.admin")) { if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) { if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
list.add("createReportLog"); list.add("createReportLog");
list.add("deleteReportLog");
} }
} }
return list; return list;

View File

@ -5,13 +5,23 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.json.JSONObject;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -19,7 +29,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
public class CreateReportLog { public class CreateReportLog {
protected static void create(CommandSender sender) { protected static void create(CommandSender sender) throws IOException {
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog is created..."); T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog is created...");
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime()); String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
@ -120,10 +130,26 @@ public class CreateReportLog {
e.printStackTrace(); e.printStackTrace();
} }
file.delete(); file.delete();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://debug.t2code.net/uploadFile");
File zipFile = new File(zipPath);
FileBody bin = new FileBody(zipFile);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("file", bin);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
String responseString = EntityUtils.toString(resEntity, "UTF-8");
JSONObject obj = new JSONObject(responseString);
String downloadURL = obj.getString("fileDownloadUri");
String fileID = obj.getString("fileID");
String fileType = obj.getString("fileType");
Integer fileSize = obj.getInt("size");
zipFile.delete();
if (sender instanceof Player) { if (sender instanceof Player) {
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath); T2Csend.sender(sender, Util.getPrefix() + "<green>A DebugLog zip has been created. You can download it <click:open_url:'url'><gold>here</gold></click>. Please enter the following key in the ticket: <gold>key</gold></green><br><dark_red>Do not share the download URL with anyone!</dark_red><br><click:run_command:'/t2code debug deleteReportLog key'><green>You can <b>delte </b>yor Debug-File by clicking me.</green></click>".replace("key",fileID).replace("url",downloadURL));
T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath); T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. You can download it here: url.\n§6Please enter the following key in the ticket: §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog key.".replace("[key]",fileID).replace("url",downloadURL));
} else T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath); } else T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. You can download it here: url.\n§6Please enter the following key in the ticket: §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog key.".replace("[key]",fileID).replace("url",downloadURL));
} }
@ -190,4 +216,10 @@ public class CreateReportLog {
} }
} }
} }
public static void delete(String arg) throws IOException {
URL url = new URL("https://debug.t2code.net/delte/" + arg);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
}
} }

View File

@ -39,7 +39,7 @@ public final class T2CodeLibMain extends JavaPlugin {
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
this.adventure = BukkitAudiences.create(this); adventure = BukkitAudiences.create(this);
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
String prefix = Util.getPrefix(); String prefix = Util.getPrefix();
@ -90,9 +90,9 @@ public final class T2CodeLibMain extends JavaPlugin {
SelectLibConfig.onSelect(); SelectLibConfig.onSelect();
SelectLibMsg.onSelect(); SelectLibMsg.onSelect();
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getSpigotID(), Util.getDiscord()); T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord());
Metrics.Bstats(plugin, Util.getBstatsID()); Metrics.Bstats(plugin, Util.getBstatsID());
if (SelectLibConfig.getBungee()){ if (SelectLibConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
} }
@ -155,7 +155,7 @@ public final class T2CodeLibMain extends JavaPlugin {
private static BukkitAudiences adventure; private static BukkitAudiences adventure;
public static BukkitAudiences adventure() { public BukkitAudiences getAdventure() {
if (adventure == null) { if (adventure == null) {
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!"); throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
} }

View File

@ -16,6 +16,9 @@ public class Util {
public static Integer getSpigotID() { public static Integer getSpigotID() {
return 96388; return 96388;
} }
public static String getGit() {
return "https://git.t2code.net/api/v1/repos/JaTiTV/T2CodeLib/releases?limit=1";
}
public static Integer getBstatsID() { public static Integer getBstatsID() {
return 12518; return 12518;
@ -35,7 +38,7 @@ public class Util {
"T2C-LuckyBox", "T2C-LuckyBox",
"WonderBagShop", "WonderBagShop",
"CommandGUI", "CommandGUI",
"T2C-OPSecurity", // "T2C-OPSecurity",
"OPSecurity", "OPSecurity",
"PaPiTest", "PaPiTest",
"T2C-Alias", "T2C-Alias",