mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 20:59:12 +01:00
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)
|
||||
{
|
||||
int packetId = packet.getUnsignedShort( 0 );
|
||||
int packetId = packet.getUnsignedByte( 0 );
|
||||
if ( packetId == 0x1D )
|
||||
{ // bulk entity
|
||||
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.config.ServerInfo;
|
||||
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.netty.HandlerBoss;
|
||||
import net.md_5.bungee.packet.DefinedPacket;
|
||||
@ -100,6 +101,8 @@ public class ServerConnector extends PacketHandler
|
||||
}
|
||||
|
||||
thisState = State.FINISHED;
|
||||
|
||||
throw new CancelSendSignal();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
class CancelSendSignal extends Error
|
||||
public class CancelSendSignal extends Error
|
||||
{
|
||||
|
||||
@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.ProxyPingEvent;
|
||||
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.packet.Packet1Login;
|
||||
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" );
|
||||
|
||||
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 );
|
||||
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.PluginMessageEvent;
|
||||
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.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.packet.PacketHandler;
|
||||
@ -23,7 +24,16 @@ public class UpstreamBridge extends PacketHandler
|
||||
public void handle(ByteBuf buf) throws Exception
|
||||
{
|
||||
EntityMap.rewrite( buf, con.clientEntityId, con.serverEntityId );
|
||||
con.getServer().getCh().write( buf );
|
||||
if ( con.getServer() != null )
|
||||
{
|
||||
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
|
||||
|
@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
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.PacketHandler;
|
||||
|
||||
@ -48,11 +48,21 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<ByteBuf>
|
||||
if ( handler != null && ctx.channel().isActive() )
|
||||
{
|
||||
DefinedPacket packet = DefinedPacket.packet( msg );
|
||||
boolean sendPacket = true;
|
||||
if ( packet != null )
|
||||
{
|
||||
packet.handle( handler );
|
||||
try
|
||||
{
|
||||
packet.handle( handler );
|
||||
} catch ( CancelSendSignal ex )
|
||||
{
|
||||
sendPacket = false;
|
||||
}
|
||||
}
|
||||
if ( sendPacket )
|
||||
{
|
||||
handler.handle( msg );
|
||||
}
|
||||
handler.handle( msg );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
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.ChannelException;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
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.util.AttributeKey;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.ServerConnector;
|
||||
@ -46,7 +45,7 @@ public class PipelineUtils
|
||||
};
|
||||
public static final Base BASE = new Base();
|
||||
|
||||
public final static class Base extends ChannelInitializer<Channel>
|
||||
public final static class Base extends ChannelInitializer<Channel>
|
||||
{
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user