11.6 Perform Update in Update Checker
This commit is contained in:
parent
abf95ecf0c
commit
f27ec3c985
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>11.5</version>
|
<version>11.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>T2CodeLib</name>
|
<name>T2CodeLib</name>
|
||||||
|
@ -25,22 +25,27 @@ public class UpdateAPI {
|
|||||||
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
|
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
|
||||||
|
|
||||||
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
|
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
if (!player.hasPermission(perm) && !player.isOp()) {
|
@Override
|
||||||
return;
|
public void run() {
|
||||||
}
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
if (UpdateAPI.PluginVersionen.get(plugin.getName()) == null) {
|
if (!player.hasPermission(perm) && !player.isOp()) {
|
||||||
new BukkitRunnable() {
|
return;
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
join(plugin, prefix, perm, player, spigot, discord);
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20L);
|
if (UpdateAPI.PluginVersionen.get(plugin.getName()) == null) {
|
||||||
} else use(plugin, prefix, player, pluginVersion, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion, spigot, discord);
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
join(plugin, prefix, perm, player, spigot, discord);
|
||||||
|
}
|
||||||
|
}.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) {
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!pluginVersion.equals(publicVersion)) {
|
if (!pluginVersion.equals(publicVersion)) {
|
||||||
@ -49,19 +54,19 @@ public class UpdateAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 200L);
|
}, 200L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion) {
|
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion) {
|
||||||
send.console("§4=========== " + Prefix + " §4===========");
|
send.console("§4=========== " + Prefix + " §4===========");
|
||||||
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")){
|
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
if (publicVersion.toLowerCase().contains("dev")){
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
send.console("§6A new §4DEV§6 version was found!");
|
send.console("§6A new §4DEV§6 version was found!");
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("beta")){
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
send.console("§6A new §2BETA§6 version was found!");
|
send.console("§6A new §2BETA§6 version was found!");
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")){
|
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
send.console("§6A new §eSNAPSHOT§6 version was found!");
|
send.console("§6A new §eSNAPSHOT§6 version was found!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -78,18 +83,18 @@ public class UpdateAPI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send.player(player, Prefix);
|
send.player(player, Prefix);
|
||||||
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")){
|
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
if (publicVersion.toLowerCase().contains("dev")){
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
TextComponent comp = new TextBuilder(Prefix + " §6A new §4DEV§6 version was found!")
|
TextComponent comp = new TextBuilder(Prefix + " §6A new §4DEV§6 version was found!")
|
||||||
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
||||||
player.spigot().sendMessage(comp);
|
player.spigot().sendMessage(comp);
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("beta")){
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
TextComponent comp = new TextBuilder(Prefix + " §6A new §2BETA§6 version was found!")
|
TextComponent comp = new TextBuilder(Prefix + " §6A new §2BETA§6 version was found!")
|
||||||
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
||||||
player.spigot().sendMessage(comp);
|
player.spigot().sendMessage(comp);
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")){
|
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
TextComponent comp = new TextBuilder(Prefix + " §6A new §eSNAPSHOT§6 version was found!")
|
TextComponent comp = new TextBuilder(Prefix + " §6A new §eSNAPSHOT§6 version was found!")
|
||||||
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
|
||||||
player.spigot().sendMessage(comp);
|
player.spigot().sendMessage(comp);
|
||||||
@ -152,7 +157,7 @@ public class UpdateAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
|
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
|
||||||
if (!plugin.isEnabled()){
|
if (!plugin.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||||
|
@ -13,7 +13,6 @@ public class JoinEvent implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoinEvent(PlayerLoginEvent event) {
|
public void onJoinEvent(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
|
||||||
UpdateAPI.join(Main.plugin, Util.getPrefix(), "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
|
UpdateAPI.join(Main.plugin, Util.getPrefix(), "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user