diff --git a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java index 16124d0a..a2e10fe9 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java @@ -194,4 +194,8 @@ public class CoreListeners { pos.addY((int) entity.getHeight()), 1); return !(feetInPortal || headInPortal); } + + public boolean physicsEvent(BlockLocation blockLocation, String string) { + return !configRepository.getDisablePhysicsEvents() || !portalServices.inPortalRegionProtected(blockLocation); + } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java index 47af562d..c82ef922 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java @@ -100,7 +100,7 @@ public class ShowDestiSubCommand if (Objects.equals(pos.getWorldName(), player.getWorldName()) && pos.distanceTo(player.getLoc()) - < config.getVisibleRange()) { + < config.getShowVisibleRange()) { Debug.addMarker(player, pos.toBlockPos(), destination.getArgValues("name")[0], new Color(100, 100, 100, 100), 1300); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java index 24dceab2..c8ee98d9 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java @@ -138,7 +138,7 @@ public class ShowPortalSubCommand if (Objects.equals(portal.getMinLoc().getWorldName(), player.getWorldName()) && portal.isLocationInPortal( - player.getLoc(), config.getVisibleRange())) { + player.getLoc(), config.getShowVisibleRange())) { BlockLocation minLoc = portal.getMinLoc(); BlockLocation maxLoc = portal.getMaxLoc(); int midX = (minLoc.getPosX() + maxLoc.getPosX()) / 2; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java index 335f0f6a..dfec9dcd 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java @@ -12,7 +12,7 @@ public interface ConfigRepository { void loadConfig(DataStorage dataStorage); - int getVisibleRange(); + int getShowVisibleRange(); int getMaxTriggerVisualisationSize(); @@ -34,5 +34,7 @@ public interface ConfigRepository { void storeConfig(); + boolean getDisablePhysicsEvents(); + CommandPortalConfig getCommandPortals(); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java index c2ffc783..b79dc54e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java @@ -41,8 +41,8 @@ public class ConfigRepositoryImpl implements ConfigRepository { } @Override - public int getVisibleRange() { - return this.config.visibleRange; + public int getShowVisibleRange() { + return this.config.showVisibleRange; } @Override @@ -96,6 +96,11 @@ public class ConfigRepositoryImpl implements ConfigRepository { return this.config.playFailSound; } + @Override + public boolean getDisablePhysicsEvents() { + return this.config.disablePhysicsEvents; + } + @Override public CommandPortalConfig getCommandPortals() { return this.config.commandPortals; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/Config.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/Config.java index 06191c47..77fc0806 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/Config.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/Config.java @@ -22,11 +22,11 @@ public class Config { public String warpSound = "ENDER"; - public String selectionBlock = "RED_STAINED_GLASS"; - public String translationFile = "en_GB"; - public int visibleRange = 50; + public int showVisibleRange = 50; + + public boolean disablePhysicsEvents = true; public int maxTriggerVisualisationSize = 1000; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java index 91ff717a..4f21184a 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java @@ -10,10 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.*; import org.bukkit.event.entity.*; import org.bukkit.event.player.*; @@ -52,6 +49,15 @@ public class Listeners implements Listener { } } + @EventHandler(priority = EventPriority.HIGH) + public void onPhysicsEvent(BlockPhysicsEvent event) { + if (!coreListeners.physicsEvent(ContainerHelpers.toBlockLocation( + event.getBlock().getLocation()), + event.getBlock().getType().toString())) { + event.setCancelled(true); + } + } + @EventHandler public void onWorldChangeEvent(PlayerChangedWorldEvent event) { coreListeners.worldChange(new SpigotPlayerContainer(event.getPlayer()));