Fixes #1686: Let PlayerRegistry handle nonexistent players
This commit is contained in:
parent
37f51db0d9
commit
33e2eb5a74
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue