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 c9f8320b..cea61323 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 @@ -23,6 +23,8 @@ public interface ConfigRepository { int getProtectionRadius(); + boolean blockSpectatorMode(); + boolean getStopWaterFlow(); boolean getPortalProtection(); 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 fec9e231..9037502c 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 @@ -134,6 +134,11 @@ public boolean getDisablePhysicsEvents() { return this.config.disablePhysicsEvents; } + @Override + public boolean blockSpectatorMode() { + return this.config.blockSpectatorMode; + } + @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 9b4cfe3d..ad638b20 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 @@ -24,6 +24,8 @@ public class Config { public boolean disablePhysicsEvents = true; + public boolean blockSpectatorMode = true; + public int maxPortalVisualisationSize = 1000; public int maxSelectionVisualisationSize = 9000; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java index cb78170e..7fb0335f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java @@ -2,6 +2,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import com.sekwah.advancedportals.core.connector.containers.GameMode; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.portal.AdvancedPortal; import com.sekwah.advancedportals.core.registry.TagRegistry; @@ -102,6 +103,10 @@ public enum PortalActivationResult { public PortalActivationResult checkPortalActivation( PlayerContainer player, PlayerLocation toLoc, TriggerType triggerType) { + if(configRepository.blockSpectatorMode() && player.getGameMode() == GameMode.SPECTATOR) { + return PortalActivationResult.NOT_IN_PORTAL; + } + var blockLoc = toLoc.toBlockPos(); var blockEntityTopLoc = blockLoc.addY(player.getHeight()); var world = player.getWorld();