diff --git a/src/main/java/ch/njol/skript/Skript.java b/src/main/java/ch/njol/skript/Skript.java index a4f4b653f2c..0bd0a4877b7 100644 --- a/src/main/java/ch/njol/skript/Skript.java +++ b/src/main/java/ch/njol/skript/Skript.java @@ -838,32 +838,9 @@ protected void afterErrors() { } }); - Bukkit.getPluginManager().registerEvents(new Listener() { - @EventHandler - public void onJoin(final PlayerJoinEvent e) { - if (e.getPlayer().hasPermission("skript.admin")) { - new Task(Skript.this, 0) { - @Override - public void run() { - Player p = e.getPlayer(); - SkriptUpdater updater = getUpdater(); - if (updater == null) - return; - - // Don't actually check for updates to avoid breaking Github rate limit - if (updater.getReleaseStatus() == ReleaseStatus.OUTDATED) { - // Last check indicated that an update is available - UpdateManifest update = updater.getUpdateManifest(); - assert update != null; // Because we just checked that one is available - Skript.info(p, "" + SkriptUpdater.m_update_available.toString(update.id, Skript.getVersion())); - p.spigot().sendMessage(BungeeConverter.convert(ChatMessages.parseToArray( - "Download it at: " + update.downloadUrl))); - } - } - }; - } - } - }, this); + if (!TestMode.ENABLED) { + Bukkit.getPluginManager().registerEvents(new JoinUpdateNotificationListener(), this); + } // Send a warning to console when the plugin is reloaded Bukkit.getPluginManager().registerEvents(new Listener() { @@ -888,6 +865,36 @@ public void onServerReload(ServerLoadEvent event) { SkriptTimings.setSkript(this); } + private class JoinUpdateNotificationListener implements Listener { + @EventHandler + public void onJoin(PlayerJoinEvent event) { + if (!event.getPlayer().hasPermission("skript.admin")) + return; + + new Task(Skript.this, 0) { + @Override + public void run() { + Player player = event.getPlayer(); + SkriptUpdater updater = getUpdater(); + + // Don't actually check for updates to avoid breaking GitHub rate limit + if (updater == null || updater.getReleaseStatus() != ReleaseStatus.OUTDATED) + return; + + // Last check indicated that an update is available + UpdateManifest update = updater.getUpdateManifest(); + + if (update == null) + return; + + Skript.info(player, SkriptUpdater.m_update_available.toString(update.id, Skript.getVersion())); + player.spigot().sendMessage(BungeeConverter.convert(ChatMessages.parseToArray( + "Download it at: " + update.downloadUrl))); + } + }; + } + } + private void runTest(Class clazz, AtomicLong shutdownDelay, AtomicLong tests, AtomicLong milliseconds, AtomicLong ignored, AtomicLong fails) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {