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,6 +70,8 @@ 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();
if ( loginResult != null )
{
String[][] props = new String[ loginResult.getProperties().length ][]; String[][] props = new String[ loginResult.getProperties().length ][];
for ( int j = 0; j < props.length; j++ ) for ( int j = 0; j < props.length; j++ )
{ {
@ -81,6 +83,10 @@ public class Global extends TabList
}; };
} }
item.setProperties( props ); item.setProperties( props );
} else
{
item.setProperties( new String[0][0] );
}
item.setGamemode( ( (UserConnection) p ).getGamemode() ); item.setGamemode( ( (UserConnection) p ).getGamemode() );
item.setPing( p.getPing() ); item.setPing( p.getPing() );
} }

View File

@ -36,6 +36,8 @@ public abstract class TabList
{ {
item.setUuid( player.getUniqueId() ); item.setUuid( player.getUniqueId() );
LoginResult loginResult = player.getPendingConnection().getLoginProfile(); LoginResult loginResult = player.getPendingConnection().getLoginProfile();
if ( loginResult != null )
{
String[][] props = new String[ loginResult.getProperties().length ][]; String[][] props = new String[ loginResult.getProperties().length ][];
for ( int i = 0; i < props.length; i++ ) for ( int i = 0; i < props.length; i++ )
{ {
@ -47,6 +49,10 @@ public abstract class TabList
}; };
} }
item.setProperties( props ); item.setProperties( props );
} else
{
item.setProperties( new String[ 0 ][ 0 ] );
}
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() );