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:
Ursprung
3ef1ac06df
Commit
d0300de136
@ -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()
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren