fix: disable spectators triggering portals by default

Fixes #491
This commit is contained in:
Sekwah 2024-12-15 04:53:18 +00:00
parent 51b725ea58
commit f44f3fb7d6
4 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,8 @@ public interface ConfigRepository {
int getProtectionRadius();
boolean blockSpectatorMode();
boolean getStopWaterFlow();
boolean getPortalProtection();

View File

@ -134,6 +134,11 @@ public class ConfigRepositoryImpl implements ConfigRepository {
return this.config.disablePhysicsEvents;
}
@Override
public boolean blockSpectatorMode() {
return this.config.blockSpectatorMode;
}
@Override
public CommandPortalConfig getCommandPortals() {
return this.config.commandPortals;

View File

@ -24,6 +24,8 @@ public class Config {
public boolean disablePhysicsEvents = true;
public boolean blockSpectatorMode = true;
public int maxPortalVisualisationSize = 1000;
public int maxSelectionVisualisationSize = 9000;

View File

@ -2,6 +2,7 @@ package com.sekwah.advancedportals.core.services;
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 class PortalServices {
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();