Encapsulate ping fields

This commit is contained in:
md_5 2013-04-28 11:19:19 +10:00
parent a1f928b210
commit ff32764f9a
3 changed files with 14 additions and 10 deletions

View File

@ -54,14 +54,18 @@ public final class UserConnection implements ProxiedPlayer
// reconnect stuff
public int clientEntityId;
public int serverEntityId;
// ping stuff
public int trackingPingId;
public long pingTime;
@Getter
private String displayName;
/*========================================================================*/
@Getter
@Setter
private int ping = 1000;
private int sentPingId;
@Getter
@Setter
private long sentPingTime;
@Getter
@Setter
private int ping = 100;
/*========================================================================*/
private final Collection<String> groups = new HashSet<>();
private final Collection<String> permissions = new HashSet<>();

View File

@ -78,8 +78,8 @@ public class DownstreamBridge extends PacketHandler
@Override
public void handle(Packet0KeepAlive alive) throws Exception
{
con.trackingPingId = alive.id;
con.pingTime = System.currentTimeMillis();
con.setSentPingId( alive.id );
con.setSentPingTime( System.currentTimeMillis() );
}
@Override

View File

@ -31,12 +31,12 @@ public class UpstreamBridge extends PacketHandler
BungeeCord.getInstance().connections.put( con.getName(), con );
bungee.getTabListHandler().onConnect( con );
con.sendPacket(BungeeCord.getInstance().registerChannels() );
con.sendPacket( BungeeCord.getInstance().registerChannels() );
TexturePackInfo texture = con.getPendingConnection().getListener().getTexturePack();
if ( texture != null )
{
con.sendPacket(new PacketFAPluginMessage( "MC|TPack", ( texture.getUrl() + "\00" + texture.getSize() ).getBytes() ) );
con.sendPacket( new PacketFAPluginMessage( "MC|TPack", ( texture.getUrl() + "\00" + texture.getSize() ).getBytes() ) );
}
}
@ -74,9 +74,9 @@ public class UpstreamBridge extends PacketHandler
@Override
public void handle(Packet0KeepAlive alive) throws Exception
{
if ( alive.id == con.trackingPingId )
if ( alive.id == con.getSentPingId() )
{
int newPing = (int) ( System.currentTimeMillis() - con.pingTime );
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
bungee.getTabListHandler().onPingChange( con, newPing );
con.setPing( newPing );
}