Compare commits

...

3 Commits
13.4 ... 13.9

Author SHA1 Message Date
eb7fd03650 13.9
Bugfix:
- The plugin messaging channel for T2C-Commendgui was not properly registered on the proxy
- Fixed a small bug in the Update Checker where a NullPointExeption appeared in the console when the UpdateCheck server was unreachable
2022-12-22 01:43:40 +01:00
deeedcd408 13.6 2022-11-20 20:17:43 +01:00
e4c4aee0f7 13.5
Change:
- If no new update was found from a plugin, then there is now no more console spam
- Support for the old update checker has been removed
2022-11-19 02:51:28 +01:00
9 changed files with 86 additions and 178 deletions

16
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>13.4</version> <version>13.9</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2CodeLib</name> <name>T2CodeLib</name>
@@ -106,7 +106,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version> <version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- repo.t2code / T2Code --> <!-- repo.t2code / T2Code -->
@@ -133,33 +133,33 @@
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.11.1</version> <version>2.11.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- votingplugin --> <!-- votingplugin -->
<dependency> <dependency>
<groupId>com.bencodez</groupId> <groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId> <artifactId>votingplugin</artifactId>
<version>LATEST</version> <version>6.10.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--Kyori MiniMessage--> <!--Kyori MiniMessage-->
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId> <artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version> <version>4.12.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId> <artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version> <version>4.2.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId> <artifactId>adventure-platform-bungeecord</artifactId>
<version>4.1.2</version> <version>4.2.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
@@ -180,7 +180,7 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId> <artifactId>httpmime</artifactId>
<version>4.5.13</version> <version>4.5.14</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -11,13 +11,13 @@ import java.util.logging.Level;
public class T2CBsend { public class T2CBsend {
public static void console(String msg) { public static void console(String msg) {
if (T2CodeBMain.getMmIsLoad()) { if (T2CodeBMain.getMmIsLoad() && T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendConsoleMiniMessage(msg); T2CBminiMessage.sendConsoleMiniMessage(msg);
} else ProxyServer.getInstance().getConsole().sendMessage(msg); } else ProxyServer.getInstance().getConsole().sendMessage(msg);
} }
public static void player(ProxiedPlayer player, String msg) { public static void player(ProxiedPlayer player, String msg) {
if (T2CodeBMain.getMmIsLoad()) { if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendPlayerMiniMessage(msg, player); T2CBminiMessage.sendPlayerMiniMessage(msg, player);
} else player.sendMessage(msg); } else player.sendMessage(msg);
} }
@@ -27,7 +27,7 @@ public class T2CBsend {
} }
public static void sender(CommandSender sender, String msg) { public static void sender(CommandSender sender, String msg) {
if (T2CodeBMain.getMmIsLoad()) { if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendSenderMiniMessage(msg, sender); T2CBminiMessage.sendSenderMiniMessage(msg, sender);
} else sender.sendMessage(msg); } else sender.sendMessage(msg);
} }

View File

@@ -40,7 +40,7 @@ public class T2CBload {
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CplmsgBcmd()); plugin.getProxy().getPluginManager().registerListener(plugin, new T2CplmsgBcmd());
if (T2CBlibConfig.getApiCommandGUIEnable()) { if (T2CBlibConfig.getApiCommandGUIEnable()) {
plugin.getProxy().registerChannel("t2c:cgui"); plugin.getProxy().registerChannel("t2c:cguiopl");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI()); plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI());
T2CapiCGUI.sendToSpigotDeleteAll(); T2CapiCGUI.sendToSpigotDeleteAll();
} }

View File

@@ -37,7 +37,9 @@ public class T2CodeBMain extends Plugin {
autor = plugin.getDescription().getAuthor(); autor = plugin.getDescription().getAuthor();
try { try {
adventure = BungeeAudiences.create(this); adventure = BungeeAudiences.create(this);
T2CBsend.info(this,"Adventure load!");
} catch (Exception e){ } catch (Exception e){
T2CBsend.error(this,"Adventure can not be load!");
mmIsLoad = false; mmIsLoad = false;
} }
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit()); T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());

View File

@@ -1,12 +1,11 @@
package net.t2code.t2codelib.SPIGOT.api.update; package net.t2code.t2codelib.SPIGOT.api.update;
import com.sun.org.apache.xpath.internal.operations.Bool;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.UpdateType; import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@@ -18,7 +17,17 @@ public class T2CupdateAPI {
public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>(); public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) { public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
if (! pluginVersions.get(plugin.getName()).updateCheckOnJoin) { if (pluginVersions.get(plugin.getName()) == null){
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
join(plugin,prefix,perm,player,spigotID,discord);
}
},2*20L);
return;
}
if (!pluginVersions.get(plugin.getName()).updateCheckOnJoin) {
return; return;
} }
if (!player.hasPermission(perm) && !player.isOp()) { if (!player.hasPermission(perm) && !player.isOp()) {
@@ -170,82 +179,7 @@ public class T2CupdateAPI {
return text; return text;
} }
public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) {
new BukkitRunnable() {
@Override
public void run() {
(new T2CupdateChecker((JavaPlugin) plugin, spigotID)).getVersion((update_version) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
new T2CupdateWebData("OLD", update_version, "", "https://www.spigotmc.org/resources/" + spigotID, "",
"https://www.spigotmc.org/resources/" + spigotID, false),
false,
!plugin.getDescription().getVersion().equals(update_version),
true
);
pluginVersions.put(plugin.getName(), update);
if (pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) {
new BukkitRunnable() {
@Override
public void run() {
update.load = true;
sendUpdateMsg(prefix, discord, update.webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 200L);
} else sendUpdateMsg(prefix, discord, update.webData, plugin);
} else {
if (!update.load) {
T2Csend.console(prefix + " §2No update found.");
update.load = true;
}
}
}, prefix, plugin.getDescription().getVersion(),true,true,60);
}
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
}
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) { public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1"; new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
if (!seePreReleaseUpdates) {
RepoURL = RepoURL + "&pre-release=false";
}
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,
!plugin.getDescription().getVersion().equals(webData.getVersion()),
updateCheckOnJoin
);
pluginVersions.put(plugin.getName(), update);
if (pluginVersions.get(plugin.getName()).updateAvailable) {
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, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}.runTaskTimerAsynchronously(plugin, 0L, timeInterval * 60 * 20L);
} }
} }

View File

@@ -1,76 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.T2CupdateObject;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
public class T2CupdateChecker {
private JavaPlugin plugin;
private int resourceId;
public T2CupdateChecker(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if (!plugin.isEnabled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
inputStream.close();
} catch (IOException 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,
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@@ -1,9 +1,11 @@
package net.t2code.t2codelib.SPIGOT.api.update; package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@@ -15,10 +17,55 @@ import java.util.Date;
import java.util.function.Consumer; import java.util.function.Consumer;
public class T2CupdateCheckerGit { public class T2CupdateCheckerGit {
private JavaPlugin plugin; private final JavaPlugin plugin;
private T2CupdateObject t2CupdateObject;
public T2CupdateCheckerGit(JavaPlugin plugin) {
public T2CupdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
this.plugin = plugin; this.plugin = plugin;
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
if (!seePreReleaseUpdates) {
RepoURL = RepoURL + "&pre-release=false";
}
String finalRepoURL = RepoURL;
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
getVersion((webData) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
webData,
t2CupdateObject != null && t2CupdateObject.load,
!plugin.getDescription().getVersion().equals(webData.getVersion()),
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) {
new BukkitRunnable() {
@Override
public void run() {
update.load = true;
T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
} else T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
} else {
if (!update.load) {
T2Csend.console(prefix + " §2No update found.");
update.load = true;
}
}
t2CupdateObject = update;
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}, 0L, timeInterval * 60 * 20L);
} }
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) { public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {

View File

@@ -1,5 +1,6 @@
package net.t2code.t2codelib.SPIGOT.system; package net.t2code.t2codelib.SPIGOT.system;
import lombok.Getter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@@ -33,6 +34,7 @@ public final class T2CodeLibMain extends JavaPlugin {
private static List<String> autor; private static List<String> autor;
private static String version; private static String version;
@Getter
private static Boolean mmIsLoad = true; private static Boolean mmIsLoad = true;
private static Boolean load = false; private static Boolean load = false;

View File

@@ -143,15 +143,14 @@ public class CreateReportLog {
file.delete(); file.delete();
File zipFile = new File(zipPath); File zipFile = new File(zipPath);
if (!confirmUpload){ if (!confirmUpload) {
if (sender instanceof Player) { Files.move(Paths.get(zipPath), Paths.get(directory + "/" + zipFile.getName()));
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.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);
Files.move(Paths.get(zipPath),Paths.get(directory+"/"+zipFile.getName()));
zipFile.delete(); zipFile.delete();
directoryTemp.delete(); directoryTemp.delete();
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" + directory + "/" + zipFile.getName());
}
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" + directory + "/" + zipFile.getName());
return; return;
} }
@@ -179,7 +178,7 @@ public class CreateReportLog {
"<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" + "<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" +
"<br><hover:show_text:'<yellow>Click to delete</yellow>'><click:run_command:'/t2code debug deleteReportLog [key]'>[prefix] <green>You can <b>delte</b> yor Debug-File by clicking me.</green>" + "<br><hover:show_text:'<yellow>Click to delete</yellow>'><click:run_command:'/t2code debug deleteReportLog [key]'>[prefix] <green>You can <b>delte</b> yor Debug-File by clicking me.</green>" +
"<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>") "<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>")
.replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]",Util.getPrefix())); .replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]", Util.getPrefix()));
} }
T2Csend.console(Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" + T2Csend.console(Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" +
"<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." + "<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." +