This is so tiring
This commit is contained in:
parent
4fb85721a9
commit
504f703fbb
@ -117,7 +117,7 @@ public class EntityMap
|
|||||||
|
|
||||||
public static void rewrite(ByteBuf packet, int oldId, int newId)
|
public static void rewrite(ByteBuf packet, int oldId, int newId)
|
||||||
{
|
{
|
||||||
int packetId = packet.getUnsignedShort( 0 );
|
int packetId = packet.getUnsignedByte( 0 );
|
||||||
if ( packetId == 0x1D )
|
if ( packetId == 0x1D )
|
||||||
{ // bulk entity
|
{ // bulk entity
|
||||||
for ( int pos = 2; pos < packet.writerIndex(); pos += 4 )
|
for ( int pos = 2; pos < packet.writerIndex(); pos += 4 )
|
||||||
|
@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||||
|
import net.md_5.bungee.connection.CancelSendSignal;
|
||||||
import net.md_5.bungee.connection.DownstreamBridge;
|
import net.md_5.bungee.connection.DownstreamBridge;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.packet.DefinedPacket;
|
||||||
@ -100,6 +101,8 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisState = State.FINISHED;
|
thisState = State.FINISHED;
|
||||||
|
|
||||||
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
class CancelSendSignal extends Error
|
public class CancelSendSignal extends Error
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
import net.md_5.bungee.netty.CipherCodec;
|
import net.md_5.bungee.netty.CipherCodec;
|
||||||
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.netty.PacketDecoder;
|
import net.md_5.bungee.netty.PacketDecoder;
|
||||||
import net.md_5.bungee.packet.Packet1Login;
|
import net.md_5.bungee.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.Packet2Handshake;
|
import net.md_5.bungee.packet.Packet2Handshake;
|
||||||
@ -198,6 +199,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
||||||
|
|
||||||
UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages );
|
UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages );
|
||||||
|
ch.pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
|
|
||||||
ServerInfo server = bungee.getReconnectHandler().getServer( userCon );
|
ServerInfo server = bungee.getReconnectHandler().getServer( userCon );
|
||||||
userCon.connect( server );
|
userCon.connect( server );
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import net.md_5.bungee.api.event.ChatEvent;
|
import net.md_5.bungee.api.event.ChatEvent;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
import net.md_5.bungee.packet.Packet0KeepAlive;
|
||||||
|
import net.md_5.bungee.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
@ -23,8 +24,17 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
public void handle(ByteBuf buf) throws Exception
|
public void handle(ByteBuf buf) throws Exception
|
||||||
{
|
{
|
||||||
EntityMap.rewrite( buf, con.clientEntityId, con.serverEntityId );
|
EntityMap.rewrite( buf, con.clientEntityId, con.serverEntityId );
|
||||||
|
if ( con.getServer() != null )
|
||||||
|
{
|
||||||
con.getServer().getCh().write( buf );
|
con.getServer().getCh().write( buf );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Packet1Login login) throws Exception
|
||||||
|
{
|
||||||
|
super.handle( login ); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Packet0KeepAlive alive) throws Exception
|
public void handle(Packet0KeepAlive alive) throws Exception
|
||||||
|
@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||||
import net.md_5.bungee.Util;
|
import net.md_5.bungee.connection.CancelSendSignal;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ -48,13 +48,23 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<ByteBuf>
|
|||||||
if ( handler != null && ctx.channel().isActive() )
|
if ( handler != null && ctx.channel().isActive() )
|
||||||
{
|
{
|
||||||
DefinedPacket packet = DefinedPacket.packet( msg );
|
DefinedPacket packet = DefinedPacket.packet( msg );
|
||||||
|
boolean sendPacket = true;
|
||||||
if ( packet != null )
|
if ( packet != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
packet.handle( handler );
|
packet.handle( handler );
|
||||||
|
} catch ( CancelSendSignal ex )
|
||||||
|
{
|
||||||
|
sendPacket = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ( sendPacket )
|
||||||
|
{
|
||||||
handler.handle( msg );
|
handler.handle( msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package net.md_5.bungee.netty;
|
package net.md_5.bungee.netty;
|
||||||
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelException;
|
import io.netty.channel.ChannelException;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.ChannelOutboundMessageHandlerAdapter;
|
||||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
import io.netty.util.AttributeKey;
|
import io.netty.util.AttributeKey;
|
||||||
import java.net.SocketAddress;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.ServerConnector;
|
import net.md_5.bungee.ServerConnector;
|
||||||
|
Loading…
Reference in New Issue
Block a user