Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Convert to Netty 5, sans ByteBuf -> Buffer migration
Since `ByteBuf` is everywhere in the codebase, moving to the `Buffer` interface will be the most difficult part of the migration. The main causality is the HAProxy support, which seems to have not been pushed up to Maven Central or Sonatype snapshots.
Dieser Commit ist enthalten in:
Ursprung
302b15d3bc
Commit
81e302e6d2
@ -14,7 +14,7 @@ allprojects {
|
||||
junitVersion = '5.7.0'
|
||||
slf4jVersion = '1.7.30'
|
||||
log4jVersion = '2.17.1'
|
||||
nettyVersion = '4.1.74.Final'
|
||||
nettyVersion = '5.0.0.Alpha1'
|
||||
guavaVersion = '25.1-jre'
|
||||
checkerFrameworkVersion = '3.6.1'
|
||||
configurateVersion = '3.7.2'
|
||||
|
@ -19,7 +19,7 @@ license {
|
||||
|
||||
dependencies {
|
||||
implementation "com.google.guava:guava:${guavaVersion}"
|
||||
implementation "io.netty:netty-handler:${nettyVersion}"
|
||||
implementation "io.netty:netty5-handler:${nettyVersion}"
|
||||
implementation "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
|
||||
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.velocitypowered.natives.compression;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
class CompressorUtils {
|
||||
|
@ -23,7 +23,7 @@ import static com.velocitypowered.natives.compression.CompressorUtils.ZLIB_BUFFE
|
||||
import static com.velocitypowered.natives.compression.CompressorUtils.ensureMaxSize;
|
||||
|
||||
import com.velocitypowered.natives.util.BufferPreference;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Deflater;
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.natives.compression;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.util.BufferPreference;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
public class LibdeflateVelocityCompressor implements VelocityCompressor {
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.natives.compression;
|
||||
|
||||
import com.velocitypowered.natives.Disposable;
|
||||
import com.velocitypowered.natives.Native;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.natives.encryption;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.util.BufferPreference;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.security.GeneralSecurityException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.natives.encryption;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.util.BufferPreference;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.security.GeneralSecurityException;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.natives.encryption;
|
||||
|
||||
import com.velocitypowered.natives.Disposable;
|
||||
import com.velocitypowered.natives.Native;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public interface VelocityCipher extends Disposable, Native {
|
||||
void process(ByteBuf source);
|
||||
|
@ -18,8 +18,8 @@
|
||||
package com.velocitypowered.natives.util;
|
||||
|
||||
import com.velocitypowered.natives.Native;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufAllocator;
|
||||
|
||||
public class MoreByteBufUtils {
|
||||
private MoreByteBufUtils() {
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package com.velocitypowered.natives.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class NativeConstraints {
|
||||
|
@ -24,9 +24,9 @@ import static org.junit.jupiter.api.condition.OS.LINUX;
|
||||
|
||||
import com.velocitypowered.natives.util.BufferPreference;
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -22,9 +22,9 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.condition.OS.LINUX;
|
||||
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -45,13 +45,13 @@ dependencies {
|
||||
implementation project(':velocity-api').sourceSets.ap.output
|
||||
implementation project(':velocity-native')
|
||||
|
||||
implementation "io.netty:netty-codec:${nettyVersion}"
|
||||
implementation "io.netty:netty-codec-haproxy:${nettyVersion}"
|
||||
implementation "io.netty:netty-codec-http:${nettyVersion}"
|
||||
implementation "io.netty:netty-handler:${nettyVersion}"
|
||||
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}"
|
||||
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
|
||||
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch_64"
|
||||
implementation "io.netty:netty5-codec:${nettyVersion}"
|
||||
// implementation "io.netty.contrib:netty5-codec-haproxy:5.0.0.Final-SNAPSHOT"
|
||||
implementation "io.netty:netty5-codec-http:${nettyVersion}"
|
||||
implementation "io.netty:netty5-handler:${nettyVersion}"
|
||||
implementation "io.netty:netty5-transport-native-epoll:${nettyVersion}"
|
||||
implementation "io.netty:netty5-transport-native-epoll:${nettyVersion}:linux-x86_64"
|
||||
implementation "io.netty:netty5-transport-native-epoll:${nettyVersion}:linux-aarch_64"
|
||||
|
||||
implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}"
|
||||
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package com.velocitypowered.proxy;
|
||||
|
||||
import io.netty.util.ResourceLeakDetector;
|
||||
import io.netty.util.ResourceLeakDetector.Level;
|
||||
import io.netty5.util.ResourceLeakDetector;
|
||||
import io.netty5.util.ResourceLeakDetector.Level;
|
||||
import java.text.DecimalFormat;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -38,12 +38,12 @@ public class Velocity {
|
||||
// If Velocity's natives are being extracted to a different temporary directory, make sure the
|
||||
// Netty natives are extracted there as well
|
||||
if (System.getProperty("velocity.natives-tmpdir") != null) {
|
||||
System.setProperty("io.netty.native.workdir", System.getProperty("velocity.natives-tmpdir"));
|
||||
System.setProperty("io.netty5.native.workdir", System.getProperty("velocity.natives-tmpdir"));
|
||||
}
|
||||
|
||||
// Disable the resource leak detector by default as it reduces performance. Allow the user to
|
||||
// override this if desired.
|
||||
if (System.getProperty("io.netty.leakDetection.level") == null) {
|
||||
if (System.getProperty("io.netty5.leakDetection.level") == null) {
|
||||
ResourceLeakDetector.setLevel(Level.DISABLED);
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ import com.velocitypowered.proxy.util.bossbar.AdventureBossBarManager;
|
||||
import com.velocitypowered.proxy.util.ratelimit.Ratelimiter;
|
||||
import com.velocitypowered.proxy.util.ratelimit.Ratelimiters;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty5.bootstrap.Bootstrap;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelInitializer;
|
||||
import io.netty5.channel.EventLoopGroup;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.http.HttpClient;
|
||||
|
@ -36,7 +36,6 @@ import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.LoginSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.StatusSessionHandler;
|
||||
import com.velocitypowered.proxy.network.Connections;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.VelocityConnectionEvent;
|
||||
@ -48,17 +47,15 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.handler.codec.haproxy.HAProxyMessage;
|
||||
import io.netty.handler.timeout.ReadTimeoutException;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import java.net.InetSocketAddress;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelFutureListeners;
|
||||
import io.netty5.channel.ChannelHandler;
|
||||
import io.netty5.channel.ChannelHandlerAdapter;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.channel.EventLoop;
|
||||
import io.netty5.handler.timeout.ReadTimeoutException;
|
||||
import io.netty5.util.ReferenceCountUtil;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -72,7 +69,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
* A utility class to make working with the pipeline a little less painful and transparently handles
|
||||
* certain Minecraft protocol mechanics.
|
||||
*/
|
||||
public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
public class MinecraftConnection extends ChannelHandlerAdapter {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(MinecraftConnection.class);
|
||||
|
||||
@ -142,10 +139,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
if (!pkt.handle(sessionHandler)) {
|
||||
sessionHandler.handleGeneric((MinecraftPacket) msg);
|
||||
}
|
||||
} else if (msg instanceof HAProxyMessage) {
|
||||
HAProxyMessage proxyMessage = (HAProxyMessage) msg;
|
||||
this.remoteAddress = new InetSocketAddress(proxyMessage.sourceAddress(),
|
||||
proxyMessage.sourcePort());
|
||||
// TODO: Readd HAProxy support
|
||||
} else if (msg instanceof ByteBuf) {
|
||||
sessionHandler.handleUnknown((ByteBuf) msg);
|
||||
}
|
||||
@ -201,12 +195,13 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureInEventLoop() {
|
||||
Preconditions.checkState(this.channel.eventLoop().inEventLoop(), "Not in event loop");
|
||||
private void ensureInExecutor() {
|
||||
Preconditions.checkState(this.channel.executor().inEventLoop(),
|
||||
"Not running in channel executor");
|
||||
}
|
||||
|
||||
public EventLoop eventLoop() {
|
||||
return channel.eventLoop();
|
||||
public EventLoop executor() {
|
||||
return channel.executor();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +210,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void write(Object msg) {
|
||||
if (channel.isActive()) {
|
||||
channel.writeAndFlush(msg, channel.voidPromise());
|
||||
channel.writeAndFlush(msg);
|
||||
} else {
|
||||
ReferenceCountUtil.release(msg);
|
||||
}
|
||||
@ -227,7 +222,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void delayedWrite(Object msg) {
|
||||
if (channel.isActive()) {
|
||||
channel.write(msg, channel.voidPromise());
|
||||
channel.write(msg);
|
||||
} else {
|
||||
ReferenceCountUtil.release(msg);
|
||||
}
|
||||
@ -251,18 +246,18 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
boolean is17 = this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) < 0
|
||||
&& this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_7_2) >= 0;
|
||||
if (is17 && this.getState() != StateRegistry.STATUS) {
|
||||
channel.eventLoop().execute(() -> {
|
||||
channel.executor().execute(() -> {
|
||||
// 1.7.x versions have a race condition with switching protocol states, so just explicitly
|
||||
// close the connection after a short while.
|
||||
this.setAutoReading(false);
|
||||
channel.eventLoop().schedule(() -> {
|
||||
channel.executor().schedule(() -> {
|
||||
knownDisconnect = true;
|
||||
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
|
||||
channel.writeAndFlush(msg).addListener(channel, ChannelFutureListeners.CLOSE);
|
||||
}, 250, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
} else {
|
||||
knownDisconnect = true;
|
||||
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
|
||||
channel.writeAndFlush(msg).addListener(channel, ChannelFutureListeners.CLOSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -277,13 +272,13 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void close(boolean markKnown) {
|
||||
if (channel.isActive()) {
|
||||
if (channel.eventLoop().inEventLoop()) {
|
||||
if (channel.executor().inEventLoop()) {
|
||||
if (markKnown) {
|
||||
knownDisconnect = true;
|
||||
}
|
||||
channel.close();
|
||||
} else {
|
||||
channel.eventLoop().execute(() -> {
|
||||
channel.executor().execute(() -> {
|
||||
if (markKnown) {
|
||||
knownDisconnect = true;
|
||||
}
|
||||
@ -322,7 +317,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
* @param autoReading whether or not we should read data automatically
|
||||
*/
|
||||
public void setAutoReading(boolean autoReading) {
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
channel.config().setAutoRead(autoReading);
|
||||
if (autoReading) {
|
||||
@ -340,7 +335,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
* @param state the new state
|
||||
*/
|
||||
public void setState(StateRegistry state) {
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
this.state = state;
|
||||
this.channel.pipeline().get(MinecraftEncoder.class).setState(state);
|
||||
@ -356,7 +351,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
* @param protocolVersion the protocol version to use
|
||||
*/
|
||||
public void setProtocolVersion(ProtocolVersion protocolVersion) {
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
boolean changed = this.protocolVersion != protocolVersion;
|
||||
this.protocolVersion = protocolVersion;
|
||||
@ -383,7 +378,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
* @param sessionHandler the handler to use
|
||||
*/
|
||||
public void setSessionHandler(MinecraftSessionHandler sessionHandler) {
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
if (this.sessionHandler != null) {
|
||||
this.sessionHandler.deactivated();
|
||||
@ -403,7 +398,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void setCompressionThreshold(int threshold) {
|
||||
ensureOpen();
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
if (threshold == -1) {
|
||||
final ChannelHandler removedDecoder = channel.pipeline().remove(COMPRESSION_DECODER);
|
||||
@ -445,7 +440,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void enableEncryption(byte[] secret) throws GeneralSecurityException {
|
||||
ensureOpen();
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
|
||||
SecretKey key = new SecretKeySpec(secret, "AES");
|
||||
|
||||
@ -465,7 +460,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
public void setAssociation(MinecraftConnectionAssociation association) {
|
||||
ensureInEventLoop();
|
||||
ensureInExecutor();
|
||||
this.association = association;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.TitleSubtitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.TitleTextPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.TitleTimesPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public interface MinecraftSessionHandler {
|
||||
|
||||
|
@ -48,11 +48,11 @@ import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.handler.timeout.ReadTimeoutException;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.handler.timeout.ReadTimeoutException;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -172,7 +172,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
PlayerResourcePackStatusEvent.Status.DECLINED
|
||||
));
|
||||
}
|
||||
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
||||
}, playerConnection.executor()).exceptionally((ex) -> {
|
||||
if (serverConn.getConnection() != null) {
|
||||
serverConn.getConnection().write(new ResourcePackResponse(
|
||||
packet.getHash(),
|
||||
@ -229,7 +229,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
Unpooled.wrappedBuffer(copy));
|
||||
playerConnection.write(copied);
|
||||
}
|
||||
}, playerConnection.eventLoop())
|
||||
}, playerConnection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling plugin message {}", packet, ex);
|
||||
return null;
|
||||
@ -260,7 +260,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
server.getEventManager().fire(
|
||||
new PlayerAvailableCommandsEvent(serverConn.getPlayer(), rootNode))
|
||||
.thenAcceptAsync(event -> playerConnection.write(commands), playerConnection.eventLoop())
|
||||
.thenAcceptAsync(event -> playerConnection.write(commands), playerConnection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling available commands for {}", playerConnection, ex);
|
||||
return null;
|
||||
|
@ -34,8 +34,8 @@ import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import edu.umd.cs.findbugs.annotations.Nullable;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.util.Optional;
|
||||
import java.util.StringJoiner;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
|
@ -37,9 +37,9 @@ import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -101,7 +101,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
} else {
|
||||
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
||||
}
|
||||
}, mc.eventLoop());
|
||||
}, mc.executor());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
||||
server.getEventManager().fireAndForget(new ServerPostConnectEvent(player,
|
||||
existingConnection == null ? null : existingConnection.getServer()));
|
||||
resultFuture.complete(ConnectionRequestResults.successful(serverConn.getServer()));
|
||||
}, smc.eventLoop())
|
||||
}, smc.executor())
|
||||
.exceptionally(exc -> {
|
||||
logger.error("Unable to switch to new server {} for {}",
|
||||
serverConn.getServerInfo().getName(),
|
||||
|
@ -41,10 +41,9 @@ import com.velocitypowered.proxy.protocol.packet.Handshake;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import java.net.InetSocketAddress;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import io.netty5.channel.Channel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -88,14 +87,16 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
CompletableFuture<Impl> result = new CompletableFuture<>();
|
||||
// Note: we use the event loop for the connection the player is on. This reduces context
|
||||
// switches.
|
||||
server.createBootstrap(proxyPlayer.getConnection().eventLoop())
|
||||
server.createBootstrap(proxyPlayer.getConnection().executor())
|
||||
.handler(server.getBackendChannelInitializer())
|
||||
.connect(registeredServer.getServerInfo().getAddress())
|
||||
.addListener((ChannelFutureListener) future -> {
|
||||
.addListener(future -> {
|
||||
if (future.isSuccess()) {
|
||||
connection = new MinecraftConnection(future.channel(), server);
|
||||
final Channel channel = future.getNow();
|
||||
|
||||
connection = new MinecraftConnection(channel, server);
|
||||
connection.setAssociation(VelocityServerConnection.this);
|
||||
future.channel().pipeline().addLast(HANDLER, connection);
|
||||
channel.pipeline().addLast(HANDLER, connection);
|
||||
|
||||
// Kick off the connection process
|
||||
connection.setSessionHandler(
|
||||
|
@ -58,10 +58,10 @@ import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse.Offer;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.util.CharacterUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import io.netty5.util.ReferenceCountUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -189,7 +189,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
smc.write(packet);
|
||||
}
|
||||
}
|
||||
}, smc.eventLoop())
|
||||
}, smc.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling player chat for {}", player, ex);
|
||||
return null;
|
||||
@ -283,7 +283,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
backendConn.write(message);
|
||||
}
|
||||
}
|
||||
}, backendConn.eventLoop())
|
||||
}, backendConn.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling plugin message packet for {}",
|
||||
player, ex);
|
||||
@ -353,7 +353,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// sure to do it on a future invocation of the event loop, otherwise while the issue will
|
||||
// fix itself, we'll still disable auto-reading and instead of backpressure resolution, we
|
||||
// get client timeouts.
|
||||
player.getConnection().eventLoop().execute(() -> player.getConnection().flush());
|
||||
player.getConnection().executor().execute(() -> player.getConnection().flush());
|
||||
}
|
||||
|
||||
VelocityServerConnection serverConn = player.getConnectedServer();
|
||||
@ -526,7 +526,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
resp.getOffers().addAll(offers);
|
||||
player.getConnection().write(resp);
|
||||
}
|
||||
}, player.getConnection().eventLoop())
|
||||
}, player.getConnection().executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling command tab completion for player {} executing {}",
|
||||
player, command, ex);
|
||||
@ -589,7 +589,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
player.getUsername(),
|
||||
command, e);
|
||||
}
|
||||
}, player.getConnection().eventLoop())
|
||||
}, player.getConnection().executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error(
|
||||
"Exception while finishing command tab completion, with request {} and response {}",
|
||||
@ -610,7 +610,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
response.getOffers().add(new Offer(s));
|
||||
}
|
||||
player.getConnection().write(response);
|
||||
}, player.getConnection().eventLoop())
|
||||
}, player.getConnection().executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error(
|
||||
"Exception while finishing regular tab completion, with request {} and response{}",
|
||||
@ -629,14 +629,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
String commandToRun = result.getCommand().orElse(originalCommand);
|
||||
if (result.isForwardToServer()) {
|
||||
return CompletableFuture.runAsync(() -> smc.write(Chat.createServerbound("/"
|
||||
+ commandToRun)), smc.eventLoop());
|
||||
+ commandToRun)), smc.executor());
|
||||
} else {
|
||||
return server.getCommandManager().executeImmediatelyAsync(player, commandToRun)
|
||||
.thenAcceptAsync(hasRun -> {
|
||||
if (!hasRun) {
|
||||
smc.write(Chat.createServerbound("/" + commandToRun));
|
||||
}
|
||||
}, smc.eventLoop());
|
||||
}, smc.executor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ import com.velocitypowered.proxy.tablist.VelocityTabListLegacy;
|
||||
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
|
||||
import com.velocitypowered.proxy.util.DurationUtils;
|
||||
import com.velocitypowered.proxy.util.collect.CappedSet;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
@ -90,11 +90,10 @@ import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.permission.PermissionChecker;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import net.kyori.adventure.title.Title.Times;
|
||||
import net.kyori.adventure.title.TitlePart;
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
@ -108,8 +107,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
private static final int MAX_PLUGIN_CHANNELS = 1024;
|
||||
private static final PlainComponentSerializer PASS_THRU_TRANSLATE = new PlainComponentSerializer(
|
||||
c -> "", TranslatableComponent::key);
|
||||
private static final PlainTextComponentSerializer PASS_THRU_TRANSLATE =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED;
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class);
|
||||
@ -491,10 +490,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public void disconnect(Component reason) {
|
||||
if (connection.eventLoop().inEventLoop()) {
|
||||
if (connection.executor().inEventLoop()) {
|
||||
disconnect0(reason, false);
|
||||
} else {
|
||||
connection.eventLoop().execute(() -> disconnect0(reason, false));
|
||||
connection.executor().execute(() -> disconnect0(reason, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,7 +688,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// The only remaining value is successful (no need to do anything!)
|
||||
break;
|
||||
}
|
||||
}, connection.eventLoop());
|
||||
}, connection.executor());
|
||||
} else if (event.getResult() instanceof Notify) {
|
||||
Notify res = (Notify) event.getResult();
|
||||
if (event.kickedDuringServerConnect() && previouslyConnected) {
|
||||
@ -701,7 +700,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// In case someone gets creative, assume we want to disconnect the player.
|
||||
disconnect(friendlyReason);
|
||||
}
|
||||
}, connection.eventLoop());
|
||||
}, connection.executor());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -984,7 +983,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
}
|
||||
|
||||
if (!peek) {
|
||||
connection.eventLoop().execute(this::tickResourcePackQueue);
|
||||
connection.executor().execute(this::tickResourcePackQueue);
|
||||
}
|
||||
|
||||
return queued != null
|
||||
@ -1067,7 +1066,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
}
|
||||
|
||||
private CompletableFuture<Optional<Status>> getInitialStatus() {
|
||||
return CompletableFuture.supplyAsync(() -> checkServer(toConnect), connection.eventLoop());
|
||||
return CompletableFuture.supplyAsync(() -> checkServer(toConnect), connection.executor());
|
||||
}
|
||||
|
||||
private CompletableFuture<Impl> internalConnect() {
|
||||
@ -1099,8 +1098,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
ConnectedPlayer.this, server);
|
||||
connectionInFlight = con;
|
||||
return con.connect().whenCompleteAsync(
|
||||
(result, exception) -> this.resetIfInFlightIs(con), connection.eventLoop());
|
||||
}, connection.eventLoop());
|
||||
(result, exception) -> this.resetIfInFlightIs(con), connection.executor());
|
||||
}, connection.executor());
|
||||
});
|
||||
}
|
||||
|
||||
@ -1123,7 +1122,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
if (throwable != null) {
|
||||
logger.error("Exception during connect; status = {}", status, throwable);
|
||||
}
|
||||
}, connection.eventLoop())
|
||||
}, connection.executor())
|
||||
.thenApply(x -> x);
|
||||
}
|
||||
|
||||
@ -1158,7 +1157,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// The only remaining value is successful (no need to do anything!)
|
||||
break;
|
||||
}
|
||||
}, connection.eventLoop())
|
||||
}, connection.executor())
|
||||
.thenApply(Result::isSuccessful);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ import com.velocitypowered.proxy.protocol.packet.Handshake;
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
|
@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayDeque;
|
||||
|
@ -50,14 +50,11 @@ import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
||||
import com.velocitypowered.proxy.util.InformationUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.MessageDigest;
|
||||
@ -176,8 +173,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
hasJoinedResponse.statusCode(), login.getUsername(), playerIp);
|
||||
inbound.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
|
||||
}
|
||||
}, mcConnection.eventLoop()).exceptionally(err -> {
|
||||
mcConnection.eventLoop().execute(() -> {
|
||||
}, mcConnection.executor()).exceptionally(err -> {
|
||||
mcConnection.executor().execute(() -> {
|
||||
if (!mcConnection.isClosed()) {
|
||||
logger.error("Unable to enable encryption", err);
|
||||
mcConnection.close(true);
|
||||
@ -219,7 +216,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
mcConnection.eventLoop().execute(() -> {
|
||||
mcConnection.executor().execute(() -> {
|
||||
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode()
|
||||
|| result.isOnlineModeAllowed())) {
|
||||
// Request encryption.
|
||||
@ -231,7 +228,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
});
|
||||
});
|
||||
}, mcConnection.eventLoop())
|
||||
}, mcConnection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception in pre-login stage", ex);
|
||||
return null;
|
||||
@ -292,8 +289,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
completeLoginProtocolPhaseAndInitialize(player);
|
||||
}
|
||||
}, mcConnection.eventLoop());
|
||||
}, mcConnection.eventLoop()).exceptionally((ex) -> {
|
||||
}, mcConnection.executor());
|
||||
}, mcConnection.executor()).exceptionally((ex) -> {
|
||||
logger.error("Exception during connection of {}", finalProfile, ex);
|
||||
return null;
|
||||
});
|
||||
@ -345,7 +342,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}, mcConnection.eventLoop())
|
||||
}, mcConnection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while completing login initialisation phase for {}", player, ex);
|
||||
return null;
|
||||
@ -366,7 +363,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
return;
|
||||
}
|
||||
player.createConnectionRequest(toTry.get()).fireAndForget();
|
||||
}, mcConnection.eventLoop());
|
||||
}, mcConnection.executor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ import com.velocitypowered.proxy.protocol.packet.StatusRequest;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -96,7 +96,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
continue;
|
||||
}
|
||||
VelocityRegisteredServer vrs = (VelocityRegisteredServer) rs.get();
|
||||
pings.add(vrs.ping(connection.eventLoop(), pingingVersion));
|
||||
pings.add(vrs.ping(connection.executor(), pingingVersion));
|
||||
}
|
||||
if (pings.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(fallback);
|
||||
@ -186,7 +186,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(inbound, ping)))
|
||||
.thenAcceptAsync(event -> connection.closeWith(
|
||||
LegacyDisconnect.fromServerPing(event.getPing(), packet.getVersion())),
|
||||
connection.eventLoop())
|
||||
connection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling legacy ping {}", packet, ex);
|
||||
return null;
|
||||
@ -216,7 +216,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
.toJson(event.getPing(), json);
|
||||
connection.write(new StatusResponse(json));
|
||||
},
|
||||
connection.eventLoop())
|
||||
connection.executor())
|
||||
.exceptionally((ex) -> {
|
||||
logger.error("Exception while handling status request {}", packet, ex);
|
||||
return null;
|
||||
|
@ -26,8 +26,8 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.util.List;
|
||||
|
||||
class LegacyForgeUtil {
|
||||
|
@ -31,9 +31,9 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelInitializer;
|
||||
import io.netty5.handler.timeout.ReadTimeoutHandler;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelInitializer;
|
||||
import java.util.function.Supplier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -25,15 +25,13 @@ import com.velocitypowered.natives.util.Natives;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.network.netty.SeparatePoolInetNameResolver;
|
||||
import com.velocitypowered.proxy.protocol.netty.GS4QueryHandler;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.WriteBufferWaterMark;
|
||||
import io.netty.channel.epoll.EpollChannelOption;
|
||||
import io.netty.util.concurrent.GlobalEventExecutor;
|
||||
import io.netty5.bootstrap.Bootstrap;
|
||||
import io.netty5.bootstrap.ServerBootstrap;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelOption;
|
||||
import io.netty5.channel.EventLoopGroup;
|
||||
import io.netty5.channel.WriteBufferWaterMark;
|
||||
import io.netty5.util.concurrent.GlobalEventExecutor;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.http.HttpClient;
|
||||
import java.util.HashMap;
|
||||
@ -92,7 +90,7 @@ public final class ConnectionManager {
|
||||
*/
|
||||
public void bind(final InetSocketAddress address) {
|
||||
final ServerBootstrap bootstrap = new ServerBootstrap()
|
||||
.channelFactory(this.transportType.serverSocketChannelFactory)
|
||||
.channel(this.transportType.serverSocketChannelClass)
|
||||
.group(this.bossGroup, this.workerGroup)
|
||||
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, SERVER_WRITE_MARK)
|
||||
.childHandler(this.serverChannelInitializer.get())
|
||||
@ -100,13 +98,13 @@ public final class ConnectionManager {
|
||||
.childOption(ChannelOption.IP_TOS, 0x18)
|
||||
.localAddress(address);
|
||||
|
||||
if (transportType == TransportType.EPOLL && server.getConfiguration().useTcpFastOpen()) {
|
||||
bootstrap.option(EpollChannelOption.TCP_FASTOPEN, 3);
|
||||
if (server.getConfiguration().useTcpFastOpen()) {
|
||||
bootstrap.option(ChannelOption.TCP_FASTOPEN, 3);
|
||||
}
|
||||
|
||||
bootstrap.bind()
|
||||
.addListener((ChannelFutureListener) future -> {
|
||||
final Channel channel = future.channel();
|
||||
.addListener(future -> {
|
||||
final Channel channel = future.getNow();
|
||||
if (future.isSuccess()) {
|
||||
this.endpoints.put(address, new Endpoint(channel, ListenerType.MINECRAFT));
|
||||
LOGGER.info("Listening on {}", channel.localAddress());
|
||||
@ -134,8 +132,8 @@ public final class ConnectionManager {
|
||||
.handler(new GS4QueryHandler(this.server))
|
||||
.localAddress(address);
|
||||
bootstrap.bind()
|
||||
.addListener((ChannelFutureListener) future -> {
|
||||
final Channel channel = future.channel();
|
||||
.addListener(future -> {
|
||||
final Channel channel = future.getNow();
|
||||
if (future.isSuccess()) {
|
||||
this.endpoints.put(address, new Endpoint(channel, ListenerType.QUERY));
|
||||
LOGGER.info("Listening for GS4 query on {}", channel.localAddress());
|
||||
@ -164,8 +162,8 @@ public final class ConnectionManager {
|
||||
this.server.getConfiguration().getConnectTimeout())
|
||||
.group(group == null ? this.workerGroup : group)
|
||||
.resolver(this.resolver.asGroup());
|
||||
if (transportType == TransportType.EPOLL && server.getConfiguration().useTcpFastOpen()) {
|
||||
bootstrap.option(EpollChannelOption.TCP_FASTOPEN_CONNECT, true);
|
||||
if (server.getConfiguration().useTcpFastOpen()) {
|
||||
bootstrap.option(ChannelOption.TCP_FASTOPEN_CONNECT, true);
|
||||
}
|
||||
return bootstrap;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.network;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.network.ListenerType;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty5.channel.Channel;
|
||||
|
||||
/**
|
||||
* Represents a listener endpoint.
|
||||
|
@ -35,10 +35,9 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelInitializer;
|
||||
import io.netty5.handler.timeout.ReadTimeoutHandler;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@ -67,8 +66,6 @@ public class ServerChannelInitializer extends ChannelInitializer<Channel> {
|
||||
connection.setSessionHandler(new HandshakeSessionHandler(connection, this.server));
|
||||
ch.pipeline().addLast(Connections.HANDLER, connection);
|
||||
|
||||
if (this.server.getConfiguration().isProxyProtocol()) {
|
||||
ch.pipeline().addFirst(new HAProxyMessageDecoder());
|
||||
}
|
||||
// TODO: Readd HAProxy support
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty5.channel.Channel;
|
||||
import io.netty5.channel.ChannelInitializer;
|
||||
import java.util.function.Supplier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -18,46 +18,49 @@
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import com.velocitypowered.proxy.util.concurrent.VelocityNettyThreadFactory;
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollDatagramChannel;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.DatagramChannel;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty5.channel.ChannelFactory;
|
||||
import io.netty5.channel.EventLoopGroup;
|
||||
import io.netty5.channel.MultithreadEventLoopGroup;
|
||||
import io.netty5.channel.epoll.Epoll;
|
||||
import io.netty5.channel.epoll.EpollDatagramChannel;
|
||||
import io.netty5.channel.epoll.EpollHandler;
|
||||
import io.netty5.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty5.channel.epoll.EpollSocketChannel;
|
||||
import io.netty5.channel.nio.NioHandler;
|
||||
import io.netty5.channel.socket.DatagramChannel;
|
||||
import io.netty5.channel.socket.ServerSocketChannel;
|
||||
import io.netty5.channel.socket.SocketChannel;
|
||||
import io.netty5.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty5.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty5.channel.socket.nio.NioSocketChannel;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
enum TransportType {
|
||||
NIO("NIO", NioServerSocketChannel::new,
|
||||
NIO("NIO", NioServerSocketChannel.class,
|
||||
NioSocketChannel::new,
|
||||
NioDatagramChannel::new,
|
||||
(name, type) -> new NioEventLoopGroup(0, createThreadFactory(name, type))),
|
||||
EPOLL("epoll", EpollServerSocketChannel::new,
|
||||
(name, type) -> new MultithreadEventLoopGroup(0,
|
||||
createThreadFactory(name, type), NioHandler.newFactory())),
|
||||
EPOLL("epoll", EpollServerSocketChannel.class,
|
||||
EpollSocketChannel::new,
|
||||
EpollDatagramChannel::new,
|
||||
(name, type) -> new EpollEventLoopGroup(0, createThreadFactory(name, type)));
|
||||
(name, type) -> new MultithreadEventLoopGroup(0,
|
||||
createThreadFactory(name, type), EpollHandler.newFactory()));
|
||||
|
||||
final String name;
|
||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
|
||||
final Class<? extends ServerSocketChannel> serverSocketChannelClass;
|
||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
|
||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
|
||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory;
|
||||
|
||||
TransportType(final String name,
|
||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
|
||||
final Class<? extends ServerSocketChannel> serverSocketChannelClass,
|
||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
|
||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
|
||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory) {
|
||||
this.name = name;
|
||||
this.serverSocketChannelFactory = serverSocketChannelFactory;
|
||||
this.serverSocketChannelClass = serverSocketChannelClass;
|
||||
this.socketChannelFactory = socketChannelFactory;
|
||||
this.datagramChannelFactory = datagramChannelFactory;
|
||||
this.eventLoopGroupFactory = eventLoopGroupFactory;
|
||||
|
@ -21,13 +21,13 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import io.netty.resolver.AddressResolver;
|
||||
import io.netty.resolver.AddressResolverGroup;
|
||||
import io.netty.resolver.DefaultNameResolver;
|
||||
import io.netty.resolver.InetNameResolver;
|
||||
import io.netty.util.concurrent.EventExecutor;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
import io.netty5.resolver.AddressResolver;
|
||||
import io.netty5.resolver.AddressResolverGroup;
|
||||
import io.netty5.resolver.DefaultNameResolver;
|
||||
import io.netty5.resolver.InetNameResolver;
|
||||
import io.netty5.util.concurrent.EventExecutor;
|
||||
import io.netty5.util.concurrent.Future;
|
||||
import io.netty5.util.concurrent.Promise;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
@ -70,18 +70,15 @@ public final class SeparatePoolInetNameResolver extends InetNameResolver {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
resolveExecutor.execute(() -> {
|
||||
promise.addListener(future -> {
|
||||
resolveExecutor.execute(() -> this.delegate.resolve(inetHost)
|
||||
.addListener(future -> {
|
||||
if (future.isSuccess()) {
|
||||
cache.put(inetHost, ImmutableList.of((InetAddress) future.getNow()));
|
||||
cache.put(inetHost, ImmutableList.of(future.getNow()));
|
||||
promise.trySuccess(future.getNow());
|
||||
} else {
|
||||
promise.tryFailure(future.cause());
|
||||
}
|
||||
});
|
||||
this.delegate.resolve(inetHost, promise);
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,16 +90,16 @@ public final class SeparatePoolInetNameResolver extends InetNameResolver {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
promise.addListener(future -> {
|
||||
if (future.isSuccess()) {
|
||||
cache.put(inetHost, (List<InetAddress>) future.getNow());
|
||||
}
|
||||
});
|
||||
resolveExecutor.execute(() -> this.delegate.resolveAll(inetHost, promise));
|
||||
} catch (RejectedExecutionException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
resolveExecutor.execute(() -> this.delegate.resolve(inetHost)
|
||||
.addListener(future -> {
|
||||
if (future.isSuccess()) {
|
||||
List<InetAddress> addressList = ImmutableList.of(future.getNow());
|
||||
cache.put(inetHost, addressList);
|
||||
promise.trySuccess(addressList);
|
||||
} else {
|
||||
promise.tryFailure(future.cause());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.protocol;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public interface MinecraftPacket {
|
||||
|
||||
|
@ -25,13 +25,13 @@ import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBufInputStream;
|
||||
import io.netty5.buffer.ByteBufOutputStream;
|
||||
import io.netty5.buffer.ByteBufUtil;
|
||||
import io.netty5.handler.codec.CorruptedFrameException;
|
||||
import io.netty5.handler.codec.DecoderException;
|
||||
import io.netty5.handler.codec.EncoderException;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
@ -70,8 +70,8 @@ import com.velocitypowered.proxy.protocol.packet.title.TitleSubtitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.TitleTextPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.title.TitleTimesPacket;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.util.collection.IntObjectHashMap;
|
||||
import io.netty.util.collection.IntObjectMap;
|
||||
import io.netty5.util.collection.IntObjectHashMap;
|
||||
import io.netty5.util.collection.IntObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.util.Collections;
|
||||
|
@ -17,17 +17,17 @@
|
||||
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import io.netty5.channel.ChannelHandlerAdapter;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.util.ReferenceCountUtil;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* A variation on {@link io.netty.handler.flow.FlowControlHandler} that explicitly holds messages
|
||||
* A variation on {@link io.netty5.handler.flow.FlowControlHandler} that explicitly holds messages
|
||||
* on {@code channelRead} and only releases them on an explicit read operation.
|
||||
*/
|
||||
public class AutoReadHolderHandler extends ChannelDuplexHandler {
|
||||
public class AutoReadHolderHandler extends ChannelHandlerAdapter {
|
||||
|
||||
private final Queue<Object> queuedMessages;
|
||||
|
||||
@ -36,7 +36,7 @@ public class AutoReadHolderHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ChannelHandlerContext ctx) throws Exception {
|
||||
public void read(ChannelHandlerContext ctx) {
|
||||
drainQueuedMessages(ctx);
|
||||
ctx.read();
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class AutoReadHolderHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
if (ctx.channel().config().isAutoRead()) {
|
||||
ctx.fireChannelRead(msg);
|
||||
} else {
|
||||
|
@ -30,10 +30,10 @@ import com.velocitypowered.api.plugin.PluginDescription;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.QueryResponse;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.channel.SimpleChannelInboundHandler;
|
||||
import io.netty5.channel.socket.DatagramPacket;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
@ -45,7 +45,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||
@ -83,7 +83,8 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
|
||||
private QueryResponse createInitialResponse() {
|
||||
return QueryResponse.builder()
|
||||
.hostname(PlainComponentSerializer.plain().serialize(server.getConfiguration().getMotd()))
|
||||
.hostname(PlainTextComponentSerializer.plainText()
|
||||
.serialize(server.getConfiguration().getMotd()))
|
||||
.gameVersion(ProtocolVersion.SUPPORTED_VERSION_STRING)
|
||||
.map(server.getConfiguration().getQueryMap())
|
||||
.currentPlayers(server.getPlayerCount())
|
||||
@ -100,7 +101,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
protected void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
ByteBuf queryMessage = msg.content();
|
||||
InetAddress senderAddress = msg.sender().getAddress();
|
||||
|
||||
@ -127,7 +128,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
writeString(queryResponse, Integer.toString(challengeToken));
|
||||
|
||||
DatagramPacket responsePacket = new DatagramPacket(queryResponse, msg.sender());
|
||||
ctx.writeAndFlush(responsePacket, ctx.voidPromise());
|
||||
ctx.writeAndFlush(responsePacket);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -179,8 +180,8 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
|
||||
// Send the response
|
||||
DatagramPacket responsePacket = new DatagramPacket(queryResponse, msg.sender());
|
||||
ctx.writeAndFlush(responsePacket, ctx.voidPromise());
|
||||
}, ctx.channel().eventLoop())
|
||||
ctx.writeAndFlush(responsePacket);
|
||||
}, ctx.channel().executor())
|
||||
.exceptionally((ex) -> {
|
||||
LogManager.getLogger(getClass()).error(
|
||||
"Exception while writing GS4 response for query from {}", senderAddress, ex);
|
||||
|
@ -22,9 +22,9 @@ import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFr
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.ByteToMessageDecoder;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
@ -34,7 +34,7 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
|
||||
private static final String MC_1_6_CHANNEL = "MC|PingHost";
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
if (!in.isReadable()) {
|
||||
return;
|
||||
}
|
||||
@ -49,21 +49,21 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
|
||||
if (first == 0xfe) {
|
||||
// possibly a ping
|
||||
if (!in.isReadable()) {
|
||||
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_3));
|
||||
ctx.fireChannelRead(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_3));
|
||||
return;
|
||||
}
|
||||
|
||||
short next = in.readUnsignedByte();
|
||||
if (next == 1 && !in.isReadable()) {
|
||||
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_4));
|
||||
ctx.fireChannelRead(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_4));
|
||||
return;
|
||||
}
|
||||
|
||||
// We got a 1.6.x ping. Let's chomp off the stuff we don't need.
|
||||
out.add(readExtended16Data(in));
|
||||
ctx.fireChannelRead(readExtended16Data(in));
|
||||
} else if (first == 0x02 && in.isReadable()) {
|
||||
in.skipBytes(in.readableBytes());
|
||||
out.add(new LegacyHandshake());
|
||||
ctx.fireChannelRead(new LegacyHandshake());
|
||||
} else {
|
||||
in.readerIndex(originalReaderIndex);
|
||||
ctx.pipeline().remove(this);
|
||||
|
@ -18,10 +18,10 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandler;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToByteEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
|
@ -20,9 +20,9 @@ package com.velocitypowered.proxy.protocol.netty;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.util.MoreByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToMessageDecoder;
|
||||
import java.util.List;
|
||||
|
||||
public class MinecraftCipherDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
@ -34,11 +34,11 @@ public class MinecraftCipherDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
ByteBuf compatible = MoreByteBufUtils.ensureCompatible(ctx.alloc(), cipher, in).slice();
|
||||
try {
|
||||
cipher.process(compatible);
|
||||
out.add(compatible);
|
||||
ctx.fireChannelRead(compatible);
|
||||
} catch (Exception e) {
|
||||
compatible.release(); // compatible will never be used if we throw an exception
|
||||
throw e;
|
||||
|
@ -20,9 +20,9 @@ package com.velocitypowered.proxy.protocol.netty;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.util.MoreByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToMessageEncoder;
|
||||
import java.util.List;
|
||||
|
||||
public class MinecraftCipherEncoder extends MessageToMessageEncoder<ByteBuf> {
|
||||
|
@ -23,9 +23,9 @@ import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFr
|
||||
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToMessageDecoder;
|
||||
import java.util.List;
|
||||
|
||||
public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
@ -46,11 +46,11 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
|
||||
if (claimedUncompressedSize == 0) {
|
||||
// This message is not compressed.
|
||||
out.add(in.retain());
|
||||
ctx.fireChannelRead(in.retain());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
ByteBuf uncompressed = preferredBuffer(ctx.alloc(), compressor, claimedUncompressedSize);
|
||||
try {
|
||||
compressor.inflate(compatibleIn, uncompressed, claimedUncompressedSize);
|
||||
out.add(uncompressed);
|
||||
ctx.fireChannelRead(uncompressed);
|
||||
} catch (Exception e) {
|
||||
uncompressed.release();
|
||||
throw e;
|
||||
|
@ -22,9 +22,9 @@ import static com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEnco
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import com.velocitypowered.natives.util.MoreByteBufUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToByteEncoder;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
public class MinecraftCompressorAndLengthEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
|
@ -23,12 +23,12 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerAdapter;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.CorruptedFrameException;
|
||||
|
||||
public class MinecraftDecoder extends ChannelInboundHandlerAdapter {
|
||||
public class MinecraftDecoder extends ChannelHandlerAdapter {
|
||||
|
||||
public static final boolean DEBUG = Boolean.getBoolean("velocity.packet-decode-logging");
|
||||
private static final QuietRuntimeException DECODE_FAILED =
|
||||
|
@ -22,9 +22,9 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class MinecraftEncoder extends MessageToByteEncoder<MinecraftPacket> {
|
||||
|
||||
|
@ -19,9 +19,9 @@ package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.netty.VarintByteDecoder.DecodeResult;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.ByteToMessageDecoder;
|
||||
import java.util.List;
|
||||
|
||||
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||
@ -32,7 +32,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||
new QuietDecoderException("VarInt too big");
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in) {
|
||||
if (!ctx.channel().isActive()) {
|
||||
in.clear();
|
||||
return;
|
||||
@ -66,7 +66,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||
} else {
|
||||
int minimumRead = bytesRead + readVarint;
|
||||
if (in.isReadable(minimumRead)) {
|
||||
out.add(in.retainedSlice(varintEnd + 1, readVarint));
|
||||
ctx.fireChannelRead(in.retainedSlice(varintEnd + 1, readVarint));
|
||||
in.skipBytes(minimumRead);
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ package com.velocitypowered.proxy.protocol.netty;
|
||||
import com.velocitypowered.natives.encryption.JavaVelocityCipher;
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.channel.ChannelHandler;
|
||||
import io.netty5.channel.ChannelHandlerContext;
|
||||
import io.netty5.handler.codec.MessageToByteEncoder;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class MinecraftVarintLengthEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
import io.netty5.util.ByteProcessor;
|
||||
|
||||
class VarintByteDecoder implements ByteProcessor {
|
||||
|
||||
|
@ -41,7 +41,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentPropertyRegistry;
|
||||
import com.velocitypowered.proxy.util.collect.IdentityHashStrategy;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenCustomHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import java.util.ArrayDeque;
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ClientSettings implements MinecraftPacket {
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Disconnect implements MinecraftPacket {
|
||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EncryptionRequest implements MinecraftPacket {
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EncryptionResponse implements MinecraftPacket {
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class Handshake implements MinecraftPacket {
|
||||
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.connection.registry.DimensionData;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionInfo;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionRegistry;
|
||||
import com.velocitypowered.proxy.protocol.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import net.kyori.adventure.nbt.BinaryTagIO;
|
||||
import net.kyori.adventure.nbt.BinaryTagTypes;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class KeepAlive implements MinecraftPacket {
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class LegacyHandshake implements MinecraftPacket {
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -22,8 +22,8 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class LoginPluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
|
||||
|
@ -22,8 +22,8 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
public class LoginPluginResponse extends DeferredByteBufHolder implements MinecraftPacket {
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
public class ResourcePackResponse implements MinecraftPacket {
|
||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.connection.registry.DimensionData;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionInfo;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import net.kyori.adventure.nbt.BinaryTagIO;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ServerLogin implements MinecraftPacket {
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.api.util.UuidUtils;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class SetCompression implements MinecraftPacket {
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class StatusPing implements MinecraftPacket {
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class StatusRequest implements MinecraftPacket {
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class StatusResponse implements MinecraftPacket {
|
||||
|
@ -26,7 +26,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TabCompleteRequest implements MinecraftPacket {
|
||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -33,7 +33,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ArgumentPropertySerializer<T> {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
class ByteArgumentPropertySerializer implements ArgumentPropertySerializer<Byte> {
|
||||
|
||||
|
@ -22,7 +22,7 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumen
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags;
|
||||
|
||||
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
class DoubleArgumentPropertySerializer implements ArgumentPropertySerializer<DoubleArgumentType> {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumen
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags;
|
||||
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
class FloatArgumentPropertySerializer implements ArgumentPropertySerializer<FloatArgumentType> {
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
class IntegerArgumentPropertySerializer implements ArgumentPropertySerializer<IntegerArgumentType> {
|
||||
|
||||
|
@ -22,7 +22,7 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumen
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags;
|
||||
|
||||
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
class LongArgumentPropertySerializer implements ArgumentPropertySerializer<LongArgumentType> {
|
||||
|
||||
|
@ -23,8 +23,8 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import io.netty5.buffer.Unpooled;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
class ModArgumentPropertySerializer implements ArgumentPropertySerializer<ModArgumentProperty> {
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class RegistryKeyArgumentSerializer implements ArgumentPropertySerializer<RegistryKeyArgument> {
|
||||
static final RegistryKeyArgumentSerializer REGISTRY = new RegistryKeyArgumentSerializer();
|
||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* Serializes properties for {@link StringArgumentType}.
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class GenericTitlePacket implements MinecraftPacket {
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class LegacyTitlePacket extends GenericTitlePacket {
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class TitleActionbarPacket extends GenericTitlePacket {
|
||||
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class TitleClearPacket extends GenericTitlePacket {
|
||||
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class TitleSubtitlePacket extends GenericTitlePacket {
|
||||
|
||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.protocol.packet.title;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty5.buffer.ByteBuf;
|
||||
|
||||
public class TitleTextPacket extends GenericTitlePacket {
|
||||
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren