Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
rebased on master
Dieser Commit ist enthalten in:
Ursprung
4813cc3077
Commit
6c3479e739
@ -26,11 +26,7 @@ import us.myles.ViaVersion.util.GsonUtil;
|
|||||||
import us.myles.ViaVersion.velocity.VersionInfo;
|
import us.myles.ViaVersion.velocity.VersionInfo;
|
||||||
import us.myles.ViaVersion.velocity.command.VelocityCommandHandler;
|
import us.myles.ViaVersion.velocity.command.VelocityCommandHandler;
|
||||||
import us.myles.ViaVersion.velocity.command.VelocityCommandSender;
|
import us.myles.ViaVersion.velocity.command.VelocityCommandSender;
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityTaskId;
|
import us.myles.ViaVersion.velocity.platform.*;
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaAPI;
|
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaConfig;
|
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaInjector;
|
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaLoader;
|
|
||||||
import us.myles.ViaVersion.velocity.service.ProtocolDetectorService;
|
import us.myles.ViaVersion.velocity.service.ProtocolDetectorService;
|
||||||
import us.myles.ViaVersion.velocity.util.LoggerWrapper;
|
import us.myles.ViaVersion.velocity.util.LoggerWrapper;
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ public class VelocityDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
|
|
||||||
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
||||||
try {
|
try {
|
||||||
boolean needsCompress = handleCompressionOrder(ctx, draft);
|
boolean needsCompress = handleCompressionOrder(ctx, bytebuf);
|
||||||
|
|
||||||
info.transformIncoming(draft, CancelDecoderException::generate);
|
info.transformIncoming(bytebuf, CancelDecoderException::generate);
|
||||||
|
|
||||||
if (needsCompress) {
|
if (needsCompress) {
|
||||||
recompress(ctx, draft);
|
recompress(ctx, bytebuf);
|
||||||
}
|
}
|
||||||
out.add(draft.retain());
|
out.add(bytebuf.retain());
|
||||||
} finally {
|
} finally {
|
||||||
transformedBuf.release();
|
transformedBuf.release();
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class VelocityEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf draft) throws InvocationTargetException {
|
private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException {
|
||||||
//if (handledCompression) return false;
|
//if (handledCompression) return false;
|
||||||
|
|
||||||
int encoderIndex = ctx.pipeline().names().indexOf("compression-encoder");
|
int encoderIndex = ctx.pipeline().names().indexOf("compression-encoder");
|
||||||
|
@ -1,33 +1,11 @@
|
|||||||
package us.myles.ViaVersion.velocity.platform;
|
package us.myles.ViaVersion.velocity.platform;
|
||||||
|
|
||||||
import io.netty.channel.ServerChannel;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class VelocityConnectionManager extends ViaConnectionManager {
|
public class VelocityConnectionManager extends ViaConnectionManager {
|
||||||
@Override
|
@Override
|
||||||
public void onLoginSuccess(UserConnection connection) {
|
public boolean isFrontEnd(UserConnection conn) {
|
||||||
if (connection.isClientSide()) {
|
return !conn.isClientSide();
|
||||||
System.out.println("backend connect!");
|
|
||||||
Objects.requireNonNull(connection, "connection is null!");
|
|
||||||
connections.add(connection);
|
|
||||||
} else {
|
|
||||||
System.out.println("frontend connect!");
|
|
||||||
super.onLoginSuccess(connection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(UserConnection connection) {
|
|
||||||
if (connection.isClientSide()) {
|
|
||||||
System.out.println("backend disconnect!");
|
|
||||||
Objects.requireNonNull(connection, "connection is null!");
|
|
||||||
connections.remove(connection);
|
|
||||||
} else {
|
|
||||||
System.out.println("frontend disconnect!");
|
|
||||||
super.onDisconnect(connection);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren