From 4ef0a2e54150ef708725d6be3d3092ed845830fd Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 7 Mar 2021 12:38:07 -0800 Subject: [PATCH 1/4] Use release version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 114692a..70759d8 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 1.7.4 1.16.1-R0.1-SNAPSHOT - 1.16.0-SNAPSHOT + 1.16.0 ${build.version}-SNAPSHOT From ec5514a8aff55371d3c9b884efe2f923c7cd6c81 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 7 Mar 2021 12:39:29 -0800 Subject: [PATCH 2/4] Version 3.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70759d8..5e58e86 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ ${build.version}-SNAPSHOT - 3.0.0 + 3.0.1 -LOCAL BentoBoxWorld_Border From d386bae4392563df5ec87dff55cfca7a29ca57ec Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 18 Apr 2021 08:21:53 -0700 Subject: [PATCH 3/4] Version 3.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e58e86..c8ec4a8 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ ${build.version}-SNAPSHOT - 3.0.1 + 3.1.0 -LOCAL BentoBoxWorld_Border From a342c61576e0678b9a6ca4219c0a0eed557a3fc3 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 18 Apr 2021 08:23:55 -0700 Subject: [PATCH 4/4] Adds config option to teleport players back who go outside the border. --- .../java/world/bentobox/border/Settings.java | 21 +++++++++++++++++++ .../border/listeners/PlayerListener.java | 14 ++++++++----- src/main/resources/config.yml | 6 +++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/border/Settings.java b/src/main/java/world/bentobox/border/Settings.java index b3b3345..af8fb04 100644 --- a/src/main/java/world/bentobox/border/Settings.java +++ b/src/main/java/world/bentobox/border/Settings.java @@ -11,6 +11,7 @@ @StoreAt(filename = "config.yml", path = "addons/Border") public class Settings implements ConfigObject { + @ConfigComment("Border Configuration file by tastybento") @ConfigComment("") @ConfigComment("This list stores GameModes in which Border addon should not work.") @ConfigComment("To disable addon it is necessary to write its name in new line that starts with -. Example:") @@ -25,6 +26,12 @@ public class Settings implements ConfigObject { @ConfigEntry(path = "use-wbapi") private boolean useWbapi = false; + @ConfigComment("") + @ConfigComment("Teleport players back inside the border if they somehow get outside.") + @ConfigComment("This will teleport players back inside if they toggle the border with a command.") + @ConfigEntry(path = "return-teleport") + private boolean returnTeleport = true; + @ConfigComment("") @ConfigComment("Use barrier blocks. If false, the border is indicated by particles only.") @ConfigComment("Only applicable if vanilla world border is not used") @@ -112,4 +119,18 @@ public boolean isUseWbapi() { public void setUseWbapi(boolean useWbapi) { this.useWbapi = useWbapi; } + + /** + * @return the returnTeleport + */ + public boolean isReturnTeleport() { + return returnTeleport; + } + + /** + * @param returnTeleport the returnTeleport to set + */ + public void setReturnTeleport(boolean returnTeleport) { + this.returnTeleport = returnTeleport; + } } diff --git a/src/main/java/world/bentobox/border/listeners/PlayerListener.java b/src/main/java/world/bentobox/border/listeners/PlayerListener.java index 97c7672..e82a85c 100644 --- a/src/main/java/world/bentobox/border/listeners/PlayerListener.java +++ b/src/main/java/world/bentobox/border/listeners/PlayerListener.java @@ -71,12 +71,9 @@ public void onPlayerTeleport(PlayerTeleportEvent e) { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerLeaveIsland(PlayerMoveEvent e) { - if (addon.getSettings().isUseWbapi()) { - return; - } Player p = e.getPlayer(); Location from = e.getFrom(); - if (!outsideCheck(e.getPlayer(), from, e.getTo())) { + if (!addon.getSettings().isReturnTeleport() || !outsideCheck(e.getPlayer(), from, e.getTo())) { return; } // Move the player back inside the border @@ -101,9 +98,16 @@ public void onPlayerLeaveIsland(PlayerMoveEvent e) { } + /** + * Check if the player is outside the island protection zone that they are supposed to be in. + * @param player - player moving + * @param from - from location + * @param to - to location + * @return true if outside the island protection zone + */ private boolean outsideCheck(Player player, Location from, Location to) { User user = User.getInstance(player); - // Only process if there is a change in X or Z coords + if ((from.getWorld() != null && from.getWorld().equals(to.getWorld()) && from.toVector().multiply(XZ).equals(to.toVector().multiply(XZ))) || !addon.getSettings().isUseBarrierBlocks() diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6be3af8..8fb66e7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -8,10 +8,14 @@ disabled-gamemodes: [] # Use vanilla world border. Requires WorldBorderAPI plugin. # Download from https://github.com/yannicklamprecht/WorldBorderAPI/releases use-wbapi: true +# +# Teleport players back inside the border if they somehow get outside. +# This will teleport players back inside if they toggle the border with a command. +return-teleport: true # # Use barrier blocks. If false, the border is indicated by particles only. # Only applicable if vanilla world border is not used -use-barrier-blocks: true +use-barrier-blocks: false # # Default border behavior show-by-default: true