From 33b49a234977fd77589d065e5d93b456d1e00ac7 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 24 Apr 2021 08:45:05 -0700 Subject: [PATCH] Set minimum portal search radius to 8. Added config option. https://github.com/BentoBoxWorld/BentoBox/issues/1747 --- .../world/bentobox/bentobox/Settings.java | 35 ++++++++++++++----- .../PortalTeleportationListener.java | 3 +- src/main/resources/config.yml | 22 +++++++++--- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/Settings.java b/src/main/java/world/bentobox/bentobox/Settings.java index 4f1f12ccd..3fd6e2102 100644 --- a/src/main/java/world/bentobox/bentobox/Settings.java +++ b/src/main/java/world/bentobox/bentobox/Settings.java @@ -248,6 +248,11 @@ public class Settings implements ConfigObject { @ConfigEntry(path = "island.clear-radius", since = "1.6.0") private int clearRadius = 5; + @ConfigComment("Minimum nether portal search radius. This should not be less that 8 otherwise duplicate") + @ConfigComment("portals can occur") + @ConfigEntry(path = "island.portal-search-radius", since = "1.17.0") + private int minPortalSearchRadius = 8; + @ConfigComment("Number of blocks to paste per tick when pasting blueprints.") @ConfigComment("Smaller values will help reduce noticeable lag but will make pasting take slightly longer.") @ConfigComment("On the contrary, greater values will make pasting take less time, but this benefit is quickly severely impacted by the") @@ -778,27 +783,27 @@ public class Settings implements ConfigObject { } - /** + /** * Method Settings#getPlayerHeadCacheTime returns the playerHeadCacheTime of this object. * * @return the playerHeadCacheTime (type long) of this object. * @since 1.14.1 */ public long getPlayerHeadCacheTime() - { - return playerHeadCacheTime; - } + { + return playerHeadCacheTime; + } - /** + /** * Method Settings#setPlayerHeadCacheTime sets new value for the playerHeadCacheTime of this object. * @param playerHeadCacheTime new value for this object. * @since 1.14.1 */ public void setPlayerHeadCacheTime(long playerHeadCacheTime) - { - this.playerHeadCacheTime = playerHeadCacheTime; - } + { + this.playerHeadCacheTime = playerHeadCacheTime; + } /** @@ -871,4 +876,18 @@ public class Settings implements ConfigObject { { this.ticksBetweenCalls = ticksBetweenCalls; } + + /** + * @return the minPortalSearchRadius + */ + public int getMinPortalSearchRadius() { + return minPortalSearchRadius; + } + + /** + * @param minPortalSearchRadius the minPortalSearchRadius to set + */ + public void setMinPortalSearchRadius(int minPortalSearchRadius) { + this.minPortalSearchRadius = minPortalSearchRadius; + } } diff --git a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java index 52cc0d3ad..546cb2568 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java @@ -424,7 +424,8 @@ public class PortalTeleportationListener implements Listener { // Find max x or max z int x = Math.abs(i.getProtectionCenter().getBlockX() - e.getFrom().getBlockX()); int z = Math.abs(i.getProtectionCenter().getBlockZ() - e.getFrom().getBlockZ()); - int diff = i.getProtectionRange() - Math.max(x, z); + int diff = Math.max(plugin.getSettings().getMinPortalSearchRadius(), i.getProtectionRange() - Math.max(x, z)); + BentoBox.getInstance().logDebug("Search radius = " + diff); if (diff > 0 && diff < 128) { e.setSearchRadius(diff); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 37b6f67b2..8d785df46 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,10 +1,10 @@ -# BentoBox v1.14.1-SNAPSHOT-LOCAL configuration file. -# +# BentoBox {$version} configuration file. +# # This configuration file contains settings that mainly apply to or manage the following elements: # * Data storage # * Gamemodes (commands, ...) # * Internet connectivity (web-based content-enriched features, ...) -# +# # Note that this configuration file is dynamic: # * It gets updated with the newest settings and comments after BentoBox loaded its settings from it. # * Upon updating BentoBox, new settings will be automatically added into this configuration file. @@ -13,7 +13,7 @@ # * They are provided with default values that should not cause issues on live production servers. # * You can however edit this file while the server is online. # You will therefore need to run the following command in order to take the changes into account: /bentobox reload. -# +# # Here are a few pieces of advice before you get started: # * You should check out our Wiki, which may provide you useful tips or insights about BentoBox's features. # Link: https://github.com/BentoBoxWorld/BentoBox/wiki @@ -58,6 +58,14 @@ general: # This helps prevent issues if the server crashes. # Data is also saved at important points in the game. backup-period: 5 + # How many players will be saved in one tick. Default is 200 + # Reduce if you experience lag while saving. + # Do not set this too low or data might get lost! + max-saved-players-per-tick: 20 + # How many islands will be saved in one tick. Default is 200 + # Reduce if you experience lag while saving. + # Do not set this too low or data might get lost! + max-saved-islands-per-tick: 20 # Enable SSL connection to MongoDB, MariaDB, MySQL and PostgreSQL databases. # Added since 1.12.0. use-ssl: false @@ -75,7 +83,7 @@ general: # Add other fake player names here if required # /!\ This feature is experimental and might not work as expected or might not work at all. fakeplayers: - - '[CoFH]' + - '[CoFH]' panel: # Toggle whether panels should be closed or not when the player clicks anywhere outside of the inventory view. close-on-click-outside: true @@ -161,6 +169,10 @@ island: # Be careful not to make this too big. Does not cover standard nether or end teleports. # Added since 1.6.0. clear-radius: 5 + # Minimum nether portal search radius. This should not be less that 8 otherwise duplicate + # can occur. + # Added since 1.17.0. + portal-search-radius: 8 # Number of blocks to paste per tick when pasting blueprints. # Smaller values will help reduce noticeable lag but will make pasting take slightly longer. # On the contrary, greater values will make pasting take less time, but this benefit is quickly severely impacted by the