Compare commits
12 Commits
497c6879e0
...
a7dbbc2f0a
Author | SHA1 | Date | |
---|---|---|---|
|
a7dbbc2f0a | ||
|
68b2df2b1e | ||
|
1ef4d27dbe | ||
|
94a1fb5117 | ||
|
78aef86a8f | ||
|
b34cfcde5a | ||
|
86e079a4b1 | ||
|
1c42c34081 | ||
|
fed646d18b | ||
|
653f1691d7 | ||
|
3cb7a12738 | ||
|
f3397b3003 |
@ -55,7 +55,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.5.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -33,6 +33,13 @@ public final class SelectorComponent extends BaseComponent
|
|||||||
*/
|
*/
|
||||||
private String selector;
|
private String selector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The separator of multiple selected entities.
|
||||||
|
* <br>
|
||||||
|
* The default is {@code {"color": "gray", "text": ", "}}.
|
||||||
|
*/
|
||||||
|
private BaseComponent separator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a selector component from the original to clone it.
|
* Creates a selector component from the original to clone it.
|
||||||
*
|
*
|
||||||
@ -42,6 +49,17 @@ public final class SelectorComponent extends BaseComponent
|
|||||||
{
|
{
|
||||||
super( original );
|
super( original );
|
||||||
setSelector( original.getSelector() );
|
setSelector( original.getSelector() );
|
||||||
|
setSeparator( original.getSeparator() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a selector component from the selector
|
||||||
|
*
|
||||||
|
* @param selector the selector as a String
|
||||||
|
*/
|
||||||
|
public SelectorComponent(String selector)
|
||||||
|
{
|
||||||
|
setSelector( selector );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,12 @@ public class SelectorComponentSerializer extends BaseComponentSerializer impleme
|
|||||||
throw new JsonParseException( "Could not parse JSON: missing 'selector' property" );
|
throw new JsonParseException( "Could not parse JSON: missing 'selector' property" );
|
||||||
}
|
}
|
||||||
SelectorComponent component = new SelectorComponent( object.get( "selector" ).getAsString() );
|
SelectorComponent component = new SelectorComponent( object.get( "selector" ).getAsString() );
|
||||||
|
|
||||||
|
if ( object.has( "separator" ) )
|
||||||
|
{
|
||||||
|
component.setSeparator( ComponentSerializer.deserialize( object.get( "separator" ).getAsString() ) );
|
||||||
|
}
|
||||||
|
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
@ -32,6 +38,11 @@ public class SelectorComponentSerializer extends BaseComponentSerializer impleme
|
|||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
serialize( object, component, context );
|
serialize( object, component, context );
|
||||||
object.addProperty( "selector", component.getSelector() );
|
object.addProperty( "selector", component.getSelector() );
|
||||||
|
|
||||||
|
if ( component.getSeparator() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "separator", ComponentSerializer.toString( component.getSeparator() ) );
|
||||||
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CommandSend extends Command implements TabExecutor
|
|||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
for ( ServerConnectRequest.Result result : ServerConnectRequest.Result.values() )
|
for ( ServerConnectRequest.Result result : ServerConnectRequest.Result.values() )
|
||||||
{
|
{
|
||||||
results.put( result, new ArrayList<String>() );
|
results.put( result, Collections.synchronizedList( new ArrayList<>() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -83,7 +83,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-bom</artifactId>
|
<artifactId>netty-bom</artifactId>
|
||||||
<version>4.1.97.Final</version>
|
<version>4.1.99.Final</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -31,12 +31,12 @@ public class LegacyDecoder extends ByteToMessageDecoder
|
|||||||
|
|
||||||
if ( packetID == 0xFE )
|
if ( packetID == 0xFE )
|
||||||
{
|
{
|
||||||
out.add( new PacketWrapper( new LegacyPing( in.isReadable() && in.readUnsignedByte() == 0x01 ), Unpooled.EMPTY_BUFFER ) );
|
out.add( new PacketWrapper( new LegacyPing( in.isReadable() && in.readUnsignedByte() == 0x01 ), Unpooled.EMPTY_BUFFER, Protocol.STATUS ) );
|
||||||
return;
|
return;
|
||||||
} else if ( packetID == 0x02 && in.isReadable() )
|
} else if ( packetID == 0x02 && in.isReadable() )
|
||||||
{
|
{
|
||||||
in.skipBytes( in.readableBytes() );
|
in.skipBytes( in.readableBytes() );
|
||||||
out.add( new PacketWrapper( new LegacyHandshake(), Unpooled.EMPTY_BUFFER ) );
|
out.add( new PacketWrapper( new LegacyHandshake(), Unpooled.EMPTY_BUFFER, Protocol.STATUS ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
|||||||
in.skipBytes( in.readableBytes() );
|
in.skipBytes( in.readableBytes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
out.add( new PacketWrapper( packet, slice ) );
|
out.add( new PacketWrapper( packet, slice, protocol ) );
|
||||||
slice = null;
|
slice = null;
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@ public class PacketWrapper
|
|||||||
|
|
||||||
public final DefinedPacket packet;
|
public final DefinedPacket packet;
|
||||||
public final ByteBuf buf;
|
public final ByteBuf buf;
|
||||||
|
public final Protocol protocol;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean released;
|
private boolean released;
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public class BungeeTitle implements Title
|
|||||||
{
|
{
|
||||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_17 )
|
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_17 )
|
||||||
{
|
{
|
||||||
player.unsafe().sendPacket( packet.newPacket );
|
( (UserConnection) player ).sendPacketQueued( packet.newPacket );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
player.unsafe().sendPacket( packet.oldPacket );
|
player.unsafe().sendPacket( packet.oldPacket );
|
||||||
|
@ -43,7 +43,6 @@ import net.md_5.bungee.protocol.packet.GameState;
|
|||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@ -334,9 +333,9 @@ public class ServerConnector extends PacketHandler
|
|||||||
user.unsafe().sendPacket( new StartConfiguration() );
|
user.unsafe().sendPacket( new StartConfiguration() );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ch.setDecodeProtocol( Protocol.CONFIGURATION );
|
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
|
||||||
ch.write( new LoginAcknowledged() );
|
user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
||||||
ch.setEncodeProtocol( Protocol.CONFIGURATION );
|
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
|||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||||
@ -123,12 +122,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private enum State
|
private enum State
|
||||||
{
|
{
|
||||||
|
|
||||||
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING, CONFIGURING;
|
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSendKickMessage()
|
private boolean canSendKickMessage()
|
||||||
{
|
{
|
||||||
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING || thisState == State.CONFIGURING;
|
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -598,15 +597,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
|
userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
|
||||||
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
|
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
|
||||||
|
|
||||||
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
|
||||||
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
thisState = State.CONFIGURING;
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
|
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
||||||
ch.setProtocol( Protocol.GAME );
|
ch.setProtocol( Protocol.GAME );
|
||||||
finish2();
|
|
||||||
}
|
}
|
||||||
|
finish2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@ -617,15 +613,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
|
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
|
|
||||||
{
|
|
||||||
Preconditions.checkState( thisState == State.CONFIGURING, "Not expecting CONFIGURING" );
|
|
||||||
|
|
||||||
finish2();
|
|
||||||
ch.setEncodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finish2()
|
private void finish2()
|
||||||
{
|
{
|
||||||
userCon.init();
|
userCon.init();
|
||||||
|
@ -10,6 +10,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.ServerConnection;
|
||||||
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
||||||
import net.md_5.bungee.UserConnection;
|
import net.md_5.bungee.UserConnection;
|
||||||
import net.md_5.bungee.Util;
|
import net.md_5.bungee.Util;
|
||||||
@ -134,14 +135,22 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper packet) throws Exception
|
public void handle(PacketWrapper packet) throws Exception
|
||||||
{
|
{
|
||||||
if ( con.getServer() != null )
|
ServerConnection server = con.getServer();
|
||||||
|
if ( server != null && server.isConnected() )
|
||||||
{
|
{
|
||||||
|
Protocol serverEncode = server.getCh().getEncodeProtocol();
|
||||||
|
// #3527: May still have old packets from client in game state when switching server to configuration state - discard those
|
||||||
|
if ( packet.protocol != serverEncode )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EntityMap rewrite = con.getEntityRewrite();
|
EntityMap rewrite = con.getEntityRewrite();
|
||||||
if ( rewrite != null && con.getServer().getCh().getEncodeProtocol() == Protocol.GAME )
|
if ( rewrite != null && serverEncode == Protocol.GAME )
|
||||||
{
|
{
|
||||||
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
||||||
}
|
}
|
||||||
con.getServer().getCh().write( packet );
|
server.getCh().write( packet );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,8 +331,19 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
con.getPendingConnection().relayMessage( pluginMessage );
|
con.getPendingConnection().relayMessage( pluginMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
|
||||||
|
{
|
||||||
|
configureServer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(StartConfiguration startConfiguration) throws Exception
|
public void handle(StartConfiguration startConfiguration) throws Exception
|
||||||
|
{
|
||||||
|
configureServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureServer()
|
||||||
{
|
{
|
||||||
ChannelWrapper ch = con.getServer().getCh();
|
ChannelWrapper ch = con.getServer().getCh();
|
||||||
if ( ch.getDecodeProtocol() == Protocol.LOGIN )
|
if ( ch.getDecodeProtocol() == Protocol.LOGIN )
|
||||||
@ -342,8 +362,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
||||||
{
|
{
|
||||||
con.sendQueuedPackets();
|
con.sendQueuedPackets();
|
||||||
|
|
||||||
super.handle( finishConfiguration );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -174,7 +174,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||||||
{
|
{
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - could not decode packet! {1}", new Object[]
|
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - could not decode packet! {1}", new Object[]
|
||||||
{
|
{
|
||||||
handler, cause.getCause() != null ? cause.getCause() : cause
|
handler, cause
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
} else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) )
|
} else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user