From 6a218f97f0bb59deece9481fb81bc21332884af9 Mon Sep 17 00:00:00 2001 From: Paul Schulze Date: Sat, 23 Feb 2013 22:16:44 +0100 Subject: [PATCH] Version 1.1 First version of basic update checker included Event priorities for Move and Teleport listeners now HIGHEST --- CraftincBorderProtection.jar | Bin 16366 -> 19986 bytes pom.xml | 2 +- .../craftinc/borderprotection/Messages.java | 10 ++ .../borderprotection/PlayerLoginListener.java | 50 +++++++++ .../borderprotection/PlayerMoveListener.java | 8 +- .../PlayerTeleportListener.java | 8 +- .../de/craftinc/borderprotection/Plugin.java | 2 + .../borderprotection/UpdateHelper.java | 98 ++++++++++++++++++ src/main/resources/plugin.yml | 3 + 9 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 src/main/java/de/craftinc/borderprotection/PlayerLoginListener.java create mode 100644 src/main/java/de/craftinc/borderprotection/UpdateHelper.java diff --git a/CraftincBorderProtection.jar b/CraftincBorderProtection.jar index 95127d03a31c937b7e47acab746085a6cc485a2e..73018975a30bc71760dcd6472aa9550b20d17244 100644 GIT binary patch delta 12859 zcmZv?1yo!?(=Cd-ySuvwhd^L(cON9Udys(ug9dkZclV&dEx20<7F>f~lJ)-Y{rT=a zvu4#f)4S_*&#JDjs@|ud_)JJt6?teFB#6IPy>=Wb4fJ!Jb{tRgUok=USDe!S5eWp4 z{Gc}}!PfuU(GCRxkpT+<@u#Pgox7#A1Dm(KU6KaSc9jF;`PBF#*H~{j)BQR5OCWJN z-!vViGXpS@YSmJoLS8!Ftls!*Ll&P|0pS(?>i5HSpSx2xNdIE3A7rjs;8tEf>W=zv z>PJO0y;9^RM?pzaht2|BeJN9m?|MLTJV+Uhc5})^lzibhX!2*WErmGCTc-TPDc|#& zi)-_tKtGcaCVzC}Ce!h!!j(;`&RIFVQbmV1Jf4xvLT&{!Rb#!XHJ*zGP zvx3-m5}w)(-Q$yPT-p}Ut0|D`d>q~G=INC8A?h*LWFA>!nM684uLSmZwd*UB->bL@ zfij1L7CtWv8?D*%rLr!D)kc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^j3oKr#VN(Mu~DC!}i7F=9C_?>jb(%%&m=Zs}gUkcFI3gOZfI80M0Ve^4F4?2AG z<*#^!&)%d zPPb1Eg=RWsk;IzV(whfa;uMm+`T6>?uZ%G+VJu;XD16}pGDDRDlrq*X@vmi@S;2qa zG$JCAApdW<$g``0=2Zm#R)=7y%Kb$RRo=fCtSa^wTUFI?|5Y^t!cya6_*V}8nTnKn z9?yRca5yT;Gcm~u3Q}YGYobt%8p#I(#3)G*T2-U}EBf;+V#fa~l2HF!vjVbKr$#~{ z{VU2-r}*2$fAet&2weX$|BT>pVcNfnWwdzQ{~go+Ee-fLL;BxV;P79}|HGGJfnI6g z{O#fY;cyT{{;T`kL&1w@WyQZr&ztN2*<1hruVKRb{2DwUDJ`78U%7@BH4=g-$We=y z;h)L=f9xSp|L+X}!qXFvCVIwh^H+3; lf^@aj|91E<@A{Y0mH4w&CD4O51|BiO^Z86$LI2L#{{ao%BG&)_ diff --git a/pom.xml b/pom.xml index b344b5b..fa478a9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.craftinc CraftincBorderProtection jar - 1.0.3-1 + 1.1 UTF-8 diff --git a/src/main/java/de/craftinc/borderprotection/Messages.java b/src/main/java/de/craftinc/borderprotection/Messages.java index 1bc7bc9..8e35632 100644 --- a/src/main/java/de/craftinc/borderprotection/Messages.java +++ b/src/main/java/de/craftinc/borderprotection/Messages.java @@ -116,4 +116,14 @@ public class Messages public static String borderEnableDisableException = ChatColor.RED + "Error: Could not save border state on server. After the next reload this border state will be lost!"; + + public static String UpdateMessage( String newVersion, String curVersion ) + { + return ChatColor.RED + "Craft Inc. BorderProtection: New version available!" + NEWLINE + + ChatColor.YELLOW + "Current version: " + ChatColor.WHITE + curVersion + NEWLINE + + ChatColor.YELLOW + "New version: " + ChatColor.WHITE + newVersion + NEWLINE + + ChatColor.YELLOW + "Please visit:" + NEWLINE + + ChatColor.AQUA + "http://dev.bukkit.org/server-mods/craftinc-borderprotection" + NEWLINE + + ChatColor.YELLOW + "to get the latest version!"; + } } diff --git a/src/main/java/de/craftinc/borderprotection/PlayerLoginListener.java b/src/main/java/de/craftinc/borderprotection/PlayerLoginListener.java new file mode 100644 index 0000000..0286300 --- /dev/null +++ b/src/main/java/de/craftinc/borderprotection/PlayerLoginListener.java @@ -0,0 +1,50 @@ +/* Craft Inc. BorderProtection + Copyright (C) 2013 Paul Schulze + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +package de.craftinc.borderprotection; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; + +public class PlayerLoginListener implements Listener +{ + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerLogin( PlayerLoginEvent e ) + { + final Player player = e.getPlayer(); + + if ( e.getPlayer().hasPermission("craftinc.borderprotection.update") ) + { + if ( UpdateHelper.newVersionAvailable() ) + { + // Schedule a task which delays 20 ticks (1 second) and then sends a message to the player + Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + player.sendMessage(Messages.UpdateMessage(UpdateHelper.cachedLatestVersion, + UpdateHelper.getCurrentVersion())); + } + }, 20L); + } + } + } +} diff --git a/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java b/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java index a3a5992..b237065 100644 --- a/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java +++ b/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java @@ -56,9 +56,15 @@ public class PlayerMoveListener implements Listener } @SuppressWarnings("unused") - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerMove( PlayerMoveEvent e ) { + // do nothing if the event is already cancelled + if (e.isCancelled()) + { + return; + } + // do nothing if player has the ignoreborders permission if ( e.getPlayer().hasPermission("craftinc.borderprotection.ignoreborders") ) { diff --git a/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java b/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java index 679e200..5be1e9a 100644 --- a/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java +++ b/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java @@ -33,9 +33,15 @@ public class PlayerTeleportListener implements Listener } @SuppressWarnings("unused") - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerMove( PlayerTeleportEvent e ) { + // do nothing if the event is already cancelled + if (e.isCancelled()) + { + return; + } + // do nothing if player has the ignoreborders permission if ( e.getPlayer().hasPermission("craftinc.borderprotection.ignoreborders") ) { diff --git a/src/main/java/de/craftinc/borderprotection/Plugin.java b/src/main/java/de/craftinc/borderprotection/Plugin.java index 7e9a948..5510721 100644 --- a/src/main/java/de/craftinc/borderprotection/Plugin.java +++ b/src/main/java/de/craftinc/borderprotection/Plugin.java @@ -48,6 +48,7 @@ public class Plugin extends JavaPlugin BorderManager borderManager = new BorderManager(); PlayerMoveListener playerMoveListener = new PlayerMoveListener(borderManager); PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener(borderManager); + PlayerLoginListener playerLoginListener = new PlayerLoginListener(); // commands Commands commandExecutor = new Commands(borderManager); @@ -57,5 +58,6 @@ public class Plugin extends JavaPlugin PluginManager pm = this.getServer().getPluginManager(); pm.registerEvents(playerMoveListener, this); pm.registerEvents(playerTeleportListener, this); + pm.registerEvents(playerLoginListener, this); } } diff --git a/src/main/java/de/craftinc/borderprotection/UpdateHelper.java b/src/main/java/de/craftinc/borderprotection/UpdateHelper.java new file mode 100644 index 0000000..37f9952 --- /dev/null +++ b/src/main/java/de/craftinc/borderprotection/UpdateHelper.java @@ -0,0 +1,98 @@ +/* Craft Inc. BorderProtection + Copyright (C) 2013 Paul Schulze + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +package de.craftinc.borderprotection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +public class UpdateHelper +{ + /** + * The URL from which the Plugin tries to get the latest version. + */ + @SuppressWarnings("FieldCanBeLocal") + private static final String updateUrl = "http://www.craftinc.de/plugins/update/craftinc-borderprotection"; + + /** + * The latest version which was seen on last check. + */ + public static String cachedLatestVersion = null; + + + /** + * Gets the latest version from the updateURL and returns it as String. + * + * @return latest version as String. + */ + @SuppressWarnings("StringBufferMayBeStringBuilder") + public static String getLatestVersion() + { + // StringBuffer is thread-safe. Don't know if this is really important here, but safe is safe :). + StringBuffer s = new StringBuffer(); + try + { + URLConnection c = new URL(updateUrl).openConnection(); + BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream())); + String inputLine; + while ( ( inputLine = br.readLine() ) != null ) + { + s.append(inputLine); + } + br.close(); + } + catch ( MalformedURLException e ) + { + Plugin.getPlugin().getLogger().warning("Could not check for latest version. Update URL is malformed."); + } + catch ( IOException e ) + { + Plugin.getPlugin().getLogger().warning("Could not check for latest version. Update URL was not readable."); + } + + // update cached latest version + cachedLatestVersion = s.toString(); + + return s.toString(); + } + + + /** + * Gets the current version of this plugin directly from the plugin.yml version entry. + * + * @return current version as String. + */ + public static String getCurrentVersion() + { + return Plugin.getPlugin().getDescription().getVersion(); + } + + + /** + * Checks if a newer version is available. + * + * @return Boolean + */ + public static Boolean newVersionAvailable() + { + return !getCurrentVersion().equals(getLatestVersion()); + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6adfe4f..4642d1c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -33,3 +33,6 @@ permissions: craftinc.borderprotection.ignoreborders: default: op description: Allows to be everywhere on the map (ignoring the borders). + craftinc.borderprotection.update: + default: op + description: Allows to get notified on login, when a new update is available. \ No newline at end of file