Compare commits

...
3 Commits
4 changed files with 42 additions and 24 deletions

No files matched your search

@@ -161,6 +161,7 @@ public final class PipelineUtil {
return null;
}
@Deprecated(forRemoval = true)
public static @Nullable ChannelHandlerContext getPreviousContext(String name, ChannelPipeline pipeline) {
String previous = null;
for (String entry : pipeline.toMap().keySet()) {
@@ -37,11 +37,12 @@ import com.viaversion.viaversion.exception.InformativeException;
import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl;
import com.viaversion.viaversion.util.ChatColorUtil;
import com.viaversion.viaversion.util.NestingLimiter;
import com.viaversion.viaversion.util.PipelineUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.handler.codec.CodecException;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -55,6 +56,7 @@ import java.util.SplittableRandom;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.logging.Level;
import org.checkerframework.checker.nullness.qual.Nullable;
public class UserConnectionImpl implements UserConnection {
@@ -302,10 +304,6 @@ public class UserConnectionImpl implements UserConnection {
final int initialCapacity = active ? packet.readableBytes() + PASSTHROUGH_DATA_BYTES : packet.readableBytes();
final ByteBuf buf = packet.alloc().buffer(initialCapacity);
try {
// We'll use passing through because there are some encoder wrappers
ChannelHandlerContext context = PipelineUtil
.getPreviousContext(Via.getManager().getInjector().getDecoderName(), channel.pipeline());
if (shouldTransformPacket()) {
// Bypass serverbound packet decoder transforming
Types.VAR_INT.writePrimitive(buf, PacketWrapper.PASSTHROUGH_ID);
@@ -313,27 +311,46 @@ public class UserConnectionImpl implements UserConnection {
}
buf.writeBytes(packet);
if (currentThread) {
fireChannelRead(context, buf);
} else {
try {
channel.eventLoop().execute(() -> fireChannelRead(context, buf));
} catch (Throwable t) {
// Couldn't schedule
buf.release();
throw t;
}
}
} catch (Throwable t) {
buf.release();
throw t;
} finally {
packet.release();
}
if (currentThread && channel.eventLoop().inEventLoop()) {
fireChannelRead(buf);
} else {
try {
channel.eventLoop().execute(() -> fireChannelRead(buf));
} catch (Throwable t) {
// Couldn't schedule
buf.release();
throw t;
}
}
}
private void fireChannelRead(@Nullable final ChannelHandlerContext context, final ByteBuf buf) {
if (context != null) {
context.fireChannelRead(buf);
} else {
channel.pipeline().fireChannelRead(buf);
private void fireChannelRead(final ByteBuf buf) {
final ChannelHandlerContext context = channel.pipeline().context(Via.getManager().getInjector().getDecoderName());
if (context == null) {
buf.release();
return;
}
// Directly invoke the decoder, copied from Netty's fireChannelRead of the previous handler
final ChannelHandler handler = context.handler();
try {
((ChannelInboundHandler) handler).channelRead(context, buf);
} catch (Throwable t) {
try {
handler.exceptionCaught(context, t);
} catch (Throwable e) {
if (e != t) {
e.addSuppressed(t);
}
Via.getPlatform().getLogger().log(Level.WARNING, "Exception thrown by exceptionCaught of " + handler, e);
}
}
}
@@ -34,6 +34,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.connection.ProtocolStorablesBase;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.exception.InformativeException;
@@ -48,7 +49,6 @@ import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacke
import com.viaversion.viaversion.protocols.v1_20to1_20_2.rewriter.BlockItemPacketRewriter1_20_2;
import com.viaversion.viaversion.protocols.v1_20to1_20_2.rewriter.BlockRewriter1_20_2;
import com.viaversion.viaversion.protocols.v1_20to1_20_2.rewriter.EntityPacketRewriter1_20_2;
import com.viaversion.viaversion.connection.ProtocolStorablesBase;
import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.ConfigurationState;
import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.ConfigurationState.BridgePhase;
import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.LastResourcePack;
@@ -344,7 +344,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
protocolInfo.setServerState(State.CONFIGURATION);
final PacketWrapper registryDataPacket = PacketWrapper.create(ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, connection);
registryDataPacket.write(Types.COMPOUND_TAG, dimensionRegistry);
registryDataPacket.write(Types.COMPOUND_TAG, dimensionRegistry.copy());
registryDataPacket.send(Protocol1_20To1_20_2.class);
// If we tracked enables features, they'd be sent here
+1 -1
View File
@@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=5.12.2
projectVersion=5.12.3-SNAPSHOT
# note that modrinth may not have added the version on release yet
mcVersionRange=1.8-26.3