diff --git a/Bukkit/plugin.yml b/Bukkit/plugin.yml index 3915b4c..762d2f7 100644 --- a/Bukkit/plugin.yml +++ b/Bukkit/plugin.yml @@ -1,6 +1,6 @@ name: CubeRunner main : me.poutineqc.cuberunner.CubeRunner -version: 2.5.1 +version: 2.5.2 description: Blocks are falling over your head! Can you outrun them? load: postworld author: PoutineQc diff --git a/Bukkit/src/me/poutineqc/cuberunner/Updater.java b/Bukkit/src/me/poutineqc/cuberunner/Updater.java index 8b1bd48..b34800e 100644 --- a/Bukkit/src/me/poutineqc/cuberunner/Updater.java +++ b/Bukkit/src/me/poutineqc/cuberunner/Updater.java @@ -25,9 +25,9 @@ public final class Updater implements Listener { private final CubeRunner plugin; private final int id; - - private boolean lastVersion; - private String latestVersion; + + private boolean lastVersion = true; + private String latestVersion = ""; public Updater(final CubeRunner plugin) { this.plugin = plugin; @@ -35,9 +35,6 @@ public Updater(final CubeRunner plugin) { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { checkForLastVersion(plugin); - if (!lastVersion) { - notifyConsole(plugin); - } } }, 0, 72000L); } @@ -48,24 +45,35 @@ public void onPlayerJoin(PlayerJoinEvent event) { notifyPlayer(event.getPlayer()); } - private void checkForLastVersion(CubeRunner plugin) { - try { - lastVersion = getInfoFromServer(); - } catch (IOException e) { - plugin.getLogger().warning("Could not find the latest version available."); - stop(); - return; - } + private void checkForLastVersion(final CubeRunner plugin) { + new Thread(new Runnable() { + + @Override + public void run() { + try { + lastVersion = getInfoFromServer(); + } catch (IOException e) { + plugin.getLogger().warning("Could not find the latest version available."); + stop(); + return; + } + + if (!lastVersion) { + notifyConsole(plugin); + } + } + }).start(); } - + private boolean getInfoFromServer() throws IOException { + URL oracle = new URL(spigotPage + "history"); URLConnection urlConn = oracle.openConnection(); urlConn.addRequestProperty("User-Agent", "Mozilla/4.76"); InputStream is = urlConn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, 4 * 1024); BufferedReader in = new BufferedReader(new InputStreamReader(bis, StandardCharsets.UTF_8)); - + latestVersion = null; String inputLine; while ((inputLine = in.readLine()) != null && latestVersion == null) @@ -76,7 +84,6 @@ private boolean getInfoFromServer() throws IOException { if (latestVersion == null) { throw new IOException("Could not find the version on the page."); } - return latestVersion.equalsIgnoreCase(plugin.getDescription().getVersion()); } diff --git a/Bukkit/src/me/poutineqc/cuberunner/game/OriginalPlayerStats.java b/Bukkit/src/me/poutineqc/cuberunner/game/OriginalPlayerStats.java index 47823d6..015e4d4 100644 --- a/Bukkit/src/me/poutineqc/cuberunner/game/OriginalPlayerStats.java +++ b/Bukkit/src/me/poutineqc/cuberunner/game/OriginalPlayerStats.java @@ -70,7 +70,7 @@ public void imaxStats(Player player) { player.setLevel(0); player.setExp(0); player.setGameMode(GameMode.ADVENTURE); - player.setHealth(20); + player.setHealth(player.getMaxHealth()); player.setFoodLevel(20); player.setSaturation(20); for (PotionEffect effect : player.getActivePotionEffects())