From c84f3564d575eadb1ae929bb003d67d763e2c601 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 19 Jun 2020 22:33:51 +0200 Subject: [PATCH] Allow for stricter movement check; resolves #802 --- .../de/erethon/dungeonsxl/config/MainConfig.java | 16 +++++++++++++++- .../de/erethon/dungeonsxl/global/DPortal.java | 8 ++++---- .../global/GlobalProtectionListener.java | 15 +++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/de/erethon/dungeonsxl/config/MainConfig.java b/core/src/main/java/de/erethon/dungeonsxl/config/MainConfig.java index cf1d085b..84cd12f4 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/config/MainConfig.java +++ b/core/src/main/java/de/erethon/dungeonsxl/config/MainConfig.java @@ -48,7 +48,7 @@ public class MainConfig extends DREConfig { NEVER } - public static final int CONFIG_VERSION = 19; + public static final int CONFIG_VERSION = 20; private String language = "english"; private boolean enableEconomy = false; @@ -97,6 +97,7 @@ public class MainConfig extends DREConfig { /* Performance */ private int maxInstances = 10; private int editInstanceRemovalDelay = 5; + private boolean strictMovementCheckEnabled = true; /* Secure Mode */ private boolean secureModeEnabled = false; @@ -282,6 +283,14 @@ public class MainConfig extends DREConfig { editInstanceRemovalDelay = delay; } + public boolean isStrictMovementCheckEnabled() { + return strictMovementCheckEnabled; + } + + public void setStrictMovementCheckEnabled(boolean enabled) { + strictMovementCheckEnabled = enabled; + } + public boolean isSecureModeEnabled() { return secureModeEnabled; } @@ -435,6 +444,10 @@ public class MainConfig extends DREConfig { config.set("editInstanceRemovalDelay", editInstanceRemovalDelay); } + if (!config.contains("strictMovementCheckEnabled")) { + config.set("strictMovementCheckEnabled", strictMovementCheckEnabled); + } + if (!config.contains("secureMode.enabled")) { config.set("secureMode.enabled", secureModeEnabled); } @@ -528,6 +541,7 @@ public class MainConfig extends DREConfig { maxInstances = config.getInt("maxInstances", maxInstances); editInstanceRemovalDelay = config.getInt("editInstanceRemovalDelay", editInstanceRemovalDelay); + strictMovementCheckEnabled = config.getBoolean("strictMovementCheckEnabled", strictMovementCheckEnabled); secureModeEnabled = config.getBoolean("secureMode.enabled", secureModeEnabled); openInventories = config.getBoolean("secureMode.openInventories", openInventories); dropItems = config.getBoolean("secureMode.dropItems", dropItems); diff --git a/core/src/main/java/de/erethon/dungeonsxl/global/DPortal.java b/core/src/main/java/de/erethon/dungeonsxl/global/DPortal.java index d0f68aed..84df4f5b 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/global/DPortal.java +++ b/core/src/main/java/de/erethon/dungeonsxl/global/DPortal.java @@ -243,13 +243,13 @@ public class DPortal extends GlobalProtection { PlayerGroup group = plugin.getPlayerGroup(player); if (group == null) { - MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage()); + MessageUtil.sendActionBarMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage()); return; } Dungeon dungeon = group.getDungeon(); if (dungeon == null) { - MessageUtil.sendMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); + MessageUtil.sendActionBarMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); return; } @@ -277,7 +277,7 @@ public class DPortal extends GlobalProtection { if (resource != null) { target = resource.instantiateGameWorld(false); if (target == null) { - MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage()); + MessageUtil.sendActionBarMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage()); return; } group.setGameWorld(target); @@ -285,7 +285,7 @@ public class DPortal extends GlobalProtection { } if (target == null) { - MessageUtil.sendMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); + MessageUtil.sendActionBarMessage(player, DMessage.ERROR_NO_SUCH_DUNGEON.getMessage()); return; } diff --git a/core/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java b/core/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java index 1e1c084a..afa9eb41 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java +++ b/core/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java @@ -148,14 +148,17 @@ public class GlobalProtectionListener implements Listener { if (DPlayerListener.isCitizensNPC(player)) { return; } - DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation()); - if (dPortal == null) { - return; + + if (!plugin.getMainConfig().isStrictMovementCheckEnabled()) { + Block blockFrom = event.getFrom().getBlock(); + Block blockTo = event.getTo().getBlock(); + if (blockFrom.equals(blockTo)) { + return; + } } - Block blockFrom = event.getFrom().getBlock(); - Block blockTo = event.getTo().getBlock(); - if (blockFrom.equals(blockTo)) { + DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation()); + if (dPortal == null) { return; }