mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
Only double switch if the dimension is the same. (#1977)
According to the protocol, a double respawn packet is only needed to be
sent if from the same dimension, so by storing the last known dimension,
we are able to compare and avoid the double packet.
This also maintains the same behaviour for Spigot
ad2f806097
This commit is contained in:
parent
75b7fdac58
commit
812141f400
@ -222,10 +222,15 @@ public class ServerConnector extends PacketHandler
|
||||
}
|
||||
user.getSentBossBars().clear();
|
||||
|
||||
user.sendDimensionSwitch();
|
||||
user.setDimensionChange( true );
|
||||
if ( login.getDimension() == user.getDimension() )
|
||||
{
|
||||
user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
||||
}
|
||||
|
||||
user.setServerEntityId( login.getEntityId() );
|
||||
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
||||
user.setDimension( login.getDimension() );
|
||||
|
||||
// Remove from old servers
|
||||
user.getServer().disconnect( "Quitting" );
|
||||
|
@ -55,6 +55,7 @@ import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.Respawn;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.tab.ServerUnique;
|
||||
import net.md_5.bungee.tab.TabList;
|
||||
@ -80,6 +81,9 @@ public final class UserConnection implements ProxiedPlayer
|
||||
private ServerConnection server;
|
||||
@Getter
|
||||
@Setter
|
||||
private int dimension;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean dimensionChange = true;
|
||||
@Getter
|
||||
private final Collection<ServerInfo> pendingConnects = new HashSet<>();
|
||||
@ -210,17 +214,10 @@ public final class UserConnection implements ProxiedPlayer
|
||||
connect( target, callback, false );
|
||||
}
|
||||
|
||||
void sendDimensionSwitch()
|
||||
{
|
||||
dimensionChange = true;
|
||||
unsafe().sendPacket( PacketConstants.DIM1_SWITCH );
|
||||
unsafe().sendPacket( PacketConstants.DIM2_SWITCH );
|
||||
}
|
||||
|
||||
public void connectNow(ServerInfo target)
|
||||
{
|
||||
sendDimensionSwitch();
|
||||
connect( target );
|
||||
dimensionChange = true;
|
||||
connect(target);
|
||||
}
|
||||
|
||||
public ServerInfo updateAndGetNextServer(ServerInfo currentTarget)
|
||||
|
@ -33,6 +33,7 @@ import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||
import net.md_5.bungee.protocol.packet.Respawn;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||
@ -504,6 +505,12 @@ public class DownstreamBridge extends PacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Respawn respawn)
|
||||
{
|
||||
con.setDimension( respawn.getDimension() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user