Skip to content

Commit

Permalink
Merge branch 'master' into patch-68
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer authored Oct 6, 2023
2 parents 688bfeb + a7dbbc2 commit 74c5a04
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 13 deletions.
18 changes: 18 additions & 0 deletions chat/src/main/java/net/md_5/bungee/api/chat/SelectorComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public final class SelectorComponent extends BaseComponent
*/
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.
*
Expand All @@ -42,6 +49,17 @@ public SelectorComponent(SelectorComponent original)
{
super( original );
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public SelectorComponent deserialize(JsonElement element, Type type, JsonDeseria
throw new JsonParseException( "Could not parse JSON: missing 'selector' property" );
}
SelectorComponent component = new SelectorComponent( object.get( "selector" ).getAsString() );

if ( object.has( "separator" ) )
{
component.setSeparator( ComponentSerializer.deserialize( object.get( "separator" ).getAsString() ) );
}

deserialize( object, component, context );
return component;
}
Expand All @@ -32,6 +38,11 @@ public JsonElement serialize(SelectorComponent component, Type type, JsonSeriali
JsonObject object = new JsonObject();
serialize( object, component, context );
object.addProperty( "selector", component.getSelector() );

if ( component.getSeparator() != null )
{
object.addProperty( "separator", ComponentSerializer.toString( component.getSeparator() ) );
}
return object;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SendCallback(CommandSender sender)
this.sender = sender;
for ( ServerConnectRequest.Result result : ServerConnectRequest.Result.values() )
{
results.put( result, new ArrayList<String>() );
results.put( result, Collections.synchronizedList( new ArrayList<>() ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.97.Final</version>
<version>4.1.99.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private static void sendPacket(ProxiedPlayer player, TitlePacketHolder packet)
{
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_17 )
{
player.unsafe().sendPacket( packet.newPacket );
( (UserConnection) player ).sendPacketQueued( packet.newPacket );
} else
{
player.unsafe().sendPacket( packet.oldPacket );
Expand Down
7 changes: 3 additions & 4 deletions proxy/src/main/java/net/md_5/bungee/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.Kick;
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.LoginPayloadResponse;
import net.md_5.bungee.protocol.packet.LoginRequest;
Expand Down Expand Up @@ -334,9 +333,9 @@ private void cutThrough(ServerConnection server)
user.unsafe().sendPacket( new StartConfiguration() );
} else
{
ch.setDecodeProtocol( Protocol.CONFIGURATION );
ch.write( new LoginAcknowledged() );
ch.setEncodeProtocol( Protocol.CONFIGURATION );
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public boolean shouldHandle(PacketWrapper packet) throws Exception

private enum State
{

HANDSHAKE, STATUS, PING_EVENT, PING, USERNAME, ENCRYPT, FINISHING;
}

Expand Down
21 changes: 16 additions & 5 deletions proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.UUID;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.ServerConnection.KeepAliveData;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.Util;
Expand Down Expand Up @@ -134,9 +135,10 @@ public boolean shouldHandle(PacketWrapper packet) throws Exception
@Override
public void handle(PacketWrapper packet) throws Exception
{
if ( con.getServer() != null )
ServerConnection server = con.getServer();
if ( server != null && server.isConnected() )
{
Protocol serverEncode = con.getServer().getCh().getEncodeProtocol();
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 )
{
Expand All @@ -148,7 +150,7 @@ public void handle(PacketWrapper packet) throws Exception
{
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
}
con.getServer().getCh().write( packet );
server.getCh().write( packet );
}
}

Expand Down Expand Up @@ -329,8 +331,19 @@ public void handle(PluginMessage pluginMessage) throws Exception
con.getPendingConnection().relayMessage( pluginMessage );
}

@Override
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
{
configureServer();
}

@Override
public void handle(StartConfiguration startConfiguration) throws Exception
{
configureServer();
}

private void configureServer()
{
ChannelWrapper ch = con.getServer().getCh();
if ( ch.getDecodeProtocol() == Protocol.LOGIN )
Expand All @@ -349,8 +362,6 @@ public void handle(StartConfiguration startConfiguration) throws Exception
public void handle(FinishConfiguration finishConfiguration) throws Exception
{
con.sendQueuedPackets();

super.handle( finishConfiguration );
}

@Override
Expand Down

0 comments on commit 74c5a04

Please sign in to comment.