From 3b57326d3b2d37bfb51ba8d1749019f116bd047f Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 7 Nov 2013 03:57:30 +1300 Subject: [PATCH] Don't notify them of a update everytime it does a update check --- .../disguise/DisguiseListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java index e55937bb..7a09c9b4 100644 --- a/src/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -39,16 +39,19 @@ public class DisguiseListener implements Listener { try { UpdateChecker updateChecker = new UpdateChecker(); updateChecker.checkUpdate("v" + currentVersion); + String lastVersion = latestVersion; latestVersion = updateChecker.getLatestVersion(); if (latestVersion != null) { latestVersion = "v" + latestVersion; - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - for (Player p : Bukkit.getOnlinePlayers()) - if (p.hasPermission(permission)) - p.sendMessage(String.format(updateMessage, currentVersion, latestVersion)); - } - }); + if (lastVersion == null || !lastVersion.equals(latestVersion)) { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + for (Player p : Bukkit.getOnlinePlayers()) + if (p.hasPermission(permission)) + p.sendMessage(String.format(updateMessage, currentVersion, latestVersion)); + } + }); + } } } catch (Exception ex) { System.out.print(String.format("[LibsDisguises] Failed to check for update: %s", ex.getMessage()));