From 155aad8bf22ed96712b3658102a8bb2a2540aeea Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Wed, 14 Nov 2012 13:52:37 -0500 Subject: [PATCH] Multiverse now uses it's own portal search radius by default (16 blocks instead of bukkit's 128). 2 new configuration options added to adjust this behaviour. --- .../MultiverseCoreConfiguration.java | 26 +++++++++++++++++ .../api/MultiverseCoreConfig.java | 28 +++++++++++++++++++ .../listeners/MVPlayerListener.java | 3 ++ 3 files changed, 57 insertions(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java index 74add175..2439468b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java @@ -63,6 +63,10 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements private volatile String firstspawnworld; @Property private volatile int teleportcooldown; + @Property + private volatile boolean defaultportalsearch; + @Property + private volatile int portalsearchradius; public MultiverseCoreConfiguration() { super(); @@ -91,6 +95,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements teleportcooldown = 1000; this.version = 2.9; silentstart = false; + defaultportalsearch = false; + portalsearchradius = 16; // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck } @@ -289,4 +295,24 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements public boolean getSilentStart() { return silentstart; } + + @Override + public void setUseDefaultPortalSearch(boolean useDefaultPortalSearch) { + defaultportalsearch = useDefaultPortalSearch; + } + + @Override + public boolean isUsingDefaultPortalSearch() { + return defaultportalsearch; + } + + @Override + public void setPortalSearchRadius(int searchRadius) { + this.portalsearchradius = searchRadius; + } + + @Override + public int getPortalSearchRadius() { + return portalsearchradius; + } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java index 6b56e348..24875b5d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java @@ -159,4 +159,32 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable { * @return true if we are suppressing startup messages. */ boolean getSilentStart(); + + /** + * Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input. + * + * @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own. + */ + void setUseDefaultPortalSearch(boolean useDefaultPortalSearch); + + /** + * Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help. + * + * @return True means Bukkit will use its own default values. + */ + boolean isUsingDefaultPortalSearch(); + + /** + * Sets the radius at which vanilla style portals will be searched for to connect to worlds together. + * + * @param searchRadius The portal search radius. + */ + void setPortalSearchRadius(int searchRadius); + + /** + * Gets the radius at which vanilla style portals will be searched for to connect to worlds together. + * + * @return The portal search radius. + */ + int getPortalSearchRadius(); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index 6b0055f4..fc04af9f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -299,6 +299,9 @@ public class MVPlayerListener implements Listener { + "' was allowed to go to '" + event.getTo().getWorld().getName() + "' because enforceaccess is off."); } + if (!plugin.getMVConfig().isUsingDefaultPortalSearch()) { + event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius()); + } } private void sendPlayerToDefaultWorld(final Player player) {