Allow platform implementation to define config path (#603)

This commit is contained in:
EnZaXD 2023-10-08 09:20:01 +02:00 committed by GitHub
parent d46eb8719a
commit e27930b1d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -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")));
}

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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