mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-21 16:17:37 +01:00
fixed injector, don't pretend to be a proxy on server-side
This commit is contained in:
parent
db57ced2bb
commit
43379d2369
@ -15,6 +15,7 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.Version;
|
||||
@ -41,11 +42,15 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// We'll use it early for ViaInjector
|
||||
installNativeVersionProvider();
|
||||
Path configDir = FabricLoader.getInstance().getConfigDir().resolve("ViaFabric");
|
||||
dataFolder = configDir.toFile();
|
||||
config = new FabricViaConfig(configDir.resolve("viaversion.yml").toFile());
|
||||
}
|
||||
|
||||
protected abstract void installNativeVersionProvider();
|
||||
|
||||
protected abstract ExecutorService asyncService();
|
||||
|
||||
protected abstract EventLoop eventLoop();
|
||||
@ -94,7 +99,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
|
||||
@Override
|
||||
public boolean isProxy() {
|
||||
// We kinda of have all server versions
|
||||
return true;
|
||||
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc114.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -108,6 +109,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return false; // Can't know if it worked
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc115.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -38,6 +39,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return MinecraftClient.getInstance().getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc116.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -37,6 +38,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return MinecraftClient.getInstance().getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc117.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -109,6 +110,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return false; // Can't know if it worked
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc118.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -109,6 +110,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return false; // Can't know if it worked
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.realms.RealmsSharedConstants;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerMetadata;
|
||||
|
||||
public class FabricNativeVersionProvider implements NativeVersionProvider {
|
||||
@Override
|
||||
@ -14,7 +15,10 @@ public class FabricNativeVersionProvider implements NativeVersionProvider {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
|
||||
return getClientProtocol();
|
||||
}
|
||||
return MinecraftServer.getServer().getServerMetadata().getVersion().getProtocolVersion();
|
||||
|
||||
ServerMetadata.Version version = MinecraftServer.getServer().getServerMetadata().getVersion();
|
||||
if (version == null) return ProtocolVersion.v1_8.getVersion();
|
||||
return version.getProtocolVersion();
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.viaversion.fabric.mc18.platform;
|
||||
|
||||
import com.viaversion.fabric.common.commands.UserCommandSender;
|
||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
||||
@ -32,6 +33,11 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
||||
return MinecraftServer.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installNativeVersionProvider() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorService asyncService() {
|
||||
return ViaFabric.ASYNC_EXECUTOR;
|
||||
|
@ -15,7 +15,6 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTr
|
||||
public class VFLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(NativeVersionProvider.class, new FabricNativeVersionProvider());
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new FabricVersionProvider());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user