Allow for stricter movement check; resolves #802

This commit is contained in:
Daniel Saukel 2020-06-19 22:33:51 +02:00
parent 5cc5073062
commit c84f3564d5
3 changed files with 28 additions and 11 deletions

View File

@ -48,7 +48,7 @@ public class MainConfig extends DREConfig {
NEVER NEVER
} }
public static final int CONFIG_VERSION = 19; public static final int CONFIG_VERSION = 20;
private String language = "english"; private String language = "english";
private boolean enableEconomy = false; private boolean enableEconomy = false;
@ -97,6 +97,7 @@ public class MainConfig extends DREConfig {
/* Performance */ /* Performance */
private int maxInstances = 10; private int maxInstances = 10;
private int editInstanceRemovalDelay = 5; private int editInstanceRemovalDelay = 5;
private boolean strictMovementCheckEnabled = true;
/* Secure Mode */ /* Secure Mode */
private boolean secureModeEnabled = false; private boolean secureModeEnabled = false;
@ -282,6 +283,14 @@ public class MainConfig extends DREConfig {
editInstanceRemovalDelay = delay; editInstanceRemovalDelay = delay;
} }
public boolean isStrictMovementCheckEnabled() {
return strictMovementCheckEnabled;
}
public void setStrictMovementCheckEnabled(boolean enabled) {
strictMovementCheckEnabled = enabled;
}
public boolean isSecureModeEnabled() { public boolean isSecureModeEnabled() {
return secureModeEnabled; return secureModeEnabled;
} }
@ -435,6 +444,10 @@ public class MainConfig extends DREConfig {
config.set("editInstanceRemovalDelay", editInstanceRemovalDelay); config.set("editInstanceRemovalDelay", editInstanceRemovalDelay);
} }
if (!config.contains("strictMovementCheckEnabled")) {
config.set("strictMovementCheckEnabled", strictMovementCheckEnabled);
}
if (!config.contains("secureMode.enabled")) { if (!config.contains("secureMode.enabled")) {
config.set("secureMode.enabled", secureModeEnabled); config.set("secureMode.enabled", secureModeEnabled);
} }
@ -528,6 +541,7 @@ public class MainConfig extends DREConfig {
maxInstances = config.getInt("maxInstances", maxInstances); maxInstances = config.getInt("maxInstances", maxInstances);
editInstanceRemovalDelay = config.getInt("editInstanceRemovalDelay", editInstanceRemovalDelay); editInstanceRemovalDelay = config.getInt("editInstanceRemovalDelay", editInstanceRemovalDelay);
strictMovementCheckEnabled = config.getBoolean("strictMovementCheckEnabled", strictMovementCheckEnabled);
secureModeEnabled = config.getBoolean("secureMode.enabled", secureModeEnabled); secureModeEnabled = config.getBoolean("secureMode.enabled", secureModeEnabled);
openInventories = config.getBoolean("secureMode.openInventories", openInventories); openInventories = config.getBoolean("secureMode.openInventories", openInventories);
dropItems = config.getBoolean("secureMode.dropItems", dropItems); dropItems = config.getBoolean("secureMode.dropItems", dropItems);

View File

@ -243,13 +243,13 @@ public class DPortal extends GlobalProtection {
PlayerGroup group = plugin.getPlayerGroup(player); PlayerGroup group = plugin.getPlayerGroup(player);
if (group == null) { if (group == null) {
MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage()); MessageUtil.sendActionBarMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
return; return;
} }
Dungeon dungeon = group.getDungeon(); Dungeon dungeon = group.getDungeon();
if (dungeon == null) { if (dungeon == null) {
MessageUtil.sendMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); MessageUtil.sendActionBarMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage());
return; return;
} }
@ -277,7 +277,7 @@ public class DPortal extends GlobalProtection {
if (resource != null) { if (resource != null) {
target = resource.instantiateGameWorld(false); target = resource.instantiateGameWorld(false);
if (target == null) { if (target == null) {
MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage()); MessageUtil.sendActionBarMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage());
return; return;
} }
group.setGameWorld(target); group.setGameWorld(target);
@ -285,7 +285,7 @@ public class DPortal extends GlobalProtection {
} }
if (target == null) { if (target == null) {
MessageUtil.sendMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); MessageUtil.sendActionBarMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage());
return; return;
} }

View File

@ -148,14 +148,17 @@ public class GlobalProtectionListener implements Listener {
if (DPlayerListener.isCitizensNPC(player)) { if (DPlayerListener.isCitizensNPC(player)) {
return; return;
} }
DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation());
if (dPortal == null) { if (!plugin.getMainConfig().isStrictMovementCheckEnabled()) {
return; Block blockFrom = event.getFrom().getBlock();
Block blockTo = event.getTo().getBlock();
if (blockFrom.equals(blockTo)) {
return;
}
} }
Block blockFrom = event.getFrom().getBlock(); DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation());
Block blockTo = event.getTo().getBlock(); if (dPortal == null) {
if (blockFrom.equals(blockTo)) {
return; return;
} }