Minecraft 1.19.3 support

This commit is contained in:
md_5
2022-12-08 03:00:00 +11:00
parent 511017ab35
commit 5467e3a842
23 changed files with 712 additions and 90 deletions

View File

@@ -54,6 +54,8 @@ import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
@@ -153,6 +155,20 @@ public class DownstreamBridge extends PacketHandler
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
}
@Override
public void handle(PlayerListItemRemove playerList) throws Exception
{
con.getTabListHandler().onUpdate( TabList.rewrite( playerList ) );
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
}
@Override
public void handle(PlayerListItemUpdate playerList) throws Exception
{
con.getTabListHandler().onUpdate( TabList.rewrite( playerList ) );
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
}
@Override
public void handle(ScoreboardObjective objective) throws Exception
{

View File

@@ -383,7 +383,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return;
}
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() && getVersion() < ProtocolConstants.MINECRAFT_1_19_3 )
{
PlayerPublicKey publicKey = loginRequest.getPublicKey();
if ( publicKey == null )
@@ -522,7 +522,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
{
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_19_1 )
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_19_1 && getVersion() < ProtocolConstants.MINECRAFT_1_19_3 )
{
boolean secure = false;
try

View File

@@ -8,6 +8,7 @@ import io.netty.channel.Channel;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.ServerConnection.KeepAliveData;
import net.md_5.bungee.UserConnection;
@@ -31,6 +32,7 @@ import net.md_5.bungee.protocol.packet.ClientCommand;
import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
@@ -75,17 +77,30 @@ public class UpstreamBridge extends PacketHandler
// TODO: This should only done with server_unique
// tab list (which is the only one supported
// currently)
PlayerListItem packet = new PlayerListItem();
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem oldPacket = new PlayerListItem();
oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item item = new PlayerListItem.Item();
item.setUuid( con.getUniqueId() );
packet.setItems( new PlayerListItem.Item[]
oldPacket.setItems( new PlayerListItem.Item[]
{
item
} );
PlayerListItemRemove newPacket = new PlayerListItemRemove();
newPacket.setUuids( new UUID[]
{
con.getUniqueId()
} );
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
{
player.unsafe().sendPacket( packet );
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 )
{
player.unsafe().sendPacket( newPacket );
} else
{
player.unsafe().sendPacket( oldPacket );
}
}
con.getServer().disconnect( "Quitting" );
}

View File

@@ -77,6 +77,7 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_19:
return EntityMap_1_16_2.INSTANCE_1_19;
case ProtocolConstants.MINECRAFT_1_19_1:
case ProtocolConstants.MINECRAFT_1_19_3:
return EntityMap_1_16_2.INSTANCE_1_19_1;
}
throw new RuntimeException( "Version " + version + " has no entity map" );

View File

@@ -4,7 +4,10 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.UUID;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
public class ServerUnique extends TabList
{
@@ -32,6 +35,32 @@ public class ServerUnique extends TabList
player.unsafe().sendPacket( playerListItem );
}
@Override
public void onUpdate(PlayerListItemRemove playerListItem)
{
for ( UUID uuid : uuids )
{
uuids.remove( uuid );
}
player.unsafe().sendPacket( playerListItem );
}
@Override
public void onUpdate(PlayerListItemUpdate playerListItem)
{
for ( PlayerListItem.Item item : playerListItem.getItems() )
{
for ( PlayerListItemUpdate.Action action : playerListItem.getActions() )
{
if ( action == PlayerListItemUpdate.Action.ADD_PLAYER )
{
uuids.add( item.getUuid() );
}
}
}
player.unsafe().sendPacket( playerListItem );
}
@Override
public void onPingChange(int ping)
{
@@ -41,17 +70,25 @@ public class ServerUnique extends TabList
@Override
public void onServerChange()
{
PlayerListItem packet = new PlayerListItem();
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
int i = 0;
for ( UUID uuid : uuids )
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 )
{
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
item.setUuid( uuid );
PlayerListItemRemove packet = new PlayerListItemRemove();
packet.setUuids( uuids.stream().toArray( UUID[]::new ) );
player.unsafe().sendPacket( packet );
} else
{
PlayerListItem packet = new PlayerListItem();
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
int i = 0;
for ( UUID uuid : uuids )
{
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
item.setUuid( uuid );
}
packet.setItems( items );
player.unsafe().sendPacket( packet );
}
packet.setItems( items );
player.unsafe().sendPacket( packet );
uuids.clear();
}
@@ -66,4 +103,5 @@ public class ServerUnique extends TabList
{
}
}

View File

@@ -7,6 +7,8 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.connection.LoginResult;
import net.md_5.bungee.protocol.Property;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
@RequiredArgsConstructor
public abstract class TabList
@@ -16,6 +18,10 @@ public abstract class TabList
public abstract void onUpdate(PlayerListItem playerListItem);
public abstract void onUpdate(PlayerListItemRemove playerListItem);
public abstract void onUpdate(PlayerListItemUpdate playerListItem);
public abstract void onPingChange(int ping);
public abstract void onServerChange();
@@ -28,14 +34,48 @@ public abstract class TabList
{
for ( PlayerListItem.Item item : playerListItem.getItems() )
{
if ( item.getUuid() == null ) // Old style ping
{
continue;
}
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
rewrite( item );
}
return playerListItem;
}
public static PlayerListItemRemove rewrite(PlayerListItemRemove playerListItem)
{
for ( int i = 0; i < playerListItem.getUuids().length; i++ )
{
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( playerListItem.getUuids()[i] );
if ( player != null )
{
item.setUuid( player.getUniqueId() );
playerListItem.getUuids()[i] = player.getUniqueId();
}
}
return playerListItem;
}
public static PlayerListItemUpdate rewrite(PlayerListItemUpdate playerListItem)
{
for ( PlayerListItem.Item item : playerListItem.getItems() )
{
rewrite( item );
}
return playerListItem;
}
private static void rewrite(PlayerListItem.Item item)
{
if ( item.getUuid() == null ) // Old style ping
{
return;
}
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
if ( player != null )
{
item.setUuid( player.getUniqueId() );
if ( item.getProperties() != null )
{
LoginResult loginResult = player.getPendingConnection().getLoginProfile();
if ( loginResult != null && loginResult.getProperties() != null )
{
@@ -49,16 +89,15 @@ public abstract class TabList
{
item.setProperties( new Property[ 0 ] );
}
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE )
{
player.setGamemode( item.getGamemode() );
}
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_LATENCY )
{
player.setPing( item.getPing() );
}
}
if ( item.getGamemode() != null )
{
player.setGamemode( item.getGamemode() );
}
if ( item.getPing() != null )
{
player.setPing( item.getPing() );
}
}
return playerListItem;
}
}