Handle offline mode in the tab list

This commit is contained in:
Thinkofdeath 2014-08-31 09:25:09 +01:00
parent c822c48fef
commit 1f132876e6
2 changed files with 28 additions and 16 deletions

View File

@ -70,17 +70,23 @@ public class Global extends TabList
item.setUsername( p.getName() ); item.setUsername( p.getName() );
item.setDisplayName( ComponentSerializer.toString( TextComponent.fromLegacyText( p.getDisplayName() ) ) ); item.setDisplayName( ComponentSerializer.toString( TextComponent.fromLegacyText( p.getDisplayName() ) ) );
LoginResult loginResult = ( (UserConnection) p ).getPendingConnection().getLoginProfile(); LoginResult loginResult = ( (UserConnection) p ).getPendingConnection().getLoginProfile();
String[][] props = new String[ loginResult.getProperties().length ][]; if ( loginResult != null )
for ( int j = 0; j < props.length; j++ )
{ {
props[ j] = new String[] String[][] props = new String[ loginResult.getProperties().length ][];
for ( int j = 0; j < props.length; j++ )
{ {
loginResult.getProperties()[j].getName(), props[ j ] = new String[]
loginResult.getProperties()[j].getValue(), {
loginResult.getProperties()[j].getSignature() loginResult.getProperties()[ j ].getName(),
}; loginResult.getProperties()[ j ].getValue(),
loginResult.getProperties()[ j ].getSignature()
};
}
item.setProperties( props );
} else
{
item.setProperties( new String[0][0] );
} }
item.setProperties( props );
item.setGamemode( ( (UserConnection) p ).getGamemode() ); item.setGamemode( ( (UserConnection) p ).getGamemode() );
item.setPing( p.getPing() ); item.setPing( p.getPing() );
} }

View File

@ -36,17 +36,23 @@ public abstract class TabList
{ {
item.setUuid( player.getUniqueId() ); item.setUuid( player.getUniqueId() );
LoginResult loginResult = player.getPendingConnection().getLoginProfile(); LoginResult loginResult = player.getPendingConnection().getLoginProfile();
String[][] props = new String[ loginResult.getProperties().length ][]; if ( loginResult != null )
for ( int i = 0; i < props.length; i++ )
{ {
props[ i] = new String[] String[][] props = new String[ loginResult.getProperties().length ][];
for ( int i = 0; i < props.length; i++ )
{ {
loginResult.getProperties()[i].getName(), props[ i ] = new String[]
loginResult.getProperties()[i].getValue(), {
loginResult.getProperties()[i].getSignature() loginResult.getProperties()[ i ].getName(),
}; loginResult.getProperties()[ i ].getValue(),
loginResult.getProperties()[ i ].getSignature()
};
}
item.setProperties( props );
} else
{
item.setProperties( new String[ 0 ][ 0 ] );
} }
item.setProperties( props );
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE ) if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE )
{ {
player.setGamemode( item.getGamemode() ); player.setGamemode( item.getGamemode() );