Compare commits

...

13 Commits
15.4 ... 15.7

Author SHA1 Message Date
c72edafd0a 15.7
- Bugfix: If a t2code plugin could not be checked for an update, it was not possible to use the info command of the respective plugin and the command '/t2c updateinfo <plugin>'.

- The message at the command '/t2code updatinfo <plugin>' was slightly adjusted
2023-07-10 03:35:06 +02:00
610cb74868 Update T2CitemBuilder.java 2023-07-09 17:01:07 +02:00
JaTiTV
3a3c9b3208 Merge pull request 'Update T2CitemBuilder.java' (#21) from 15.6 into development
Reviewed-on: #21
2023-07-09 14:35:52 +00:00
a834adc8c9 Update T2CitemBuilder.java 2023-07-09 16:35:17 +02:00
290b9264f3 final 15.6 2023-07-09 16:19:05 +02:00
eb991d01e3 15.6_beta-1 2023-07-08 22:48:02 +02:00
ec7714c9fe Update T2CitemBuilder.java 2023-07-08 21:30:09 +02:00
260dae2aa0 Update pom.xml 2023-07-08 21:29:36 +02:00
addc485ca8 Update T2Creplace.java
Fixed error when PlaceholderAPI is not installed
2023-07-08 21:29:30 +02:00
f8619e4802 Update pom.xml 2023-07-08 19:42:52 +02:00
e97fadfbec Update T2Creplace.java
add  public static Object replace(Object object,String placeholder,String replacement)
2023-07-08 19:42:48 +02:00
567b0a2442 fix ItemStack names 2023-07-08 19:42:33 +02:00
7b04697895 15.6_dev-1 2023-07-08 19:03:29 +02:00
11 changed files with 224 additions and 137 deletions

View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.4</version>
<version>15.7</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->

View File

@@ -50,20 +50,20 @@ public class T2CBupdateCheckerGit {
return;
}
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String updateTitle = obj.getString("name");
String version = obj.getString("tag_name");
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
String updateUrl = obj.getString("html_url");
boolean preRelease = obj.getBoolean("prerelease");
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);
String publishedAt = outputFormat.format(parsedDate);
JSONArray downloadArray = obj.getJSONArray("assets");
String gitURL = updateurl;
String gitURL = updateUrl;
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
@@ -71,12 +71,12 @@ public class T2CBupdateCheckerGit {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!prerelease) {
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
Boolean load = false;

View File

@@ -52,6 +52,20 @@ public class T2CitemBuilder {
return itemStack;
}
public static void setItem(Integer slot, Integer amount, String material, String displayName, List<String> lore, Inventory inventory) {
ItemStack item;
if (getLegacy && material.contains(",")) {
String[] split = material.split(",");
item = new ItemStack(Material.valueOf(split[0]), 1, Short.parseShort(split[1]));
} else item = new ItemStack(Material.valueOf(material));
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
item.setAmount(amount);
inventory.setItem(slot, item);
}
public static ItemStack base64(String base64Value, Integer amount, String displayName, List<String> lore) {
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();

View File

@@ -1,76 +1,54 @@
package net.t2code.t2codelib.SPIGOT.api.items;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class T2CitemVersion {
@Getter
private static Material Head;
@Getter
private static ItemStack HeadIS;
private static ItemStack CRAFTING_TABLE;
private static ItemStack YELLOW_WOOL;
private static ItemStack ORANGE_WOOL;
private static ItemStack GREEN_WOOL;
private static ItemStack GRAY_WOOL;
private static ItemStack RED_WOOL;
private static ItemStack RED_STAINED_GLASS_PANE;
@Getter
private static ItemStack CraftingTable;
@Getter
private static ItemStack YellowWool;
@Getter
private static ItemStack OrangeWool;
@Getter
private static ItemStack GreenWool;
@Getter
private static ItemStack GrayWool;
@Getter
private static ItemStack RedWool;
@Getter
private static ItemStack RedStainedGlassPane;
@Getter
private static ItemStack BlackStainedGlassPane;
public static void scan() {
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
Head = Material.valueOf("SKULL_ITEM");
YELLOW_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
ORANGE_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
GREEN_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 5);
GRAY_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 8);
RED_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 14);
RED_STAINED_GLASS_PANE = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 14);
CRAFTING_TABLE = new ItemStack(Material.valueOf("WORKBENCH"));
YellowWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
OrangeWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
GreenWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 5);
GrayWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 8);
RedWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 14);
RedStainedGlassPane = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 14);
BlackStainedGlassPane = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 15);
CraftingTable = new ItemStack(Material.valueOf("WORKBENCH"));
} else {
Head = Material.valueOf("PLAYER_HEAD");
CRAFTING_TABLE = new ItemStack(Material.CRAFTING_TABLE);
YELLOW_WOOL = new ItemStack(Material.YELLOW_WOOL);
ORANGE_WOOL = new ItemStack(Material.ORANGE_WOOL);
GREEN_WOOL = new ItemStack(Material.GREEN_WOOL);
GRAY_WOOL = new ItemStack(Material.GRAY_WOOL);
RED_WOOL = new ItemStack(Material.RED_WOOL);
RED_STAINED_GLASS_PANE = new ItemStack(Material.RED_STAINED_GLASS_PANE);
CraftingTable = new ItemStack(Material.CRAFTING_TABLE);
YellowWool = new ItemStack(Material.YELLOW_WOOL);
OrangeWool = new ItemStack(Material.ORANGE_WOOL);
GreenWool = new ItemStack(Material.GREEN_WOOL);
GrayWool = new ItemStack(Material.GRAY_WOOL);
RedWool = new ItemStack(Material.RED_WOOL);
RedStainedGlassPane = new ItemStack(Material.RED_STAINED_GLASS_PANE);
BlackStainedGlassPane = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
}
HeadIS = new ItemStack(Head, 1, (byte) 3);
}
public static Material getHead() {
return Head;
}
public static ItemStack getHeadIS() {
return HeadIS;
}
public static ItemStack getCraftingTable() {
return CRAFTING_TABLE;
}
public static ItemStack getYellowWool() {
return YELLOW_WOOL;
}
public static ItemStack getOrangeWool() {
return ORANGE_WOOL;
}
public static ItemStack getGreenWool() {
return GREEN_WOOL;
}
public static ItemStack getGrayWool() {
return GRAY_WOOL;
}
public static ItemStack getRedWool() {
return RED_WOOL;
}
public static ItemStack getRedStainedGlassPane() {
return RED_STAINED_GLASS_PANE;
}
}

View File

@@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@@ -17,10 +18,16 @@ public class T2Creplace {
}
public static String replace(String prefix, Player player, String Text) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
.replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static Object replaceObject(String prefix, Object object) {
@@ -46,18 +53,33 @@ public class T2Creplace {
public static Object replaceObject(String prefix, Player player, Object object) {
if (object instanceof String) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
if (T2CpluginCheck.papi()) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
} else {
object = replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
}
}
if (object instanceof List) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
object = output;
}
@@ -84,10 +106,18 @@ public class T2Creplace {
return Collections.singletonList("Text is null");
}
for (String input : Text) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
return output;
}
@@ -115,10 +145,15 @@ public class T2Creplace {
public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) {
List<String> rp = new ArrayList<>();
for (String s : Text) {
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix)
String input = s.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n")
.replace("[price]", String.valueOf(price)))));
.replace("[price]", String.valueOf(price));
if (T2CpluginCheck.papi()) {
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input)));
} else {
rp.add(replaceLegacyColor(input));
}
}
return rp;
}
@@ -132,10 +167,16 @@ public class T2Creplace {
}
public static String replacePrice(String prefix, Player player, String Text, String price) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n")));
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static String replaceLegacyColor(String text) {
@@ -171,4 +212,19 @@ public class T2Creplace {
.replace("&o", "<italic>").replace("§o", "<italic>")
.replace("&r", "<reset>").replace("§r", "<reset>");
}
public static Object replace(Object object, String placeholder, String replacement) {
if (object instanceof String) {
object = ((String) object).replace(placeholder, replacement);
}
if ((object instanceof List) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(input.replace(placeholder, replacement));
}
object = output;
}
return object;
}
}

View File

@@ -2,6 +2,8 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -46,7 +48,7 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" +
" bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
onLoadSeparateStroke(prefix);
if (!SelectLibConfig.getT2cTestDevelopment()){
if (!SelectLibConfig.getT2cTestDevelopment()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
@@ -68,6 +70,10 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §8-------------------------------");
}
public static void onLoadFooter(String prefix, Long long_, String v) {
onLoadFooter(prefix, long_);
}
public static void onLoadFooter(String prefix, Long long_) {
onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
@@ -78,16 +84,14 @@ public class T2Ctemplate {
* @param autor
* @param spigot
* @param discord
*
* @deprecated reason this method is deprecated <br/>
* {will be removed in next version} <br/>
* use {@link #onDisable(Plugin)} instead like this:
* @deprecated reason this method is deprecated <br/>
* {will be removed in next version} <br/>
* use {@link #onDisable(String, Plugin)} instead like this:
*
*
* <blockquote><pre>
* onDisable(getPlugin())
* </pre></blockquote>
*
*/
@Deprecated
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
@@ -105,15 +109,32 @@ 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.getVersion();
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
boolean player = sender instanceof Player;
String publicVersion = "";
boolean update;
String stNVersion;
T2CupdateWebData webData;
try {
webData = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData;
} catch (Exception ex) {
webData = null;
}
if (webData != null) {
publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
update = !publicVersion.equalsIgnoreCase(pluginVersion);
} else {
update = false;
}
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 stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
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>"
@@ -121,16 +142,17 @@ public class T2Ctemplate {
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;
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ "<br>" + stVersion
+ stMSG
+ stVersion
+ "<br>" + stAutor
+ "<br>" + stNVersion
+ "<br>" + stStable
+ "<br>" + stUpdate
+ stNVersion
+ "<br>" + stLink
+ pr
+ "<br><dark_red>╚════════════════════════════════</dark_red>");

View File

@@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -68,44 +69,44 @@ public class T2CupdateAPI {
"[prefix] <color:#ff9499><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></color><br>" +
"[prefix]";
String value;
String updateStatusVersion;
if (webData.isPreRelease()) {
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
value = UpdateType.PRERELEASE.text;
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
} else updateStatusVersion = UpdateType.STABLE.text;
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", webData.getUpdateUrl())
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).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.getVersion();
String pluginVersion = plugin.getDescription().getVersion();
String value;
String updateStatusVersion;
if (webData.isPreRelease()) {
value = UpdateType.PRERELEASE.text;
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
} else updateStatusVersion = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", value);
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
String s2 = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
@@ -119,9 +120,13 @@ public class T2CupdateAPI {
try {
object = T2CupdateAPI.pluginVersions.get(args[1]);
} catch (Exception e) {
return "Das Plugin " + args[1] + " gibts net"; // todo
return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
}
if (object == null) return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
T2CupdateWebData webData = object.webData;
if (webData == null) {
return Util.getPrefix() + " <b><dark_red>It could not be checked for updates with the plugin <yellow>" + args[1] + "</yellow>!</dark_red></b>";
}
String pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
@@ -162,7 +167,7 @@ public class T2CupdateAPI {
String text;
text = "<dark_red>╔══════════════════════</dark_red>";
text = "<br><dark_red>╔══════════════════════</dark_red>";
text = text + pluginNameString;
text = text + pluginVersionString;
text = text + updateInfoString.replace("[value]", object.updateAvailable ? "Update available" : "Info about your version");

View File

@@ -15,6 +15,7 @@ import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.function.Consumer;
@@ -33,7 +34,7 @@ public class T2CupdateCheckerGit {
String finalRepoURL = RepoURL;
Integer finalInterval;
if (timeInterval < 1){
if (timeInterval < 1) {
finalInterval = 1;
} else finalInterval = timeInterval;
@@ -98,19 +99,19 @@ public class T2CupdateCheckerGit {
return;
}
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String updateTitle = obj.getString("name");
String version = obj.getString("tag_name");
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateUrl = obj.getString("html_url");
boolean preRelease = obj.getBoolean("prerelease");
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);
String publishedAt = outputFormat.format(parsedDate);
String gitURL = updateurl;
String gitURL = updateUrl;
JSONArray downloadArray = obj.getJSONArray("assets");
String downloadURL;
if (downloadArray.isEmpty()) {
@@ -119,14 +120,14 @@ public class T2CupdateCheckerGit {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!prerelease) {
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
} catch (Exception exception) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
@@ -140,7 +141,9 @@ public class T2CupdateCheckerGit {
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
exception.printStackTrace();
}
});
}

View File

@@ -52,6 +52,13 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
}
Commands.updateInfo(sender, args);
return false;
// case "plugininfo": todo
// if (!sender.hasPermission("t2code.admin")) {
// T2Csend.sender(sender, "§4No Permission §8t2code.admin");
// return false;
// }
// Commands.updateInfo(sender, args);
// return false;
case "reloadconfig":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
@@ -74,10 +81,11 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
}
Commands.test(sender, args);
return false;
case "serverid":if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
case "serverid":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID())));
return false;

View File

@@ -1,6 +1,7 @@
package net.t2code.t2codelib;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import java.util.Arrays;
import java.util.List;
@@ -13,7 +14,7 @@ public class Util {
public static String getInfoText() {
return "";
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
}
public static String getPrefix() {

View File

@@ -3,7 +3,7 @@ version: '${project.version}'
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
api-version: 1.13
prefix: T2CodeLib
authors: [ JaTiTV, Jkobs ]
authors: [ JaTiTV ]
description: Library from T2Code Plugins
website: https://spigotmc.org/resources/96388/
load: STARTUP