From e27930b1d776910615ac7fd1ed653fa2e0b3f526 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 8 Oct 2023 09:20:01 +0200 Subject: [PATCH] Allow platform implementation to define config path (#603) --- .../main/java/com/viaversion/viabackwards/BukkitPlugin.java | 4 +++- .../main/java/com/viaversion/viabackwards/BungeePlugin.java | 5 +++-- .../viaversion/viabackwards/api/ViaBackwardsPlatform.java | 4 ++-- .../java/com/viaversion/viabackwards/ViaFabricAddon.java | 2 +- .../main/java/com/viaversion/viabackwards/SpongePlugin.java | 2 +- .../java/com/viaversion/viabackwards/VelocityPlugin.java | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java b/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java index d76f5f27..f37daf85 100644 --- a/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java +++ b/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java @@ -27,10 +27,12 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; + public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform { public BukkitPlugin() { - Via.getManager().addEnableListener(() -> init(getDataFolder())); + Via.getManager().addEnableListener(() -> init(new File(getDataFolder(), "config.yml"))); } @Override diff --git a/bungee/src/main/java/com/viaversion/viabackwards/BungeePlugin.java b/bungee/src/main/java/com/viaversion/viabackwards/BungeePlugin.java index 1ace01d7..5ef77710 100644 --- a/bungee/src/main/java/com/viaversion/viabackwards/BungeePlugin.java +++ b/bungee/src/main/java/com/viaversion/viabackwards/BungeePlugin.java @@ -20,14 +20,15 @@ package com.viaversion.viabackwards; import com.viaversion.viabackwards.api.ViaBackwardsPlatform; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.data.MappingDataLoader; import net.md_5.bungee.api.plugin.Plugin; +import java.io.File; + public class BungeePlugin extends Plugin implements ViaBackwardsPlatform { @Override public void onLoad() { - Via.getManager().addEnableListener(() -> this.init(getDataFolder())); + Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml"))); } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index 4c48bd28..a1563e1c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -72,8 +72,8 @@ public interface ViaBackwardsPlatform { /** * Initialize ViaBackwards. */ - default void init(File dataFolder) { - ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml")); + default void init(final File configFile) { + ViaBackwardsConfig config = new ViaBackwardsConfig(configFile); config.reload(); Via.getManager().getConfigurationProvider().register(config); diff --git a/fabric/src/main/java/com/viaversion/viabackwards/ViaFabricAddon.java b/fabric/src/main/java/com/viaversion/viabackwards/ViaFabricAddon.java index 7032f8ae..de65ffee 100644 --- a/fabric/src/main/java/com/viaversion/viabackwards/ViaFabricAddon.java +++ b/fabric/src/main/java/com/viaversion/viabackwards/ViaFabricAddon.java @@ -34,7 +34,7 @@ public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable { public void run() { Path configDirPath = FabricLoader.getInstance().getConfigDir().resolve("ViaBackwards"); configDir = configDirPath.toFile(); - this.init(getDataFolder()); + this.init(new File(getDataFolder(), "config.yml")); } @Override diff --git a/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java b/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java index 7296eb6f..1a1c2816 100644 --- a/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java +++ b/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java @@ -47,7 +47,7 @@ public class SpongePlugin implements ViaBackwardsPlatform { @Listener public void constructPlugin(ConstructPluginEvent event) { - Via.getManager().addEnableListener(() -> this.init(getDataFolder())); + Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml"))); } @Override diff --git a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java index 8afd8522..e61aa0f5 100644 --- a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java @@ -52,7 +52,7 @@ public class VelocityPlugin implements ViaBackwardsPlatform { @Subscribe(order = PostOrder.LATE) public void onProxyStart(ProxyInitializeEvent event) { this.logger = new LoggerWrapper(loggerSlf4j); - Via.getManager().addEnableListener(() -> this.init(getDataFolder())); + Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml"))); } @Override