From b9fe7152444e351e9b8dbe91dfa3a3cea3f7ec9d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 27 Sep 2015 15:34:22 +0200 Subject: [PATCH] Null checks are important! --- .../java/ellpeck/actuallyadditions/event/CraftEvent.java | 2 +- .../util/playerdata/PersistantServerData.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java b/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java index 4aa1a1f1c..e2e53c3f7 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java @@ -32,7 +32,7 @@ public class CraftEvent{ if(ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()){ if(!event.player.worldObj.isRemote && event.crafting.getItem() != InitItems.itemLexicon && (event.crafting.getItem() instanceof INameableItem || Block.getBlockFromItem(event.crafting.getItem()) instanceof INameableItem)){ PersistantServerData data = PersistantServerData.get(event.player); - if(!data.bookGottenAlready){ + if(data != null && !data.bookGottenAlready){ data.bookGottenAlready = true; EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemLexicon)); diff --git a/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java index 420dd0d39..01d782b14 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java +++ b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java @@ -47,6 +47,10 @@ public class PersistantServerData implements IExtendedEntityProperties{ } public static PersistantServerData get(EntityPlayer player){ - return (PersistantServerData)player.getExtendedProperties(ModUtil.MOD_ID); + IExtendedEntityProperties properties = player.getExtendedProperties(ModUtil.MOD_ID); + if(properties != null && properties instanceof PersistantServerData){ + return (PersistantServerData)properties; + } + return null; } }