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 8399fba8..0a55ad34 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java @@ -68,7 +68,7 @@ public class CoreListeners { switch (messageType) { case ProxyMessages.SERVER_DESTI -> { var serverDestiPacket = ServerDestiPacket.decode(buffer); - this.destinationServices.teleportToDestination(serverDestiPacket.getDestination(), player); + this.destinationServices.teleportToDestination(serverDestiPacket.getDestination(), player, true); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java b/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java index 3bedae3e..07b0634a 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java @@ -40,7 +40,7 @@ public class WarpEffectRegistry { } public WarpEffect.Visual getVisualEffect(String name) { - if (this.warpEffects.containsKey(name)) { + if (this.warpEffects.containsKey(name.toLowerCase())) { var effect = this.warpEffects.get(name); if (effect instanceof WarpEffect.Visual visual) { return visual; @@ -51,7 +51,7 @@ public class WarpEffectRegistry { } } else { this.infoLogger.warning("No effect called " + name - + " was registered"); + + " is registered"); return null; } } @@ -68,7 +68,7 @@ public class WarpEffectRegistry { } } else { this.infoLogger.warning("No effect called " + name - + " was registered"); + + " is registered"); return null; } } 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 2f2bf385..3dc6b3a6 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 @@ -44,7 +44,9 @@ public interface ConfigRepository { boolean warpMessageInChat(); - String getWarpParticles(); + String getWarpVisual(); + + boolean getWarpEffectEnabled(); boolean getEnableProxySupport(); } 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 50d23fa2..eb096cf3 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 @@ -87,12 +87,17 @@ public class ConfigRepositoryImpl implements ConfigRepository { @Override public String getWarpSound() { - return this.config.warpSound; + return this.config.warpEffect.soundEffect; } @Override - public String getWarpParticles() { - return this.config.warpParticles; + public String getWarpVisual() { + return this.config.warpEffect.visualEffect; + } + + @Override + public boolean getWarpEffectEnabled() { + return this.config.warpEffect.enabled; } @Override 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 bd321a01..d4d253b7 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 @@ -18,10 +18,6 @@ public class Config { public int joinCooldown = 5; - public String warpParticles = "ENDER"; - - public String warpSound = "ENDER"; - public String translationFile = "en_GB"; public int showVisibleRange = 50; @@ -41,4 +37,6 @@ public class Config { public CommandPortalConfig commandPortals = new CommandPortalConfig(); public boolean enableProxySupport = false; + + public WarpEffectConfig warpEffect = new WarpEffectConfig(); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/WarpEffectConfig.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/WarpEffectConfig.java new file mode 100644 index 00000000..53d47962 --- /dev/null +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/WarpEffectConfig.java @@ -0,0 +1,7 @@ +package com.sekwah.advancedportals.core.serializeddata.config; + +public class WarpEffectConfig { + public String visualEffect = "ender"; + public String soundEffect = "ender"; + public boolean enabled = true; +} diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java index 4d0addb2..b754a83f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java @@ -3,7 +3,10 @@ package com.sekwah.advancedportals.core.services; import com.google.inject.Inject; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.destination.Destination; +import com.sekwah.advancedportals.core.effect.WarpEffect; import com.sekwah.advancedportals.core.registry.TagRegistry; +import com.sekwah.advancedportals.core.registry.WarpEffectRegistry; +import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.repository.IDestinationRepository; import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; @@ -20,6 +23,12 @@ public class DestinationServices { @Inject private IDestinationRepository destinationRepository; + @Inject + private WarpEffectRegistry warpEffectRegistry; + + @Inject + private ConfigRepository configRepository; + @Inject TagRegistry tagRegistry; @@ -122,8 +131,23 @@ public class DestinationServices { public boolean teleportToDestination(String name, PlayerContainer playerContainer) { + return teleportToDestination(name, playerContainer, false); + } + + public boolean teleportToDestination(String name, + PlayerContainer player, boolean doEffect) { + if(doEffect && configRepository.getWarpEffectEnabled()) { + var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); + if (warpEffectVisual != null) { + warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); + } + var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); + if (warpEffectSound != null) { + warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); + } + } if (this.destinationRepository.containsKey(name)) { - playerContainer.teleport( + player.teleport( this.destinationRepository.get(name).getLoc()); return true; } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java index 9237272e..5d0d5315 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java @@ -128,20 +128,26 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { Destination destination = destinationServices.getDestination(selectedArg); if (destination != null) { - var warpEffectVisual = warpEffectRegistry.getVisualEffect("ender"); - if (warpEffectVisual != null) { - warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); - } - var warpEffectSound = warpEffectRegistry.getSoundEffect("ender"); - if (warpEffectSound != null) { - warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); + var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); + var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); + if(configRepository.getWarpEffectEnabled()) { + if (warpEffectVisual != null) { + warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); + } + if (warpEffectSound != null) { + warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); + } } + player.teleport(destination.getLoc()); - if (warpEffectVisual != null) { - warpEffectVisual.onWarpVisual(player, WarpEffect.Action.EXIT); - } - if (warpEffectSound != null) { - warpEffectSound.onWarpSound(player, WarpEffect.Action.EXIT); + + if(configRepository.getWarpEffectEnabled()) { + if (warpEffectVisual != null) { + warpEffectVisual.onWarpVisual(player, WarpEffect.Action.EXIT); + } + if (warpEffectSound != null) { + warpEffectSound.onWarpSound(player, WarpEffect.Action.EXIT); + } } activationData.setWarpStatus(ActivationData.WarpedStatus.WARPED); }