1.0.1 SNAPSHOT
Update checker
This commit is contained in:
1 parent
acce87ea00
commit
30726108a4
6 files changed
+52
-13
No files matched your search
+1
-2
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'me.redtea'
|
||||
version = '1.0.0-SNAPSHOT'
|
||||
version = '1.0.1-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -37,7 +37,6 @@ dependencies {
|
||||
implementation "net.kyori:adventure-api:4.14.0"
|
||||
implementation "net.kyori:adventure-platform-bukkit:4.3.0"
|
||||
implementation files("libs/MiniMessages.jar")
|
||||
compileOnly files("libs/nodropxforgebridge-1.1.jar")
|
||||
implementation "dev.triumphteam:triumph-gui:3.1.2"
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ import me.redtea.nodropx.service.respawn.RespawnService;
|
||||
import me.redtea.nodropx.service.respawn.impl.RespawnServiceImpl;
|
||||
import me.redtea.nodropx.service.storage.StorageService;
|
||||
import me.redtea.nodropx.service.storage.impl.StorageServiceImpl;
|
||||
import me.redtea.nodropxforgebridge.ApiProvider;
|
||||
import me.redtea.nodropxforgebridge.Nodropxforgebridge;
|
||||
import me.redtea.nodropx.util.UpdateChecker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -46,7 +45,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -132,13 +130,22 @@ public final class NoDropX extends JavaPlugin {
|
||||
commandManager.register(new NoDropCommand(messages, noDropAPI, guiFacade, this));
|
||||
bStatsInit();
|
||||
printCredits();
|
||||
|
||||
mod();
|
||||
checkUpdates();
|
||||
}
|
||||
|
||||
//todo remove
|
||||
private void mod() {
|
||||
Nodropxforgebridge.noDropAPI = s -> getAPI().getCapacitySlots(s);
|
||||
|
||||
private void checkUpdates() {
|
||||
if(!(getConfig().contains("checkForUpdates") && getConfig().getBoolean("checkForUpdates"))) {
|
||||
return;
|
||||
}
|
||||
new UpdateChecker(this, 111485).getVersion(version -> {
|
||||
if (this.getDescription().getVersion().equals(version)) {
|
||||
getLogger().info("There is not a new update available.");
|
||||
} else {
|
||||
getLogger().info("There is a new update available: " + version);
|
||||
getLogger().info(". Download it from https://www.spigotmc.org/resources/nodropx.111485/");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class NoDropCommand extends CommandBase {
|
||||
}
|
||||
|
||||
@SubCommand("give")
|
||||
@Permission("nodropx.give")
|
||||
@Permission("R")
|
||||
@Completion({"#players", "#materials", "#range:1-64"})
|
||||
public void onGive(final CommandSender sender,
|
||||
final Player player,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.redtea.nodropx.util;
|
||||
|
||||
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 UpdateChecker {
|
||||
private final JavaPlugin plugin;
|
||||
private final int resourceId;
|
||||
|
||||
public UpdateChecker(JavaPlugin plugin, int resourceId) {
|
||||
this.plugin = plugin;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void getVersion(final Consumer<String> consumer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scann = new Scanner(is)) {
|
||||
if (scann.hasNext()) {
|
||||
consumer.accept(scann.next());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info("Unable to check for updates: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
forceUseLegacy: false
|
||||
forceUseMD5Colors: false
|
||||
forceUseMD5Colors: false
|
||||
checkForUpdates: true
|
||||
@@ -14,7 +14,7 @@ noExists: "<dark_red><bold>[!] <red>This player doesnt exists!"
|
||||
gui:
|
||||
title: "<bold>Personal storage"
|
||||
frame:
|
||||
name: "&7"
|
||||
name: "<gray>"
|
||||
material: GLASS_PANE
|
||||
prev:
|
||||
name: "<red>Previous"
|
||||
|
||||
Reference in new issue
Block a user