Move config load after platform creation

This commit is contained in:
Nassim Jahnke 2024-02-13 23:37:00 +01:00
parent 564286d742
commit 7a6c51331b
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
9 changed files with 18 additions and 26 deletions

View File

@ -56,8 +56,8 @@ import org.bukkit.plugin.java.JavaPlugin;
public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player> { public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player> {
private static final boolean FOLIA = PaperViaInjector.hasClass("io.papermc.paper.threadedregions.RegionizedServer"); private static final boolean FOLIA = PaperViaInjector.hasClass("io.papermc.paper.threadedregions.RegionizedServer");
private static ViaVersionPlugin instance; private static ViaVersionPlugin instance;
private final BukkitCommandHandler commandHandler; private final BukkitCommandHandler commandHandler = new BukkitCommandHandler();
private final BukkitViaConfig conf; private final BukkitViaConfig conf = new BukkitViaConfig(getDataFolder());
private final ViaAPI<Player> api = new BukkitViaAPI(this); private final ViaAPI<Player> api = new BukkitViaAPI(this);
private boolean protocolSupport; private boolean protocolSupport;
private boolean lateBind; private boolean lateBind;
@ -65,20 +65,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
public ViaVersionPlugin() { public ViaVersionPlugin() {
instance = this; instance = this;
// Command handler
commandHandler = new BukkitCommandHandler();
// Init platform
BukkitViaInjector injector = new BukkitViaInjector();
Via.init(ViaManagerImpl.builder() Via.init(ViaManagerImpl.builder()
.platform(this) .platform(this)
.commandHandler(commandHandler) .commandHandler(commandHandler)
.injector(injector) .injector(new BukkitViaInjector())
.loader(new BukkitViaLoader(this)) .loader(new BukkitViaLoader(this))
.build()); .build());
// Config magic conf.reload();
conf = new BukkitViaConfig();
} }
@Override @Override

View File

@ -17,13 +17,11 @@
*/ */
package com.viaversion.viaversion.bukkit.platform; package com.viaversion.viaversion.bukkit.platform;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.configuration.AbstractViaConfig; import com.viaversion.viaversion.configuration.AbstractViaConfig;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.plugin.Plugin;
public class BukkitViaConfig extends AbstractViaConfig { public class BukkitViaConfig extends AbstractViaConfig {
private static final List<String> UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers"); private static final List<String> UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers");
@ -34,9 +32,8 @@ public class BukkitViaConfig extends AbstractViaConfig {
private boolean armorToggleFix; private boolean armorToggleFix;
private boolean registerUserConnectionOnJoin; private boolean registerUserConnectionOnJoin;
public BukkitViaConfig() { public BukkitViaConfig(final File folder) {
super(new File(((Plugin) Via.getPlatform()).getDataFolder(), "config.yml")); super(new File(folder, "config.yml"));
reload();
} }
@Override @Override

View File

@ -80,6 +80,8 @@ public class BungeePlugin extends Plugin implements ViaServerProxyPlatform<Proxi
.loader(new BungeeViaLoader(this)) .loader(new BungeeViaLoader(this))
.commandHandler(commandHandler) .commandHandler(commandHandler)
.build()); .build());
config.reload();
} }
@Override @Override

View File

@ -33,9 +33,8 @@ public class BungeeViaConfig extends AbstractViaConfig {
private boolean bungeePingSave; private boolean bungeePingSave;
private Map<String, Integer> bungeeServerProtocols; private Map<String, Integer> bungeeServerProtocols;
public BungeeViaConfig(File configFile) { public BungeeViaConfig(File folder) {
super(new File(configFile, "config.yml")); super(new File(folder, "config.yml"));
reload();
} }
@Override @Override

View File

@ -26,8 +26,8 @@ import java.util.Map;
public final class TestConfig extends AbstractViaConfig { public final class TestConfig extends AbstractViaConfig {
public TestConfig(File configFile) { public TestConfig(File file) {
super(configFile); super(file);
} }
@Override @Override

View File

@ -95,6 +95,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
.injector(new SpongeViaInjector()) .injector(new SpongeViaInjector())
.loader(new SpongeViaLoader(this)) .loader(new SpongeViaLoader(this))
.build()); .build());
conf.reload();
} }
@Listener @Listener

View File

@ -28,9 +28,8 @@ public class SpongeViaConfig extends AbstractViaConfig {
"bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers",
"quick-move-action-fix", "change-1_9-hitbox", "change-1_14-hitbox", "blockconnection-method"); "quick-move-action-fix", "change-1_9-hitbox", "change-1_14-hitbox", "blockconnection-method");
public SpongeViaConfig(File configFile) { public SpongeViaConfig(File folder) {
super(new File(configFile, "config.yml")); super(new File(folder, "config.yml"));
reload();
} }
@Override @Override

View File

@ -103,6 +103,7 @@ public class VelocityPlugin implements ViaServerProxyPlatform<Player> {
.commandHandler(commandHandler) .commandHandler(commandHandler)
.loader(new VelocityViaLoader()) .loader(new VelocityViaLoader())
.injector(new VelocityViaInjector()).build()); .injector(new VelocityViaInjector()).build());
conf.reload();
} }
@Subscribe(order = PostOrder.LAST) @Subscribe(order = PostOrder.LAST)

View File

@ -32,9 +32,8 @@ public class VelocityViaConfig extends AbstractViaConfig {
private boolean velocityPingSave; private boolean velocityPingSave;
private Map<String, Integer> velocityServerProtocols; private Map<String, Integer> velocityServerProtocols;
public VelocityViaConfig(File configFile) { public VelocityViaConfig(File folder) {
super(new File(configFile, "config.yml")); super(new File(folder, "config.yml"));
reload();
} }
@Override @Override