Skip to content

Commit

Permalink
fix: disable spectators triggering portals by default
Browse files Browse the repository at this point in the history
Fixes #491
  • Loading branch information
sekwah41 committed Dec 15, 2024
1 parent 51b725e commit f44f3fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface ConfigRepository {

int getProtectionRadius();

boolean blockSpectatorMode();

boolean getStopWaterFlow();

boolean getPortalProtection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Config {

public boolean disablePhysicsEvents = true;

public boolean blockSpectatorMode = true;

public int maxPortalVisualisationSize = 1000;

public int maxSelectionVisualisationSize = 9000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f44f3fb

Please sign in to comment.