mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 02:25:49 +01:00
feat: configure portal effects
This commit is contained in:
parent
d687e88e65
commit
a2f6574224
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ public interface ConfigRepository {
|
||||
|
||||
boolean warpMessageInChat();
|
||||
|
||||
String getWarpParticles();
|
||||
String getWarpVisual();
|
||||
|
||||
boolean getWarpEffectEnabled();
|
||||
|
||||
boolean getEnableProxySupport();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user