From 126d9ed7f6713b65d95bd0b1a8479a0d965d35a3 Mon Sep 17 00:00:00 2001 From: cs8425 Date: Wed, 23 Jun 2021 22:20:21 +0800 Subject: [PATCH 1/2] add PortalIntercept option --- .../MultiverseCore/MultiverseCore.java | 5 +++++ .../MultiverseCoreConfiguration.java | 19 +++++++++++++++++++ .../api/MultiverseCoreConfig.java | 12 ++++++++++++ .../listeners/MVPlayerListener.java | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index bc39f40ed..387fb8da6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -480,6 +480,11 @@ private void migrate22Values() { this.getMVConfig().setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept")); this.multiverseConfig.set("teleportintercept", null); } + if (this.multiverseConfig.isSet("portalintercept")) { + Logging.config("Migrating 'portalintercept'..."); + this.getMVConfig().setPortalIntercept(this.multiverseConfig.getBoolean("portalintercept")); + this.multiverseConfig.set("portalintercept", null); + } if (this.multiverseConfig.isSet("firstspawnoverride")) { Logging.config("Migrating 'firstspawnoverride'..."); this.getMVConfig().setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride")); diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java index a5fa94791..478520e24 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java @@ -52,6 +52,8 @@ public static MultiverseCoreConfiguration getInstance() { @Property private volatile boolean teleportintercept; @Property + private volatile boolean portalintercept; + @Property private volatile boolean firstspawnoverride; @Property private volatile boolean displaypermerrors; @@ -99,6 +101,7 @@ protected void setDefaults() { prefixchat = false; prefixchatformat = "[%world%]%chat%"; teleportintercept = true; + portalintercept = true; firstspawnoverride = true; displaypermerrors = true; enablebuscript = true; @@ -192,6 +195,22 @@ public void setTeleportIntercept(boolean teleportIntercept) { this.teleportintercept = teleportIntercept; } + /** + * {@inheritDoc} + */ + @Override + public boolean getPortalIntercept() { + return this.portalintercept; + } + + /** + * {@inheritDoc} + */ + @Override + public void setPortalIntercept(boolean portalIntercept) { + this.portalintercept = portalIntercept; + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java index 07b2bb91d..f12d432bc 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java @@ -122,6 +122,18 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable { */ boolean getTeleportIntercept(); + /** + * Sets portalIntercept. + * @param portalIntercept The new value. + */ + void setPortalIntercept(boolean portalIntercept); + + /** + * Gets portalIntercept. + * @return portalIntercept. + */ + boolean getPortalIntercept(); + /** * Sets prefixChat. * @param prefixChat The new value. diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index 2921f9c56..fdc0cb314 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -300,7 +300,7 @@ public void playerPortal(PlayerPortalEvent event) { + "' because they don't have the FUNDS required to enter."); return; } - if (plugin.getMVConfig().getEnforceAccess()) { + if (plugin.getMVConfig().getEnforceAccess() && plugin.getMVConfig().getPortalIntercept()) { event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer())); if (event.isCancelled()) { Logging.fine("Player '" + event.getPlayer().getName() From c714f357aedac9c354f1d7dc7977724580147c41 Mon Sep 17 00:00:00 2001 From: cs8425 Date: Wed, 23 Jun 2021 22:37:51 +0800 Subject: [PATCH 2/2] disable sendPlayerToDefaultWorld() if not intercept Teleport or Portal --- .../onarandombox/MultiverseCore/listeners/MVPlayerListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index fdc0cb314..f3c362b92 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -128,6 +128,7 @@ public void playerJoin(PlayerJoinEvent event) { } else { Logging.finer("Player joined AGAIN!"); if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access! + && (this.plugin.getMVConfig().getTeleportIntercept() && this.plugin.getMVConfig().getPortalIntercept()) // only all method Intercept will force send && !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) { p.sendMessage("[MV] - Sorry you can't be in this world anymore!"); this.sendPlayerToDefaultWorld(p);