Update VV dependency to the 4.0.0 repackage (#121)

Co-authored-by: KennyTV <jahnke.nassim@gmail.com>
This commit is contained in:
creeper123123321 2021-04-28 18:31:51 -03:00 committed by GitHub
parent 7b7fb9177e
commit bc3677e27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 108 additions and 131 deletions

View File

@ -19,7 +19,7 @@ val branch = try {
"unknown"
}
version = "0.3.1-SNAPSHOT+" + try {
version = "0.4.0-SNAPSHOT+" + try {
(githubShaInfo ?: gitVersion()) + "-" + branch
} catch (e: Exception) {
"unknown"
@ -28,7 +28,6 @@ extra.set("archivesBaseName", "ViaFabric")
description = "Client-side and server-side ViaVersion implementation for Fabric"
repositories {
//mavenLocal()
mavenCentral()
maven(url = "https://repo.viaversion.com/")
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
@ -50,8 +49,8 @@ tasks.named<ProcessResources>("processResources") {
dependencies {
// transitive = false because Guava is conflicting on runClient
implementation("us.myles:viaversion:3.3.0-21w15a") { isTransitive = false }
include("us.myles:viaversion:3.3.0-21w15a")
implementation("com.viaversion:viaversion:4.0.0-21w17a") { isTransitive = false }
include("com.viaversion:viaversion:4.0.0-21w17a")
implementation("org.yaml:snakeyaml:1.28")
include("org.yaml:snakeyaml:1.28")

View File

@ -22,10 +22,10 @@ import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.CommandSource;
import org.apache.logging.log4j.LogManager;
import us.myles.ViaVersion.ViaManagerImpl;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import com.viaversion.viaversion.ViaManagerImpl;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;

View File

@ -1,6 +1,6 @@
package com.github.creeper123123321.viafabric;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.Locale;
@ -32,7 +32,7 @@ public class ViaFabricAddress {
} catch (NumberFormatException e) {
ProtocolVersion closest = ProtocolVersion.getClosest(arg.replace("_", "."));
if (closest != null) {
protocol = closest.getId();
protocol = closest.getVersion();
}
}
}

View File

@ -6,9 +6,9 @@ import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.UUID;

View File

@ -1,8 +1,8 @@
package com.github.creeper123123321.viafabric.commands;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.data.UserConnection;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.connection.UserConnection;
import java.util.UUID;

View File

@ -6,7 +6,7 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.command.CommandSource;
import us.myles.ViaVersion.commands.ViaCommandHandler;
import com.viaversion.viaversion.commands.ViaCommandHandler;
import java.util.concurrent.CompletableFuture;

View File

@ -1,8 +1,8 @@
package com.github.creeper123123321.viafabric.commands.subs;
import io.netty.util.ResourceLeakDetector;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.command.ViaSubCommand;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.command.ViaSubCommand;
import java.util.Arrays;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.github.creeper123123321.viafabric.config;
import us.myles.ViaVersion.util.Config;
import com.viaversion.viaversion.util.Config;
import java.io.File;
import java.net.URL;

View File

@ -2,6 +2,7 @@ package com.github.creeper123123321.viafabric.gui;
import com.github.creeper123123321.viafabric.ViaFabric;
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
import com.viaversion.viaversion.api.Via;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -12,7 +13,6 @@ import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.TranslatableText;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import java.util.concurrent.CompletableFuture;
@ -94,7 +94,7 @@ public class ViaConfigScreen extends Screen {
}
protocolVersion.setEditableColor(
getProtocolTextColor(ProtocolUtils.isSupported(newVersion, ProtocolRegistry.SERVER_PROTOCOL),
getProtocolTextColor(ProtocolUtils.isSupported(newVersion, Via.getAPI().getServerVersion().lowestSupportedVersion()),
validProtocol));
int finalNewVersion = newVersion;

View File

@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.util.PipelineUtil;
import com.viaversion.viaversion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException;

View File

@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.exception.CancelCodecException;
import us.myles.ViaVersion.exception.CancelDecoderException;
import us.myles.ViaVersion.util.PipelineUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.exception.CancelCodecException;
import com.viaversion.viaversion.exception.CancelDecoderException;
import com.viaversion.viaversion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

View File

@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.exception.CancelCodecException;
import us.myles.ViaVersion.exception.CancelEncoderException;
import us.myles.ViaVersion.util.PipelineUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.exception.CancelCodecException;
import com.viaversion.viaversion.exception.CancelEncoderException;
import com.viaversion.viaversion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

View File

@ -2,10 +2,10 @@ package com.github.creeper123123321.viafabric.handler.clientside;
import com.github.creeper123123321.viafabric.ViaFabric;
import com.github.creeper123123321.viafabric.service.ProtocolAutoDetector;
import com.viaversion.viaversion.util.Pair;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import us.myles.ViaVersion.api.Pair;
import java.net.InetSocketAddress;
import java.util.ArrayDeque;

View File

@ -2,6 +2,7 @@ package com.github.creeper123123321.viafabric.mixin.debug.client;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import com.github.creeper123123321.viafabric.handler.FabricDecodeHandler;
import com.viaversion.viaversion.api.connection.ProtocolInfo;
import io.netty.channel.ChannelHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
@ -9,9 +10,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.List;
@ -28,8 +28,8 @@ public class MixinDebugHud {
if (protocol != null) {
ProtocolVersion serverVer = ProtocolVersion.getProtocol(protocol.getServerProtocolVersion());
ProtocolVersion clientVer = ProtocolVersion.getProtocol(protocol.getProtocolVersion());
line += " / C: " + clientVer.getName() + " (" + clientVer.getId() + ") S: "
+ serverVer.getName() + " (" + serverVer.getId() + ") A: " + protocol.getUser().isActive();
line += " / C: " + clientVer.getName() + " (" + clientVer.getVersion() + ") S: "
+ serverVer.getName() + " (" + serverVer.getVersion() + ") A: " + protocol.getUser().isActive();
}
}

View File

@ -3,22 +3,23 @@ package com.github.creeper123123321.viafabric.mixin.pipeline;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import com.github.creeper123123321.viafabric.handler.FabricDecodeHandler;
import com.github.creeper123123321.viafabric.handler.FabricEncodeHandler;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import com.viaversion.viaversion.api.connection.UserConnection;
@Mixin(targets = "net.minecraft.server.ServerNetworkIo$1")
public class MixinServerNetworkIoChInit {
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnection(channel);
new ProtocolPipeline(user);
UserConnection user = new UserConnectionImpl(channel);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));

View File

@ -6,22 +6,23 @@ import com.github.creeper123123321.viafabric.handler.FabricDecodeHandler;
import com.github.creeper123123321.viafabric.handler.FabricEncodeHandler;
import com.github.creeper123123321.viafabric.handler.clientside.ProtocolDetectionHandler;
import com.github.creeper123123321.viafabric.protocol.ViaFabricHostnameProtocol;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import com.viaversion.viaversion.api.connection.UserConnection;
@Mixin(targets = "net.minecraft.network.ClientConnection$1")
public class MixinClientConnectionChInit {
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnection(channel, true);
new ProtocolPipeline(user).add(ViaFabricHostnameProtocol.INSTANCE);
UserConnection user = new UserConnectionImpl(channel, true);
new ProtocolPipelineImpl(user).add(ViaFabricHostnameProtocol.INSTANCE);
channel.pipeline()
.addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user))

View File

@ -1,11 +0,0 @@
package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.boss.CommonBoss;
public class VRBossBar extends CommonBoss<Void> {
public VRBossBar(String title, float health, BossColor color, BossStyle style) {
super(title, health, color, style);
}
}

View File

@ -4,9 +4,9 @@ import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.SharedConstants;
import us.myles.ViaVersion.api.platform.ViaInjector;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.util.GsonUtil;
import com.viaversion.viaversion.libs.gson.JsonObject;
import java.lang.reflect.Method;
import java.util.Arrays;

View File

@ -4,12 +4,12 @@ import com.github.creeper123123321.viafabric.providers.VRHandItemProvider;
import com.github.creeper123123321.viafabric.providers.VRVersionProvider;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
import us.myles.ViaVersion.protocols.base.VersionProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
import com.viaversion.viaversion.bungee.providers.BungeeMovementTransmitter;
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
public class VRLoader implements ViaPlatformLoader {
@Override

View File

@ -5,6 +5,8 @@ import com.github.creeper123123321.viafabric.commands.NMSCommandSender;
import com.github.creeper123123321.viafabric.commands.UserCommandSender;
import com.github.creeper123123321.viafabric.util.FutureTaskId;
import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.platform.PlatformTask;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.fabricmc.api.EnvType;
@ -19,18 +21,16 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import org.apache.logging.log4j.LogManager;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import us.myles.ViaVersion.api.platform.TaskId;
import us.myles.ViaVersion.api.platform.ViaPlatform;
import us.myles.ViaVersion.dump.PluginInfo;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.ViaAPI;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.dump.PluginInfo;
import com.viaversion.viaversion.util.GsonUtil;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.io.File;
import java.nio.file.Path;
@ -96,7 +96,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
}
@Override
public TaskId runAsync(Runnable runnable) {
public FutureTaskId runAsync(Runnable runnable) {
return new FutureTaskId(CompletableFuture
.runAsync(runnable, ViaFabric.ASYNC_EXECUTOR)
.exceptionally(throwable -> {
@ -109,7 +109,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
}
@Override
public TaskId runSync(Runnable runnable) {
public FutureTaskId runSync(Runnable runnable) {
if (getServer() != null) {
return runServerSync(runnable);
} else {
@ -117,12 +117,12 @@ public class VRPlatform implements ViaPlatform<UUID> {
}
}
private TaskId runServerSync(Runnable runnable) {
private FutureTaskId runServerSync(Runnable runnable) {
// Kick task needs to be on main thread, it does already have error logger
return new FutureTaskId(CompletableFuture.runAsync(runnable, getServer()));
}
private TaskId runEventLoop(Runnable runnable) {
private FutureTaskId runEventLoop(Runnable runnable) {
return new FutureTaskId(
ViaFabric.EVENT_LOOP
.submit(runnable)
@ -131,7 +131,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
}
@Override
public TaskId runSync(Runnable runnable, Long ticks) {
public PlatformTask runSync(Runnable runnable, Long ticks) {
// ViaVersion seems to not need to run delayed tasks on main thread
return new FutureTaskId(
ViaFabric.EVENT_LOOP
@ -141,7 +141,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
}
@Override
public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
public PlatformTask runRepeatingSync(Runnable runnable, Long ticks) {
// ViaVersion seems to not need to run repeating tasks on main thread
return new FutureTaskId(
ViaFabric.EVENT_LOOP
@ -158,13 +158,6 @@ public class VRPlatform implements ViaPlatform<UUID> {
};
}
@Override
public void cancelTask(TaskId taskId) {
if (taskId instanceof FutureTaskId) {
((FutureTaskId) taskId).getObject().cancel(false);
}
}
@Override
public ViaCommandSender[] getOnlinePlayers() {
MinecraftServer server = getServer();

View File

@ -1,20 +1,8 @@
package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.api.ViaAPIBase;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import com.viaversion.viaversion.ViaAPIBase;
import java.util.UUID;
public class VRViaAPI extends ViaAPIBase<UUID> {
@Override
public BossBar<Void> createBossBar(String s, BossColor bossColor, BossStyle bossStyle) {
return new VRBossBar(s, 1f, bossColor, bossStyle);
}
@Override
public BossBar<Void> createBossBar(String s, float v, BossColor bossColor, BossStyle bossStyle) {
return new VRBossBar(s, v, bossColor, bossStyle);
}
}

View File

@ -1,6 +1,6 @@
package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.AbstractViaConfig;
import com.viaversion.viaversion.configuration.AbstractViaConfig;
import java.io.File;
import java.net.URL;

View File

@ -1,19 +1,19 @@
package com.github.creeper123123321.viafabric.protocol;
import com.github.creeper123123321.viafabric.ViaFabricAddress;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.protocol.packet.State;
public class ViaFabricHostnameProtocol extends SimpleProtocol {
public class ViaFabricHostnameProtocol extends AbstractSimpleProtocol {
public static final ViaFabricHostnameProtocol INSTANCE = new ViaFabricHostnameProtocol();
@Override
protected void registerPackets() {
registerIncoming(State.HANDSHAKE, 0, 0, new PacketRemapper() {
registerServerbound(State.HANDSHAKE, 0, 0, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Protocol version

View File

@ -13,9 +13,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import java.util.Map;
import java.util.UUID;

View File

@ -5,15 +5,16 @@ import com.github.creeper123123321.viafabric.ViaFabricAddress;
import com.github.creeper123123321.viafabric.service.ProtocolAutoDetector;
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
import com.google.common.primitives.Ints;
import com.viaversion.viaversion.api.connection.ProtocolInfo;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.network.ClientConnection;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.base.*;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.protocols.base.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -76,7 +77,7 @@ public class VRVersionProvider extends BaseVersionProvider {
ProtocolVersion autoVer =
ProtocolAutoDetector.detectVersion((InetSocketAddress) addr).getNow(null);
if (autoVer != null) {
serverVer = autoVer.getId();
serverVer = autoVer.getVersion();
}
}
} catch (Exception e) {
@ -111,7 +112,7 @@ public class VRVersionProvider extends BaseVersionProvider {
&& (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection
int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer);
ViaFabric.JLOGGER.info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
PacketWrapper newAnswer = new PacketWrapper(0x00, null, connection);
PacketWrapper newAnswer = PacketWrapper.create(0x00, null, connection);
newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}");
newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class, true, true);
throw CancelException.generate();

View File

@ -20,7 +20,7 @@ import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.minecraft.server.ServerMetadata;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.net.InetAddress;
import java.net.InetSocketAddress;

View File

@ -1,10 +1,10 @@
package com.github.creeper123123321.viafabric.util;
import us.myles.ViaVersion.api.platform.TaskId;
import com.viaversion.viaversion.api.platform.PlatformTask;
import java.util.concurrent.Future;
public class FutureTaskId implements TaskId {
public class FutureTaskId implements PlatformTask<Future<?>> {
private final Future<?> object;
public FutureTaskId(Future<?> object) {
@ -15,4 +15,9 @@ public class FutureTaskId implements TaskId {
public Future<?> getObject() {
return object;
}
@Override
public void cancel() {
object.cancel(false);
}
}

View File

@ -1,14 +1,14 @@
package com.github.creeper123123321.viafabric.util;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.Arrays;
import java.util.stream.Stream;
public class ProtocolUtils {
public static boolean isSupported(int server, int client) {
return server == client || ProtocolRegistry.getProtocolPath(client, server) != null;
return server == client || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null;
}
public static String getProtocolName(int id) {
@ -42,7 +42,7 @@ public class ProtocolUtils {
} catch (NumberFormatException ignored) {
ProtocolVersion closest = ProtocolVersion.getClosest(s);
if (closest == null) return null;
return closest.getId();
return closest.getVersion();
}
}