diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 0dd6c4cc..056daa81 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -678,7 +678,7 @@ Include jenkins dockerfile in repo Better model for gameobjects Server synchronization of sprint tree Fix potential bad path for item state lookup -Fix ItemUtils NPE bug +Fix multiple ItemUtils NPE bugs Fix AttachUtils NPE bug diff --git a/src/main/java/electrosphere/entity/types/item/ItemUtils.java b/src/main/java/electrosphere/entity/types/item/ItemUtils.java index 3bdea071..bc40f068 100644 --- a/src/main/java/electrosphere/entity/types/item/ItemUtils.java +++ b/src/main/java/electrosphere/entity/types/item/ItemUtils.java @@ -344,7 +344,15 @@ public class ItemUtils { return item.containsKey(EntityDataStrings.ITEM_IS_ARMOR); } + /** + * Checks if the entity has an equip list + * @param item The item entity + * @return true if it has an equip list, false otherwise + */ public static boolean hasEquipList(Entity item){ + if(item == null){ + return false; + } return item.containsKey(EntityDataStrings.ITEM_EQUIP_WHITELIST); } diff --git a/src/test/java/electrosphere/entity/types/item/ItemUtilsUnitTests.java b/src/test/java/electrosphere/entity/types/item/ItemUtilsUnitTests.java index ec451529..f57b55f2 100644 --- a/src/test/java/electrosphere/entity/types/item/ItemUtilsUnitTests.java +++ b/src/test/java/electrosphere/entity/types/item/ItemUtilsUnitTests.java @@ -17,4 +17,11 @@ public class ItemUtilsUnitTests { Assertions.assertEquals(false, result); } + @UnitTest + @FastTest + public void hasEquipList_NullEntity_False(){ + boolean result = ItemUtils.hasEquipList(null); + Assertions.assertEquals(false, result); + } + }