Fixes #1686: Let PlayerRegistry handle nonexistent players

This commit is contained in:
yueh 2015-07-06 16:44:36 +02:00 committed by thatsIch
parent 37f51db0d9
commit 33e2eb5a74
2 changed files with 9 additions and 8 deletions

View File

@ -34,13 +34,18 @@ public class PlayerRegistry implements IPlayerRegistry
@Override
public int getID( GameProfile username )
{
if( username == null || !username.isComplete() )
{
return -1;
}
return WorldData.instance().playerData().getPlayerID( username );
}
@Override
public int getID( EntityPlayer player )
{
return WorldData.instance().playerData().getPlayerID( player.getGameProfile() );
return this.getID( player.getGameProfile() );
}
@Nullable

View File

@ -93,17 +93,13 @@ final class PlayerData implements IWorldPlayerData, IOnWorldStartable, IOnWorldS
public int getPlayerID( @Nonnull final GameProfile profile )
{
Preconditions.checkNotNull( profile );
Preconditions.checkNotNull( this.config.getCategory( "players" ) );
Preconditions.checkState( profile.isComplete() );
final ConfigCategory players = this.config.getCategory( "players" );
if( players == null || !profile.isComplete() )
{
return -1;
}
final String uuid = profile.getId().toString();
final Property maybePlayerID = players.get( uuid );
if( maybePlayerID != null && maybePlayerID.isIntValue() )
{
return maybePlayerID.getInt();