dev 2
This commit is contained in:
parent
564288c9ab
commit
a0e590a2c1
8
pom.xml
8
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>13.4_DEV-1</version>
|
||||
<version>13.4_DEV-2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2CodeLib</name>
|
||||
@ -170,14 +170,14 @@
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20220924</version>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<scope>provided</scope>
|
||||
<version>4.5.13</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -82,26 +82,26 @@ public class T2Ctemplate {
|
||||
|
||||
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getTagName();
|
||||
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
|
||||
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
|
||||
boolean player = sender instanceof Player;
|
||||
|
||||
String stPlugin = "<dark_red>|</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
||||
String stVersion = "<dark_red>|</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
||||
String stAutor = "<dark_red>|</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
||||
String stNVersion = "<dark_red>|</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", publicVersion);
|
||||
String stStable = "<dark_red>|</dark_red> <yellow>Stable version available:</yellow> [up]".replace("[up]", update ? "<dark_green>YES</dark_green>" : "<red>no</red>");
|
||||
String stLinkPlayer = "<dark_red>|</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
||||
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
||||
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
||||
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
||||
String stNVersion = "<dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", publicVersion);
|
||||
String stStable = "<dark_red>║</dark_red> <yellow>Stable version available:</yellow> [up]".replace("[up]", update ? "<dark_green>YES</dark_green>" : "<red>no</red>");
|
||||
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
||||
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
||||
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
||||
.replace("[dlink]", discord);
|
||||
String stLinkConsole = "<dark_red>|</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
||||
+ "<br><dark_red>|</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
||||
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
||||
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
||||
String stLink = player ? stLinkPlayer : stLinkConsole;
|
||||
String pr = premiumVerified != null ? "<br><dark_red>|</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
||||
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
||||
|
||||
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>|</dark_red> " + text + "<br>";
|
||||
T2Csend.sender(sender, "<dark_red>---------------------</dark_red>"
|
||||
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text + "<br>";
|
||||
T2Csend.sender(sender, "<dark_red>╔══════════════════════════════════════</dark_red>"
|
||||
+ "<br>" + stPlugin
|
||||
+ stMSG
|
||||
+ stVersion
|
||||
@ -110,7 +110,7 @@ public class T2Ctemplate {
|
||||
+ "<br>" + stStable
|
||||
+ "<br>" + stLink
|
||||
+ pr
|
||||
+ "<br><dark_red>---------------------</dark_red>");
|
||||
+ "<br><dark_red>╚══════════════════════════════════════</dark_red>");
|
||||
}
|
||||
|
||||
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
|
||||
|
@ -2,7 +2,9 @@ package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.UpdateType;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -31,7 +33,7 @@ public class T2CupdateAPI {
|
||||
}
|
||||
T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
if (pluginVersion.equals(webData.getTagName())) return;
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -41,61 +43,133 @@ public class T2CupdateAPI {
|
||||
}
|
||||
|
||||
public static void sendUpdateMsg(String prefix, T2CupdateWebData webData, String discord, Plugin plugin, Player player) {
|
||||
String publicVersion = webData.getTagName();
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
if (publicVersion.equals("§4No public version found!")) {
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
return;
|
||||
}
|
||||
String st = "[prefix]<br>" +
|
||||
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <gold>A new</gold> [value]<gold>version was found!</gold></hover></click><br>" +
|
||||
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <red>[plv]</red> <gray>-></gray> <green>[puv]</green></hover></click><br>" +
|
||||
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <gold>A new</gold> [value] <gold>version was" +
|
||||
" found!</gold></hover></click><br>" +
|
||||
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <red>[plv]</red> <gray>-></gray> " +
|
||||
"<green>[puv]</green></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] <blue><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></blue><br>" +
|
||||
"[prefix]";
|
||||
String value = "";
|
||||
|
||||
String value;
|
||||
|
||||
if (webData.isPreRelease()) {
|
||||
value = "<light_purple>Pre-Release </light_purple>";
|
||||
value = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
value = "<dark_red>DEV </dark_red>";
|
||||
value = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
value = "<green>BETA </green>";
|
||||
value = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
value = "<yellow>SNAPSHOT </yellow>";
|
||||
value = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
}
|
||||
} else value = UpdateType.STABLE.text;
|
||||
|
||||
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", webData.getUpdateUrl())
|
||||
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
|
||||
}
|
||||
|
||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
|
||||
String publicVersion =webData.getTagName();
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
String value;
|
||||
if (webData.isPreRelease()) {
|
||||
value = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
value = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
value = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
value = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else value = UpdateType.STABLE.text;
|
||||
String h = "§4=========== " + prefix + " §4===========";
|
||||
String s1 = "";
|
||||
String s1 = "§6A new [value] version was found!§r".replace("[value]", value);
|
||||
String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion;
|
||||
String s3 = "§6You can download it here: §e" + webData.getUpdateUrl();
|
||||
String s4 = "§6You can find more information on Discord: §e" + discord;
|
||||
if (webData.isPreRelease()) {
|
||||
s1 = "§6A new §4Pre-Release§6 version was found!§r";
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
s1 = "§6A new §4DEV§6 version was found!§r";
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
s1 = "§6A new §2BETA§6 version was found!§r";
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
s1 = "§6A new §eSNAPSHOT§6 version was found!§r";
|
||||
}
|
||||
} else {
|
||||
s1 = "§6A new version was found!§r";
|
||||
}
|
||||
String text = "<br>" + h + "<br>" + s1 + "<br>" + s2 + "<br>" + s3 + "<br>" + s4 + "<br>" + h;
|
||||
T2Csend.console(text);
|
||||
}
|
||||
|
||||
public static void onUpdateCheck(Plugin plugin, String prefix, Integer spigotID, String discord) {
|
||||
public static String updateInfo(CommandSender sender, String[] args, Boolean player) {
|
||||
T2CupdateObject object;
|
||||
try {
|
||||
object = T2CupdateAPI.pluginVersions.get(args[1]);
|
||||
} catch (Exception e) {
|
||||
return "Das Plugin " + args[1] + " gibts net"; // todo
|
||||
}
|
||||
T2CupdateWebData webData = object.webData;
|
||||
String pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
|
||||
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
||||
|
||||
String updateTitle = webData.getUpdateTitle();
|
||||
String updateVersion = webData.getVersion();
|
||||
String updateType;
|
||||
|
||||
if (webData.isPreRelease()) {
|
||||
updateType = UpdateType.PRERELEASE.text;
|
||||
if (updateVersion.toLowerCase().contains("dev")) {
|
||||
updateType = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (updateVersion.toLowerCase().contains("beta")) {
|
||||
updateType = UpdateType.BETA.text;
|
||||
}
|
||||
if (updateVersion.toLowerCase().contains("snapshot")) {
|
||||
updateType = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else updateType = UpdateType.STABLE.text;
|
||||
|
||||
String updateAt = webData.getPublishedAt();
|
||||
String updateUpdate = webData.getUpdateUrl();
|
||||
String updateDescription = webData.getUpdateDescription();
|
||||
|
||||
String pluginNameString = "<br><dark_red>║</dark_red> <yellow>Plugin:</yellow> <color:#5eff89>" + pluginName + "</color>";
|
||||
String pluginVersionString = "<br><dark_red>║</dark_red> <yellow>Your version:</yellow> <color:#5eff89>" + pluginVersion + "</color>";
|
||||
String updateInfoString = "<br><dark_red>║</dark_red> <color:#308aff>[value]:</color>";
|
||||
String updateTitleString = "<br><dark_red>║</dark_red> <yellow>Title:</yellow> <color:#5eff89>" + updateTitle + "</color>";
|
||||
String updateVersionString = "<br><dark_red>║</dark_red> <yellow>Version:</yellow> <color:#5eff89>" + updateVersion + "</color>";
|
||||
String updateAtString = "<br><dark_red>║</dark_red> <yellow>Update at:</yellow> <color:#5eff89>" + updateAt + "</color>";
|
||||
String updateTypeString = "<br><dark_red>║</dark_red> <yellow>Update type:</yellow> <color:#5eff89>" + updateType + "</color>";
|
||||
|
||||
String updateButton;
|
||||
if (player) {
|
||||
// updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate +"'>Download</click></hover></color>";
|
||||
updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate + "'>Download</click></hover></color> <dark_gray>|</dark_gray> <blue><hover:show_text:'" + updateDescription + "'>Update Description</hover></blue>";
|
||||
} else updateButton = "<br><dark_red>║</dark_red> <color:#5eff89>Download:</color> <gold>" + updateUpdate + "</gold>";
|
||||
|
||||
String text;
|
||||
|
||||
text = "<dark_red>╔══════════════════════</dark_red>";
|
||||
text = text + pluginNameString;
|
||||
text = text + pluginVersionString;
|
||||
text = text + updateInfoString.replace("[value]", object.updateAvailable ? "Update available" : "Info about your version");
|
||||
if (!updateTitle.equals("OLD")) text = text + updateTitleString;
|
||||
if (object.updateAvailable) text = text + updateVersionString;
|
||||
if (!updateTitle.equals("OLD")) text = text + updateAtString;
|
||||
if (!updateTitle.equals("OLD")) text = text + updateTypeString;
|
||||
if (object.updateAvailable)
|
||||
text = text + updateButton;
|
||||
|
||||
if (updateTitle.equals("OLD")) text = text + "<br><dark_gray>This plugin does not have the new update checker yet, so there is no exact update / " +
|
||||
"version information available!</dark_gray>";
|
||||
|
||||
text = text + "<br><dark_red>╚══════════════════════</dark_red>";
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -105,10 +179,10 @@ public class T2CupdateAPI {
|
||||
plugin.getDescription().getVersion(),
|
||||
new T2CupdateWebData("OLD", update_version, "", "https://www.spigotmc.org/resources/" + spigotID, "",
|
||||
"https://www.spigotmc.org/resources/" + spigotID, false),
|
||||
false
|
||||
false, !plugin.getDescription().getVersion().equals(update_version)
|
||||
);
|
||||
pluginVersions.put(plugin.getName(), update);
|
||||
if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) {
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
if (!update.load) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@ -142,10 +216,11 @@ public class T2CupdateAPI {
|
||||
plugin.getName(),
|
||||
plugin.getDescription().getVersion(),
|
||||
webData,
|
||||
false
|
||||
false,
|
||||
!plugin.getDescription().getVersion().equals(webData.getVersion())
|
||||
);
|
||||
pluginVersions.put(plugin.getName(), update);
|
||||
if (!plugin.getDescription().getVersion().equalsIgnoreCase(webData.getTagName())) {
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
if (!update.load) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
@ -62,7 +62,8 @@ public class T2CupdateChecker {
|
||||
plugin.getName(),
|
||||
pluginVersion,
|
||||
null,
|
||||
load
|
||||
load,
|
||||
false
|
||||
);
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
|
||||
|
@ -8,6 +8,8 @@ import org.json.JSONObject;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class T2CupdateCheckerGit {
|
||||
@ -41,10 +43,16 @@ public class T2CupdateCheckerGit {
|
||||
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");
|
||||
String body = obj.getString("body").replace("\n","<br>").replace("\r","").replace("'","''");
|
||||
String updateurl = obj.getString("html_url");
|
||||
boolean prerelease = obj.getBoolean("prerelease");
|
||||
String published_at = obj.getString("published_at");
|
||||
|
||||
String date = obj.getString("published_at");
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
||||
Date parsedDate = inputFormat.parse(date);
|
||||
String formattedDate = outputFormat.format(parsedDate);
|
||||
|
||||
JSONArray downloadArray = obj.getJSONArray("assets");
|
||||
String downloadURL;
|
||||
if (downloadArray.isEmpty()) {
|
||||
@ -58,7 +66,7 @@ public class T2CupdateCheckerGit {
|
||||
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
}
|
||||
|
||||
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, published_at, downloadURL, prerelease);
|
||||
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, prerelease);
|
||||
consumer.accept(webData);
|
||||
} catch (Exception var10) {
|
||||
Boolean load = false;
|
||||
@ -69,7 +77,8 @@ public class T2CupdateCheckerGit {
|
||||
plugin.getName(),
|
||||
pluginVersion,
|
||||
null,
|
||||
load
|
||||
load,
|
||||
false
|
||||
);
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
|
||||
|
@ -7,14 +7,17 @@ public class T2CupdateObject {
|
||||
public String pluginVersion;
|
||||
public T2CupdateWebData webData;
|
||||
public Boolean load;
|
||||
public Boolean updateAvailable;
|
||||
|
||||
public T2CupdateObject(String pluginName,
|
||||
String pluginVersion,
|
||||
T2CupdateWebData webData,
|
||||
Boolean load) {
|
||||
Boolean load,
|
||||
Boolean updateAvailable) {
|
||||
this.pluginName = pluginName;
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.webData = webData;
|
||||
this.load = load;
|
||||
this.updateAvailable = updateAvailable;
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import lombok.Getter;
|
||||
|
||||
public class T2CupdateWebData {
|
||||
@Getter
|
||||
private String updateName;
|
||||
private String updateTitle;
|
||||
@Getter
|
||||
private String tagName;
|
||||
private String version;
|
||||
@Getter
|
||||
private String body;
|
||||
private String updateDescription;
|
||||
@Getter
|
||||
private String updateUrl;
|
||||
@Getter
|
||||
@ -18,10 +18,10 @@ public class T2CupdateWebData {
|
||||
@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;
|
||||
public T2CupdateWebData(String updateTitle, String version, String updateDescription, String updateUrl, String publishedAt, String downloadURL, boolean preRelease) {
|
||||
this.updateTitle = updateTitle;
|
||||
this.version = version;
|
||||
this.updateDescription = updateDescription;
|
||||
this.updateUrl = updateUrl;
|
||||
this.publishedAt = publishedAt;
|
||||
this.downloadURL = downloadURL;
|
||||
|
@ -10,6 +10,8 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
|
||||
import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
|
||||
@ -96,6 +98,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
||||
}
|
||||
|
||||
ReportLogStorage.load();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
||||
T2Ctemplate.onLoadFooter(prefix, long_);
|
||||
load = true;
|
||||
@ -105,6 +108,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (!load) return;
|
||||
ReportLogStorage.save();
|
||||
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.closeInventory();
|
||||
|
@ -0,0 +1,15 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
|
||||
public enum UpdateType {
|
||||
PRERELEASE("<light_purple>Pre-Release</light_purple>"),
|
||||
DEVELOPMENT("<dark_red>DEV</dark_red>"),
|
||||
BETA("<gold>BETA</gold>"),
|
||||
SNAPSHOT("<yellow>SNAPSHOT</yellow>"),
|
||||
STABLE("<dark_green>STABLE</dark_green>");
|
||||
|
||||
public String text;
|
||||
|
||||
UpdateType(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
@ -1,21 +1,19 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.CreateReportLog;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateObject;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
@ -26,7 +24,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
Commands.info(sender);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
@ -35,44 +33,16 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "pl":
|
||||
case "version":
|
||||
case "ver":
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
Commands.info(sender);
|
||||
return false;
|
||||
case "updateinfo":
|
||||
Commands.updateInfo(sender,args);
|
||||
return false;
|
||||
case "reloadconfig":
|
||||
SelectLibConfig.onSelect();
|
||||
return false;
|
||||
case "debug":
|
||||
if (args.length < 2) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return false;
|
||||
}
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "createreportlog":
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
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 {
|
||||
CreateReportLog.delete(args[2]);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
||||
break;
|
||||
}
|
||||
Commands.debug(sender,args);
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -86,6 +56,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
put("debug", "t2code.admin");
|
||||
put("info", "t2code.admin");
|
||||
put("reloadconfig", "t2code.admin");
|
||||
put("updateinfo", "t2code.admin");
|
||||
}};
|
||||
|
||||
@Override
|
||||
@ -103,9 +74,32 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
|
||||
list.add("createReportLog");
|
||||
list.add("deleteReportLog");
|
||||
if (hasPermission(p, arg1.get("debug"))) {
|
||||
if (passend("createReportLog",args[1])) list.add("createReportLog");
|
||||
if (passend("deleteReportLog",args[1])) list.add("deleteReportLog");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("updateinfo"))) {
|
||||
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()){
|
||||
if (passend(pl.getValue().pluginName,args[1])) list.add(pl.getValue().pluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
if (args.length == 3 && args[0].equalsIgnoreCase("debug")&& args[1].equalsIgnoreCase("deleteReportLog")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("debug"))) {
|
||||
for (String st : ReportLogStorage.list){
|
||||
String[] string = st.split(" - ");
|
||||
if (passend(st,args[2])) list.add(string[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
@ -0,0 +1,60 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateObject;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.UpdateType;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Commands {
|
||||
public static void info(CommandSender sender) {
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
}
|
||||
|
||||
public static void debug(CommandSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return;
|
||||
}
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "createreportlog":
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
try {
|
||||
CreateReportLog.delete(args[2]);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateInfo(CommandSender sender, String[] args) {
|
||||
T2Csend.sender(sender, T2CupdateAPI.updateInfo(sender, args, sender instanceof Player));
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.luckyBox.api.LuckyBoxAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.Vault;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
@ -146,11 +148,14 @@ public class CreateReportLog {
|
||||
String fileType = obj.getString("fileType");
|
||||
Integer fileSize = obj.getInt("size");
|
||||
zipFile.delete();
|
||||
directory.delete();
|
||||
if (sender instanceof Player) {
|
||||
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));
|
||||
System.out.println(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 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 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));
|
||||
|
||||
ReportLogStorage.add(fileID +" - "+downloadURL);
|
||||
}
|
||||
|
||||
private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException {
|
||||
@ -221,5 +226,6 @@ public class CreateReportLog {
|
||||
URL url = new URL("https://debug.t2code.net/delte/" + arg);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
ReportLogStorage.remove(arg);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReportLogStorage {
|
||||
public static List<String> list = new ArrayList<>();
|
||||
|
||||
protected static File config = new File("T2CodeReportKeys.yml");
|
||||
protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
public static void add(String key){
|
||||
list.add(key);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void remove(String key){
|
||||
list.remove(key);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void save(){
|
||||
if (list.isEmpty()) return;
|
||||
yamlConfiguration.set("Keys",list);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(){
|
||||
if (!config.exists()) return;
|
||||
list = yamlConfiguration.getStringList("Keys");
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ public class Util {
|
||||
public static Integer getSpigotID() {
|
||||
return 96388;
|
||||
}
|
||||
|
||||
public static String getGit() {
|
||||
return "https://git.t2code.net/api/v1/repos/JaTiTV/T2CodeLib/releases?limit=1";
|
||||
}
|
||||
@ -38,7 +39,7 @@ public class Util {
|
||||
"T2C-LuckyBox",
|
||||
"WonderBagShop",
|
||||
"CommandGUI",
|
||||
// "T2C-OPSecurity",
|
||||
// "T2C-OPSecurity",
|
||||
"OPSecurity",
|
||||
"PaPiTest",
|
||||
"T2C-Alias",
|
||||
|
Loading…
Reference in New Issue
Block a user