From 32b5700562f39b40d27ac92dd6631a336db51858 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 2 Nov 2020 04:12:24 +1300 Subject: [PATCH] Make the update protocollib messages even more extreme --- .../utilities/listeners/DisguiseListener.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java index 0c3b01c5..9d17d833 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java @@ -326,33 +326,22 @@ public class DisguiseListener implements Listener { p.removeMetadata("ld_loggedin", LibsDisguises.getInstance()); plugin.getUpdateChecker().notifyUpdate(p); - if (p.isOp() || p.hasPermission("minecraft.command.op") || - new DisguisePermissions(p, "disguiseradius").hasPermissions()) { - String requiredProtocolLib = DisguiseUtilities.getProtocolLibRequiredVersion(); - String version = ProtocolLibrary.getPlugin().getDescription().getVersion(); + String requiredProtocolLib = DisguiseUtilities.getProtocolLibRequiredVersion(); + String version = ProtocolLibrary.getPlugin().getDescription().getVersion(); - if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) { - new BukkitRunnable() { - @Override - public void run() { - if (!p.isOnline()) { - cancel(); - return; - } - - p.sendMessage(ChatColor.RED + "Update your ProtocolLib! You are running " + version + - " but the minimum version you should be on is " + requiredProtocolLib + "!"); - p.sendMessage(ChatColor.RED + - "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + - "/ProtocolLib" + ".jar"); - p.sendMessage(ChatColor.RED + - "Or! Use /ld updateprotocollib - To update to the latest development build"); - p.sendMessage(ChatColor.DARK_GREEN + - "This message is `kindly` provided by Lib's Disguises on repeat due to the sheer " + - "number of people who don't see it"); + if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) { + sendUpdateMessage(p, version, requiredProtocolLib); + new BukkitRunnable() { + @Override + public void run() { + if (!p.isOnline()) { + cancel(); + return; } - }.runTaskTimer(LibsDisguises.getInstance(), 10, 10 * 60 * 20); // Run every 10 minutes - } + + sendUpdateMessage(p, version, requiredProtocolLib); + } + }.runTaskTimer(LibsDisguises.getInstance(), 10, 10 * 60 * 20); // Run every 10 minutes } if (DisguiseConfig.isSavePlayerDisguises()) { @@ -443,6 +432,18 @@ public class DisguiseListener implements Listener { }.runTaskLater(LibsDisguises.getInstance(), 60); } + private void sendUpdateMessage(Player p, String version, String requiredProtocolLib) { + p.sendMessage(ChatColor.RED + "Please ask the server owner to update ProtocolLib! You are running " + version + + " but the minimum version you should be on is " + requiredProtocolLib + "!"); + p.sendMessage(ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + + "/ProtocolLib" + ".jar"); + p.sendMessage(ChatColor.RED + "Or! Use " + ChatColor.DARK_RED + "/ld updateprotocollib" + ChatColor.RED + + " - To update to the latest development build"); + p.sendMessage(ChatColor.DARK_GREEN + + "This message is `kindly` provided by Lib's Disguises on repeat to all players due to the sheer " + + "number of people who don't see it"); + } + /** * Most likely faster if we don't bother doing checks if he sees a player disguise */