From 19b8e12ff464df806e36cc19871e32919415f390 Mon Sep 17 00:00:00 2001 From: Paul Schulze Date: Sat, 29 Sep 2012 22:53:44 +0200 Subject: [PATCH] timeout for bordermessage cancel teleport events if destination is outside border --- CraftincBorderProtection.jar | Bin 0 -> 18229 bytes pom.xml | 2 +- .../borderprotection/BorderManager.java | 113 +++++++++++++++++- .../craftinc/borderprotection/Commands.java | 2 +- .../craftinc/borderprotection/Messages.java | 17 ++- .../borderprotection/PlayerMoveListener.java | 61 +++------- .../PlayerTeleportListener.java | 64 ++++++++++ .../de/craftinc/borderprotection/Plugin.java | 13 +- .../de/craftinc/borderprotection/Util.java | 25 ++-- src/main/resources/plugin.yml | 2 +- 10 files changed, 231 insertions(+), 68 deletions(-) create mode 100644 CraftincBorderProtection.jar create mode 100644 src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java diff --git a/CraftincBorderProtection.jar b/CraftincBorderProtection.jar new file mode 100644 index 0000000000000000000000000000000000000000..0c9a0b546b4b25b0aaff9d09595fd6ad2d4b71ba GIT binary patch literal 18229 zcmb_@19WA})^6NkcWidlv8|46+qQSyv2EKnJGO13V;h~k^ncOk-h1wU-W%gp_R3y+ zteW4fs#R;%tU2c=BMu4%4fLz{HgNI&&&l8aLA`%V3M%kYiAo94$o#z;B#_U0H7Ex8 zI^*}t9`6V8AFE07N{I>y$}3Py3SCQ%j!1}8QBT2%Q<0C4PSncL&N6K7*-?s(4^oO# z@j-sr%~Og)rRXFAG^d5iA&JY$JEW7BBV)rL#xlsExFe0oUB6!uW3U(N-0n+mesn2@ zk4Dz4jI)Tk{NW053Gt&%qfG?yU}|mkPfKgy&Yh^Ypy@i29d7g$Ms#9TId`yf-f|`M*`8{K|N5fg zQSSUo2I-VdMMmog9U7Blc|A>0Uoosiy62TYJjp;&Y`GW^I#1$HKdlnXEC0ZozCEQb z-7i%J>~}6w5LT#&;ABrN%3OesGsS2gfzWjj3KfSUz_BN!ZlZkvH^>S6$9a>SY(r?J z*WxSlVZQM8S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! z|E&Dqtit~Vh4=pf|c>-|e?1T@D%{TJ1ghsSY5c*^CV5 z-;Rg>7F`J2m^C-MKGXZKKue?L36%==xDw$G9 zMK8+_KjOt_e5F($ttjtJl0^lk7Q{||l`5fAi79caP*_z>Eb4jNyV*$GB+Z_$Vw{7b z^s-R#T_E*L>;vlh8UEmEQT82)6*PM$_(oWGA}s7MH%;qhJY40^h`h7k6+agpNv|8T zMdfKE##4fIby*y25p;w)IM=uIGX~HgXlAKCeH!@+OmaXybC@iv#p6%gniJqrO`uBq z;!RknYIb0RWi?!7(kUYw$0a%!Cu4HTBz1Gzy?5(EPJcbjzaO{XVt>xq|5f={$@Bh2P5b9l z`Un30Z-oD3&i|s;|E>H|-1&a`KScZAE&X>c{x7Qi-^wq6t@qP+0sY^^``?m(M!o+n z3G===`lIBZ5b^&3_2*RlzqjJO-$L(Dzlr(3d;8~n_1|);?{ByNwF&>uUjHNXpYZ~J zLrc7;dH%1^zgdER1pPB|!*9@4_`d-C->43MRP*be{(HXiZ#6b3f1&2Tz2W~fd-;!g ze~sC{C&B*K8;kZAdjBLP_TSO}J>%myIvBxUp#N+B#~*?JEGYOJnEm~+`(JPMA47zH zg#EMd$Zyy{^1p=r^I*vzRs5Ml>bD92-CwBqZ#Vi++*5zl`e#0n-&)-m{zB_NJtBX^ z{Ifm&Z_IPXzrg(09sh6O|Fp+`8E=0p@IY^G)*OF$rT)W|`^S6fKZSo8bH9bt{!{qB zjp(~+_uo-@{{i~GIJ~`W|39GqU#RIHE9!r}@ORVicPAl%{%mdk it#y$5|C83=E4_?3_`81y2nhB4&+9$3pT+a**Z%=E3rfZS literal 0 HcmV?d00001 diff --git a/pom.xml b/pom.xml index db960a2..9d4854e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ CraftincBorderProtection CraftincBorderProtection jar - 0.9.5 + 0.9.9 CraftincGates http://maven.apache.org diff --git a/src/main/java/de/craftinc/borderprotection/BorderManager.java b/src/main/java/de/craftinc/borderprotection/BorderManager.java index c7fc438..4c2c1ec 100644 --- a/src/main/java/de/craftinc/borderprotection/BorderManager.java +++ b/src/main/java/de/craftinc/borderprotection/BorderManager.java @@ -2,10 +2,12 @@ package de.craftinc.borderprotection; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.entity.Player; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.HashMap; public class BorderManager @@ -25,15 +27,21 @@ public class BorderManager private HashMap> borders = null; /** - * the buffer in blocks which applies when a player is teleported inside the border. 0 means the player + * For every player save the time when he got the last borderMessage + */ + public HashMap lastBorderMessage = new HashMap(); + + /** + * The buffer in blocks which applies when a player is teleported inside the border. 0 means the player * will be teleported directly to the border. */ private double buffer = 0.5; - public Serializer getSerializer() - { - return serializer; - } + /** + * A timeout for the border message. When a player tries to cross the border and sees the border message, + * the earliest possible time the message will show up again is after timeout milliseconds. + */ + private Long timeout = 10000L; /** * Serializer, which is used for loading and saving data to harddisk @@ -59,11 +67,21 @@ public class BorderManager * ********************************************************** */ + public Serializer getSerializer() + { + return serializer; + } + public double getBuffer() { return buffer; } + public Long getTimeout() + { + return timeout; + } + public HashMap> getBorders() { return borders; @@ -103,4 +121,89 @@ public class BorderManager borders.put(worldName, locations); } + + + /** + * Checks if the given location is inside the border rectangle. Returns null if yes, otherwise new coordinates. + * + * @param location location to check + * @param borderPoints points which define the border rectangle + * @param buffer if the player will be teleported back, then he will be buffer far away + * from the border he tried to cross + * @return null if the player is inside, otherwise a new player location + */ + public Double[] checkBorder( Location location, ArrayList borderPoints, double buffer ) + { + // New x and z: null by default + Double[] newXZ = { null, null }; + + // check if player is withing the X borders + newXZ[0] = _checkBorder(location.getX(), borderPoints.get(0).getX(), borderPoints.get(1).getX(), buffer); + // check if player is withing the Z borders + newXZ[1] = _checkBorder(location.getZ(), borderPoints.get(0).getZ(), borderPoints.get(1).getZ(), buffer); + + // Do nothing, if no new coordinates have been calculated. + if ( newXZ[0] == null && newXZ[1] == null ) + { + return null; + } + return newXZ; + } + + + /** + * Checks if the given location is between one specific border pair. + * + * @param location part of the location coordinates + * @param border1 one side of the rectangle + * @param border2 opposite side of the rectangle + * @return null if the location is inside, otherwise a new location + */ + public Double _checkBorder( double location, double border1, double border2, double buffer ) + { + double bigBorder = Math.max(border1, border2); + double smallBorder = Math.min(border1, border2); + + // if location is between borders do nothing + if ( location >= smallBorder && location <= bigBorder ) + { + return null; + } + else + { + if ( location > bigBorder ) + { + // if location is outside of the bigBorder, teleport to the bigBorder + return bigBorder - buffer; + } + else + { + // if location is outside of the smallBorder, teleport to the smallBorder + return smallBorder + buffer; + } + } + } + + + /** + * Show the border message to a player and respect the timeout. + * + * @param player Player who will see the border message. + */ + public void showMessageWithTimeout( Player player, String message ) + { + // get the current time + Long now = Calendar.getInstance().getTimeInMillis(); + + if ( ( lastBorderMessage.get(player.getName()) != null && + now - getTimeout() > lastBorderMessage.get(player.getName()) ) || + lastBorderMessage.get(player.getName()) == null ) + { + // show message + player.sendMessage(message); + + // set last sent message for this player to now + lastBorderMessage.put(player.getName(), now); + } + } } \ No newline at end of file diff --git a/src/main/java/de/craftinc/borderprotection/Commands.java b/src/main/java/de/craftinc/borderprotection/Commands.java index be62b66..c5c8218 100644 --- a/src/main/java/de/craftinc/borderprotection/Commands.java +++ b/src/main/java/de/craftinc/borderprotection/Commands.java @@ -74,7 +74,7 @@ public class Commands implements CommandExecutor } ArrayList borderPoints = borderManager.getBorders() - .get(worldName); + .get(worldName); String borderDef = borderPoints.get(0).getX() + "," + borderPoints.get(0).getZ() + " " + borderPoints.get(1).getX() + "," + borderPoints.get(1).getZ(); diff --git a/src/main/java/de/craftinc/borderprotection/Messages.java b/src/main/java/de/craftinc/borderprotection/Messages.java index 72cda7f..9d99f5e 100644 --- a/src/main/java/de/craftinc/borderprotection/Messages.java +++ b/src/main/java/de/craftinc/borderprotection/Messages.java @@ -37,15 +37,22 @@ public class Messages return sb.toString(); } + private static String borderExplanation = + "One day the holy mods and administrators will expand the border. It is then your mission to explore " + + "strange new worlds, to seek out new life and new civilizations, to boldly go where no one has gone before."; + public static String borderMessage = - "Sorry Dude! This is the border... the final frontier! One day the holy mods " + - "and administrators will expand the border. It is then your mission to explore " + - "strange new worlds, to seek out new life and new civilizations, to boldly go " + - "where no one has gone before."; + "Sorry Dude! This is the border... the final frontier! " + borderExplanation + NEWLINE + + makeCmd("/cibp get", "shows the borders of the current world"); + + public static String borderTeleportMessage = + "Sorry Dude! You cannot teleport outside the border. " + borderExplanation + NEWLINE + + makeCmd("/cibp get", "shows the borders of the current world"); public static String helpGeneral = ChatColor.GREEN + "CraftInc BorderProtection - Usage:" + NEWLINE + makeCmd("help", "shows this help") + + makeCmd("get | info", "shows the borders of the current world") + makeCmd("set", "Border rectangle edges will be this far away from point of origin.", "") + makeCmd("set", "Border rectangle is defined by the two points. A point is specified as: x,z", "", ""); @@ -56,7 +63,7 @@ public class Messages public static String borderInfo( String worldName, String borderDef ) { - return ChatColor.WHITE + "Border definition of world " + + return ChatColor.WHITE + "Borders of world " + ChatColor.YELLOW + worldName + ChatColor.WHITE + ": " + ChatColor.YELLOW + borderDef; diff --git a/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java b/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java index 4ce9ccb..d0a24bf 100644 --- a/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java +++ b/src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java @@ -21,39 +21,6 @@ public class PlayerMoveListener implements Listener this.borderManager = borderManager; } - /** - * Checks if the player is outside of one specific border. - * - * @param player part of the player coordinates - * @param border1 one side of the rectangle - * @param border2 opposite side of the rectangle - * @return null if the player is inside, otherwise a new player location - */ - private Double checkBorder( double player, double border1, double border2 ) - { - double bigBorder = Math.max(border1, border2); - double smallBorder = Math.min(border1, border2); - - // if player is between borders do nothing - if ( player >= smallBorder && player <= bigBorder ) - { - return null; - } - else - { - if ( player > bigBorder ) - { - // if player is outside of the bigBorder, teleport him to the bigBorder - return bigBorder - borderManager.getBuffer(); - } - else - { - // if player is outside of the smallBorder, teleport him to the smallBorder - return smallBorder + borderManager.getBuffer(); - } - } - } - private Double goUpUntilFreeSpot( Player player ) { // go up in height until the player can stand in AIR @@ -82,14 +49,19 @@ public class PlayerMoveListener implements Listener return; } - // do nothing if there is no border defined + // do nothing if there are no border definitions at all if ( borderManager.getBorders() == null ) { return; } - Location pl = e.getPlayer().getLocation(); + // player location + Location playerLocation = e.getPlayer().getLocation(); + + // world where the player is in String worldName = e.getPlayer().getWorld().getName(); + + // borders of this world ArrayList borderPoints = borderManager.getBorders().get(worldName); // do nothing if there are no borders for this specific world @@ -97,29 +69,30 @@ public class PlayerMoveListener implements Listener return; // change x or z. default: do not change - Double newX, newY, newZ; + Double[] newXZ; - newX = checkBorder(pl.getX(), borderPoints.get(0).getX(), borderPoints.get(1).getX()); - newZ = checkBorder(pl.getZ(), borderPoints.get(0).getZ(), borderPoints.get(1).getZ()); + // check if player is inside the borders. null if yes, otherwise a tuple which defines the new player position + newXZ = borderManager.checkBorder(playerLocation, borderPoints, borderManager.getBuffer()); // Do nothing, if no new coordinates have been calculated. - if ( newX == null && newZ == null ) + if ( newXZ == null ) { return; } // if one of the coordinates is null, set it to the player's value - newX = newX == null ? pl.getX() : newX; - newZ = newZ == null ? pl.getZ() : newZ; + newXZ[0] = newXZ[0] == null ? playerLocation.getX() : newXZ[0]; + newXZ[1] = newXZ[1] == null ? playerLocation.getZ() : newXZ[1]; // change Y if necessary (when there is no free spot) - newY = goUpUntilFreeSpot(e.getPlayer()); + Double newY = goUpUntilFreeSpot(e.getPlayer()); // teleport the player to the new X and Z coordinates e.getPlayer().teleport( - new Location(e.getPlayer().getWorld(), newX, newY, newZ, pl.getYaw(), pl.getPitch())); + new Location(e.getPlayer().getWorld(), newXZ[0], newY, newXZ[1], playerLocation.getYaw(), + playerLocation.getPitch())); // send a message to the player - e.getPlayer().sendMessage(Messages.borderMessage); + borderManager.showMessageWithTimeout(e.getPlayer(), Messages.borderMessage); } } diff --git a/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java b/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java new file mode 100644 index 0000000..adda49a --- /dev/null +++ b/src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java @@ -0,0 +1,64 @@ +package de.craftinc.borderprotection; + +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; + +import java.util.ArrayList; + +public class PlayerTeleportListener implements Listener +{ + private BorderManager borderManager; + + public PlayerTeleportListener( BorderManager borderManager ) + { + this.borderManager = borderManager; + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerMove( PlayerTeleportEvent e ) + { + // do nothing if player has the ignoreborders permission + if ( e.getPlayer().hasPermission("craftinc.borderprotection.ignoreborders") ) + { + return; + } + + // do nothing if there are no border definitions at all + if ( borderManager.getBorders() == null ) + { + return; + } + + // target location + Location targetLocation = e.getTo(); + + // world where the player is in + String worldName = targetLocation.getWorld().getName(); + + // borders of this world + ArrayList borderPoints = borderManager.getBorders().get(worldName); + + // do nothing if there are no borders for this specific world + if ( borderPoints == null ) + { + return; + } + + // change x or z. default: do not change + Double[] newXZ; + + // check if target is inside the borders. null if yes, otherwise a tuple which defines the new position + newXZ = borderManager.checkBorder(targetLocation, borderPoints, borderManager.getBuffer()); + + + // Cancel event, if new coordinates have been calculated. + if ( newXZ != null ) + { + e.setCancelled(true); + borderManager.showMessageWithTimeout(e.getPlayer(), Messages.borderTeleportMessage); + } + } +} diff --git a/src/main/java/de/craftinc/borderprotection/Plugin.java b/src/main/java/de/craftinc/borderprotection/Plugin.java index f0d9888..734214e 100644 --- a/src/main/java/de/craftinc/borderprotection/Plugin.java +++ b/src/main/java/de/craftinc/borderprotection/Plugin.java @@ -23,11 +23,16 @@ public class Plugin extends JavaPlugin Plugin.cibpPlugin = this; BorderManager borderManager = new BorderManager(); - PlayerMoveListener eventListener = new PlayerMoveListener(borderManager); - Commands commandExecutor = new Commands(borderManager); + PlayerMoveListener playerMoveListener = new PlayerMoveListener(borderManager); + PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener(borderManager); - PluginManager pm = this.getServer().getPluginManager(); + // commands + Commands commandExecutor = new Commands(borderManager); getCommand("cibp").setExecutor(commandExecutor); - pm.registerEvents(eventListener, this); + + // listeners + PluginManager pm = this.getServer().getPluginManager(); + pm.registerEvents(playerMoveListener, this); + pm.registerEvents(playerTeleportListener, this); } } diff --git a/src/main/java/de/craftinc/borderprotection/Util.java b/src/main/java/de/craftinc/borderprotection/Util.java index d898fee..8d16df9 100644 --- a/src/main/java/de/craftinc/borderprotection/Util.java +++ b/src/main/java/de/craftinc/borderprotection/Util.java @@ -17,6 +17,11 @@ public class Util for ( Object jsonEntry : json.toArray() ) { JSONObject j = (JSONObject) jsonEntry; +// // check if border for this world is enabled. continue if not +// String enabled = (String) j.get("enabled"); +// if (enabled != "1") { +// continue; +// } String worldname = (String) j.get("worldname"); ArrayList locations = new ArrayList(); JSONArray borderPoints = (JSONArray) j.get("borderPoints"); @@ -32,18 +37,20 @@ public class Util data.put(worldname, locations); } - if (data.size() > 0) { + if ( data.size() > 0 ) + { return data; } return null; } - public static JSONArray encodeJSON( HashMap> data ) + public static JSONArray encodeJSON( HashMap> data ) { JSONArray json = new JSONArray(); int i = 0; - for (ArrayList border: data.values()) { + for ( ArrayList border : data.values() ) + { // add point 1 as json array JSONArray point1 = new JSONArray(); @@ -62,15 +69,19 @@ public class Util // Add points and worldname to world json object JSONObject borderOfAWorld = new JSONObject(); - try { + try + { borderOfAWorld.put("worldname", border.get(0).getWorld().getName()); borderOfAWorld.put("borderPoints", points); json.add(i, borderOfAWorld); i++; } - catch (NullPointerException e) { - if (border.get(0).getWorld() == null) { - Plugin.getPlugin().getLogger().warning("A world is null. Ignoring this border (not saving this border)."); + catch ( NullPointerException e ) + { + if ( border.get(0).getWorld() == null ) + { + Plugin.getPlugin().getLogger() + .warning("A world is null. Ignoring this border (not saving this border)."); } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cb05d4a..628914c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: CraftincBorderProtection main: de.craftinc.borderprotection.Plugin -version: 0.9.5 +version: 0.9.9 author: ddidderr website: http://www.craftinc.de/plugins/borderprotection