Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add portal intercept option #2650

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,6 +101,7 @@ protected void setDefaults() {
prefixchat = false;
prefixchatformat = "[%world%]%chat%";
teleportintercept = true;
portalintercept = true;
firstspawnoverride = true;
displaypermerrors = true;
enablebuscript = true;
Expand Down Expand Up @@ -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}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -300,7 +301,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()
Expand Down