11.6 Perform Update in Update Checker

This commit is contained in:
JaTiTV 2022-04-19 01:29:24 +02:00
parent abf95ecf0c
commit f27ec3c985
3 changed files with 28 additions and 24 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>11.5</version>
<version>11.6</version>
<packaging>jar</packaging>
<name>T2CodeLib</name>

View File

@ -25,6 +25,9 @@ public class UpdateAPI {
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
String pluginVersion = plugin.getDescription().getVersion();
if (!player.hasPermission(perm) && !player.isOp()) {
return;
@ -38,9 +41,11 @@ public class UpdateAPI {
}.runTaskLater(plugin, 20L);
} else use(plugin, prefix, player, pluginVersion, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion, spigot, discord);
}
});
}
private static void use(Plugin plugin, String prefix, Player player, String pluginVersion, String publicVersion, String spigot, String discord) {
new BukkitRunnable() {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (!pluginVersion.equals(publicVersion)) {
@ -49,7 +54,7 @@ public class UpdateAPI {
}
}
}
}.runTaskLater(plugin, 200L);
}, 200L);
}
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion) {

View File

@ -13,7 +13,6 @@ public class JoinEvent implements Listener {
@EventHandler
public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer();
UpdateAPI.join(Main.plugin, Util.getPrefix(), "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
}
}