Add some NPE protection to saving player data to disk
This commit is contained in:
parent
e9db1db54d
commit
dce8ea6af3
2 changed files with 4 additions and 2 deletions
|
@ -34,8 +34,9 @@ public class PlayerEventHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void syncEnergyValuesOnLogin(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
|
||||
public void onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().loadPlayerFromDiskIfNeeded(event.player);
|
||||
PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), (EntityPlayerMP) event.player);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,12 +275,13 @@ public class TransmutationKnowledgeRegistry
|
|||
{
|
||||
if (entityPlayer != null && entityPlayer.getUniqueID() != null)
|
||||
{
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()) && playerKnowledgeMap.get(entityPlayer.getUniqueID()).hasBeenModified())
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()) && playerKnowledgeMap.get(entityPlayer.getUniqueID()) != null && playerKnowledgeMap.get(entityPlayer.getUniqueID()).hasBeenModified())
|
||||
{
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", playerKnowledgeMap.get(entityPlayer.getUniqueID()));
|
||||
}
|
||||
else
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", new TransmutationKnowledge());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue