3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Merge branch 'master' into dev

Dieser Commit ist enthalten in:
Myles 2017-04-01 00:07:32 +01:00
Commit e3c4253c13
3 geänderte Dateien mit 22 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@ License:
MIT License MIT License
Copyright (c) 2016 Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

Datei anzeigen

@ -46,6 +46,8 @@ public class ViaManager {
// Check for updates // Check for updates
if (platform.getConf().isCheckForUpdates()) if (platform.getConf().isCheckForUpdates())
UpdateUtil.sendUpdateMessage(); UpdateUtil.sendUpdateMessage();
// Force class load
ProtocolRegistry.getSupportedVersions();
// Inject // Inject
try { try {
injector.inject(); injector.inject();

Datei anzeigen

@ -7,6 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -31,18 +32,23 @@ public class SpongeChannelInitializer extends ChannelInitializer<SocketChannel>
@Override @Override
protected void initChannel(SocketChannel socketChannel) throws Exception { protected void initChannel(SocketChannel socketChannel) throws Exception {
UserConnection info = new UserConnection(socketChannel); // Ensure ViaVersion is loaded
// init protocol if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
new ProtocolPipeline(info); UserConnection info = new UserConnection(socketChannel);
// Add originals // init protocol
this.method.invoke(this.original, socketChannel); new ProtocolPipeline(info);
// Add our transformers // Add originals
MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder")); this.method.invoke(this.original, socketChannel);
ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder")); // Add our transformers
SpongePacketHandler chunkHandler = new SpongePacketHandler(info); MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder"));
ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder"));
SpongePacketHandler chunkHandler = new SpongePacketHandler(info);
socketChannel.pipeline().replace("encoder", "encoder", encoder); socketChannel.pipeline().replace("encoder", "encoder", encoder);
socketChannel.pipeline().replace("decoder", "decoder", decoder); socketChannel.pipeline().replace("decoder", "decoder", decoder);
socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler);
} else {
this.method.invoke(this.original, socketChannel);
}
} }
} }