diff --git a/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java b/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java index 52a388661a62e28ccde8b52354eb8354861949f9..db2632426dd8104f7f3c4a033a6e41ad4112dd7b 100644 --- a/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java +++ b/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java @@ -76,12 +76,7 @@ public class GraphDbAetherMudStorage implements AetherMudStorage { @Override public ItemData saveItem(Item item) { ItemData itemData = framedGraph.addFramedVertex(ItemData.class); - try { - PropertyUtils.copyProperties(itemData, item); - } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new IllegalStateException("Could not copy beans", e); - } - itemData.setItemTriggers(item.getItemTriggers()); + ItemData.copyItem(itemData, item); return itemData; } diff --git a/src/main/java/com/syncleus/aethermud/storage/graphdb/model/ItemData.java b/src/main/java/com/syncleus/aethermud/storage/graphdb/model/ItemData.java index 6db2519caf0584fb27d2d05f4f124cb701560ecb..570bf14a88f20fba76682cdc068f1626654d266e 100644 --- a/src/main/java/com/syncleus/aethermud/storage/graphdb/model/ItemData.java +++ b/src/main/java/com/syncleus/aethermud/storage/graphdb/model/ItemData.java @@ -257,11 +257,15 @@ public abstract class ItemData extends AbstractInterceptingVertexFrame { public static void copyItem(ItemData dest, Item src) { try { PropertyUtils.copyProperties(dest, src); - StatData.copyStats(dest.createItemApplyStatData(), src.getItemApplyStats()); - LootData.copyLoot(dest.createLoottData(), src.getLoot()); - EquipmentData.copyEquipment(dest.createEquipmentData(), src.getEquipment()); - for(Effect effect : src.getEffects()) - EffectData.copyEffect(dest.createEffectData(), effect); + if( src.getItemApplyStats() != null ) + StatData.copyStats(dest.createItemApplyStatData(), src.getItemApplyStats()); + if(src.getLoot() != null ) + LootData.copyLoot(dest.createLoottData(), src.getLoot()); + if( src.getEquipment() != null ) + EquipmentData.copyEquipment(dest.createEquipmentData(), src.getEquipment()); + if( src.getEffects() != null ) + for(Effect effect : src.getEffects()) + EffectData.copyEffect(dest.createEffectData(), effect); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Could not copy properties", e); } @@ -284,10 +288,12 @@ public abstract class ItemData extends AbstractInterceptingVertexFrame { if( applyStats != null ) retVal.setItemApplyStats(StatData.copyStats(applyStats)); - Set<Effect> effects = new HashSet<>(); - for(EffectData effect : src.getEffectDatas()) - effects.add(EffectData.copyEffect(effect)); - retVal.setEffects(Collections.unmodifiableSet(effects)); + if( src.getEffectDatas() != null ) { + Set<Effect> effects = new HashSet<>(); + for (EffectData effect : src.getEffectDatas()) + effects.add(EffectData.copyEffect(effect)); + retVal.setEffects(Collections.unmodifiableSet(effects)); + } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Could not copy properties", e);