From db17ba1bd2a083a12ffa09fc67350a86ce8add8a Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Wed, 4 Jan 2023 22:17:53 +0100 Subject: [PATCH] Added optimized default values for Via configs --- .../viaproxy/protocolhack/ProtocolHack.java | 7 ++-- .../ViaProxyViaBackwardsPlatformImpl.java | 23 ++++++++++++ .../impl/ViaProxyViaRewindPlatformImpl.java | 35 +++++++++++++++++++ .../impl/ViaProxyViaVersionPlatformImpl.java | 16 +++++++++ .../viaproxy/config_diff/viabackwards.yml | 4 +++ .../assets/viaproxy/config_diff/viarewind.yml | 4 +++ .../viaproxy/config_diff/viaversion.yml | 6 ++++ 7 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaBackwardsPlatformImpl.java create mode 100644 src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaRewindPlatformImpl.java create mode 100644 src/main/resources/assets/viaproxy/config_diff/viabackwards.yml create mode 100644 src/main/resources/assets/viaproxy/config_diff/viarewind.yml create mode 100644 src/main/resources/assets/viaproxy/config_diff/viaversion.yml diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java b/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java index 21fdf42..4681323 100644 --- a/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java @@ -1,14 +1,13 @@ package net.raphimc.viaproxy.protocolhack; import net.raphimc.viaprotocolhack.ViaProtocolHack; -import net.raphimc.viaprotocolhack.impl.platform.*; -import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVPLoader; -import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaVersionPlatformImpl; +import net.raphimc.viaprotocolhack.impl.platform.ViaLegacyPlatformImpl; +import net.raphimc.viaproxy.protocolhack.impl.*; public class ProtocolHack { public static void init() { - ViaProtocolHack.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVPLoader(), null, null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new); + ViaProtocolHack.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVPLoader(), null, null, ViaProxyViaBackwardsPlatformImpl::new, ViaProxyViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new); } } diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaBackwardsPlatformImpl.java b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaBackwardsPlatformImpl.java new file mode 100644 index 0000000..1cccac7 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaBackwardsPlatformImpl.java @@ -0,0 +1,23 @@ +package net.raphimc.viaproxy.protocolhack.impl; + +import com.viaversion.viabackwards.ViaBackwardsConfig; +import net.raphimc.viaprotocolhack.impl.platform.ViaBackwardsPlatformImpl; + +import java.io.File; +import java.net.URL; + +public class ViaProxyViaBackwardsPlatformImpl extends ViaBackwardsPlatformImpl { + + @Override + public void init(File dataFolder) { + new ViaBackwardsConfig(new File(dataFolder, "config.yml")) { + @Override + public URL getDefaultConfigURL() { + return ViaProxyViaVersionPlatformImpl.class.getClassLoader().getResource("assets/viaproxy/config_diff/viabackwards.yml"); + } + }.reloadConfig(); + + super.init(dataFolder); + } + +} diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaRewindPlatformImpl.java b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaRewindPlatformImpl.java new file mode 100644 index 0000000..2aa2d08 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaRewindPlatformImpl.java @@ -0,0 +1,35 @@ +package net.raphimc.viaproxy.protocolhack.impl; + +import com.viaversion.viaversion.api.Via; +import de.gerrygames.viarewind.api.ViaRewindConfigImpl; +import de.gerrygames.viarewind.api.ViaRewindPlatform; +import net.raphimc.viaprotocolhack.util.JLoggerToSLF4J; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.net.URL; +import java.util.logging.Logger; + +public class ViaProxyViaRewindPlatformImpl implements ViaRewindPlatform { + + private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaRewind")); + + public ViaProxyViaRewindPlatformImpl() { + new ViaRewindConfigImpl(new File(Via.getPlatform().getDataFolder(), "viarewind.yml")) { + @Override + public URL getDefaultConfigURL() { + return ViaProxyViaVersionPlatformImpl.class.getClassLoader().getResource("assets/viaproxy/config_diff/viarewind.yml"); + } + }.reloadConfig(); + + final ViaRewindConfigImpl config = new ViaRewindConfigImpl(new File(Via.getPlatform().getDataFolder(), "viarewind.yml")); + config.reloadConfig(); + this.init(config); + } + + @Override + public Logger getLogger() { + return LOGGER; + } + +} diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaVersionPlatformImpl.java b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaVersionPlatformImpl.java index 4b8e7f0..836d1f3 100644 --- a/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaVersionPlatformImpl.java +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaVersionPlatformImpl.java @@ -1,8 +1,12 @@ package net.raphimc.viaproxy.protocolhack.impl; +import com.viaversion.viaversion.configuration.AbstractViaConfig; import net.raphimc.viaprotocolhack.impl.platform.ViaVersionPlatformImpl; +import net.raphimc.viaprotocolhack.impl.viaversion.VPViaConfig; import net.raphimc.viaproxy.cli.ConsoleFormatter; +import java.io.File; +import java.net.URL; import java.util.UUID; public class ViaProxyViaVersionPlatformImpl extends ViaVersionPlatformImpl { @@ -16,4 +20,16 @@ public class ViaProxyViaVersionPlatformImpl extends ViaVersionPlatformImpl { super.sendMessage(uuid, ConsoleFormatter.convert(msg)); } + @Override + protected AbstractViaConfig createConfig() { + new VPViaConfig(new File(this.getDataFolder(), "viaversion.yml")) { + @Override + public URL getDefaultConfigURL() { + return ViaProxyViaVersionPlatformImpl.class.getClassLoader().getResource("assets/viaproxy/config_diff/viaversion.yml"); + } + }.reloadConfig(); + + return super.createConfig(); + } + } diff --git a/src/main/resources/assets/viaproxy/config_diff/viabackwards.yml b/src/main/resources/assets/viaproxy/config_diff/viabackwards.yml new file mode 100644 index 0000000..72558fb --- /dev/null +++ b/src/main/resources/assets/viaproxy/config_diff/viabackwards.yml @@ -0,0 +1,4 @@ +#Overwrite default value +fix-1_13-face-player: true +#Overwrite default value +handle-pings-as-inv-acknowledgements: true diff --git a/src/main/resources/assets/viaproxy/config_diff/viarewind.yml b/src/main/resources/assets/viaproxy/config_diff/viarewind.yml new file mode 100644 index 0000000..4eb05c6 --- /dev/null +++ b/src/main/resources/assets/viaproxy/config_diff/viarewind.yml @@ -0,0 +1,4 @@ +#Overwrite default value +replace-adventure: true +#Overwrite default value +replace-particles: true diff --git a/src/main/resources/assets/viaproxy/config_diff/viaversion.yml b/src/main/resources/assets/viaproxy/config_diff/viaversion.yml new file mode 100644 index 0000000..c35f9ca --- /dev/null +++ b/src/main/resources/assets/viaproxy/config_diff/viaversion.yml @@ -0,0 +1,6 @@ +#Overwrite default value +1_13-tab-complete-delay: 5 +#Overwrite default value +no-delay-shield-blocking: true +#Overwrite default value +chunk-border-fix: true