3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-04 23:30:24 +01:00

Prevent initialization error

Dieser Commit ist enthalten in:
Myles 2018-11-17 13:08:51 +00:00
Ursprung 3ef1ac06df
Commit d0300de136
3 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -56,7 +56,7 @@ public class VelocityPlugin implements ViaPlatform<Player> {
@Inject
@DataDirectory
private Path configDir;
private VelocityViaAPI api = new VelocityViaAPI();
private VelocityViaAPI api;
private VelocityViaConfig conf;
@Subscribe
@ -64,6 +64,7 @@ public class VelocityPlugin implements ViaPlatform<Player> {
PROXY = proxy;
VelocityCommandHandler commandHandler = new VelocityCommandHandler();
PROXY.getCommandManager().register(commandHandler, "viaver", "vvvelocity", "viaversion");
api = new VelocityViaAPI();
conf = new VelocityViaConfig(configDir.toFile());
logger = new LoggerWrapper(loggerslf4j);
Via.init(ViaManager.builder()

Datei anzeigen

@ -1,7 +1,6 @@
package us.myles.ViaVersion.velocity.platform;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.util.Config;
@ -49,7 +48,13 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
}
// Ensure default exists
if (!servers.containsKey("default")) {
servers.put("default", ProtocolRegistry.SERVER_PROTOCOL);
// Side note: This doesn't use ProtocolRegistry as it doesn't know the protocol version at boot.
try {
servers.put("default", VelocityViaInjector.getLowestSupportedProtocolVersion());
} catch (Exception e) {
// Something went very wrong
e.printStackTrace();
}
}
// Put back
config.put("velocity-servers", servers);

Datei anzeigen

@ -26,6 +26,10 @@ public class VelocityViaInjector implements ViaInjector {
@Override
public int getServerProtocolVersion() throws Exception {
return getLowestSupportedProtocolVersion();
}
public static int getLowestSupportedProtocolVersion() throws Exception {
return ReflectionUtil.getStatic(Class.forName("com.velocitypowered.proxy.protocol.ProtocolConstants"), "MINIMUM_GENERIC_VERSION", int.class);
}