diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index 760e5e169..34f200db9 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -78,14 +78,14 @@ public abstract class SWGObject implements Serializable, Comparable { private final HashMap slots; // HashMap used for null value support private final Map containedObjects; private final Map attributes; - private final Map templateAttributes; + private final Map dataAttributes; private final BaselineType objectType; private ContainerPermissions containerPermissions; private transient Set objectsAware; private transient BuildoutArea buildoutArea; + private transient Player owner; private List > arrangement; - private Player owner = null; private SWGObject parent = null; private StringId stringId = new StringId("", ""); private StringId detailStringId = new StringId("", ""); @@ -112,7 +112,7 @@ public abstract class SWGObject implements Serializable, Comparable { this.slots = new HashMap<>(); this.containedObjects = Collections.synchronizedMap(new HashMap()); this.attributes = new LinkedHashMap<>(); - this.templateAttributes = new Hashtable<>(); + this.dataAttributes = new Hashtable<>(); this.containerPermissions = new DefaultPermissions(); this.objectType = objectType; } @@ -122,6 +122,7 @@ public abstract class SWGObject implements Serializable, Comparable { ois.defaultReadObject(); objectsAware = new HashSet(); buildoutArea = null; + owner = null; } /** @@ -177,14 +178,17 @@ public abstract class SWGObject implements Serializable, Comparable { * @return {@link ContainerResult} */ public ContainerResult moveToContainer(SWGObject requester, SWGObject container) { - if (!container.hasPermission(requester, ContainerPermissions.Permission.MOVE)) + if (!container.hasPermission(requester, ContainerPermissions.Permission.MOVE)) { + Log.w("SWGObject", "No permission 'MOVE' for requestor %s with object %s", requester, this); return ContainerResult.NO_PERMISSION; + } // Check if object can fit into container or slots int arrangementId = container.getArrangementId(this); if (arrangementId == -1) { // Item is going to go into the container, so check to see if it'll fit if (container.getMaxContainerSize() <= container.getContainedObjects().size()) { + Log.w("SWGObject", "Unable to add object to container! Container Full"); return ContainerResult.CONTAINER_FULL; } } @@ -505,12 +509,12 @@ public abstract class SWGObject implements Serializable, Comparable { return areaId; } - public Object getTemplateAttribute(ObjectDataAttribute key) { - return templateAttributes.get(key); + public Object getDataAttribute(ObjectDataAttribute key) { + return dataAttributes.get(key); } - public void setTemplateAttribute(ObjectDataAttribute key, Object value) { - templateAttributes.put(key, value); + public void setDataAttribute(ObjectDataAttribute key, Object value) { + dataAttributes.put(key, value); } public List> getArrangement() { @@ -542,14 +546,12 @@ public abstract class SWGObject implements Serializable, Comparable { } public int getMaxContainerSize() { - Object volume = templateAttributes.get(ObjectDataAttribute.CONTAINER_VOLUME_LIMIT); - if (volume == null) - return 0; - try { - return Integer.parseInt(volume.toString()); - } catch (NumberFormatException e) { + Object volume = dataAttributes.get(ObjectDataAttribute.CONTAINER_VOLUME_LIMIT); + if (volume == null) { + Log.w("SWGObject", "Volume is null!"); return 0; } + return (Integer) volume; } public void setBuildout(boolean buildout) { diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index d76d34974..006088983 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -84,7 +84,7 @@ public class BuildingObject extends TangibleObject { if (!added || !(object instanceof CellObject)) return added; - String portalFile = (String) getTemplateAttribute(ObjectDataAttribute.PORTAL_LAYOUT_FILENAME); + String portalFile = (String) getDataAttribute(ObjectDataAttribute.PORTAL_LAYOUT_FILENAME); if (portalFile == null || portalFile.isEmpty()) return true; @@ -98,6 +98,6 @@ public class BuildingObject extends TangibleObject { private void populateCellData(CellObject cellObject, PortalLayoutData.Cell cellData) { cellObject.setCellName(cellData.getName()); -// System.out.println(cellObject + " cell name " + cellObject.getCelName()); +// System.out.println(cellObject + " cell name " + cellObject.getCellName()); } } diff --git a/src/services/objects/ObjectCreator.java b/src/services/objects/ObjectCreator.java index c1d6c708e..9b63b9100 100644 --- a/src/services/objects/ObjectCreator.java +++ b/src/services/objects/ObjectCreator.java @@ -119,31 +119,26 @@ public final class ObjectCreator { if (attributes == null) return; - ObjectDataAttribute key; - Object value; for (Entry e : attributes.getAttributes().entrySet()) { - key = e.getKey(); - value = e.getValue(); - obj.setTemplateAttribute(key, value); - - setObjectAttribute(key, value.toString(), obj); + setObjectAttribute(e.getKey(), e.getValue(), obj); } } - private static void setObjectAttribute(ObjectDataAttribute key, String value, SWGObject object) { + private static void setObjectAttribute(ObjectDataAttribute key, Object value, SWGObject object) { + object.setDataAttribute(key, value); switch (key) { - case OBJECT_NAME: object.setStringId(value); break; - case DETAILED_DESCRIPTION: object.setDetailStringId(value); break; - case CONTAINER_VOLUME_LIMIT: object.setVolume(Integer.parseInt(value)); break; - case CONTAINER_TYPE: object.setContainerType(Integer.parseInt(value)); break; + case OBJECT_NAME: object.setStringId(value.toString()); break; + case DETAILED_DESCRIPTION: object.setDetailStringId(value.toString()); break; + case CONTAINER_VOLUME_LIMIT: object.setVolume((Integer) value); break; + case CONTAINER_TYPE: object.setContainerType((Integer) value); break; default: break; } } private static void createObjectSlots(SWGObject object) { - if (object.getTemplateAttribute(ObjectDataAttribute.SLOT_DESCRIPTOR_FILENAME) != null) { + if (object.getDataAttribute(ObjectDataAttribute.SLOT_DESCRIPTOR_FILENAME) != null) { // These are the slots that the object *HAS* - SlotDescriptorData descriptor = (SlotDescriptorData) ClientFactory.getInfoFromFile((String) object.getTemplateAttribute(ObjectDataAttribute.SLOT_DESCRIPTOR_FILENAME), true); + SlotDescriptorData descriptor = (SlotDescriptorData) ClientFactory.getInfoFromFile((String) object.getDataAttribute(ObjectDataAttribute.SLOT_DESCRIPTOR_FILENAME), true); if (descriptor == null) return; @@ -152,9 +147,9 @@ public final class ObjectCreator { } } - if (object.getTemplateAttribute(ObjectDataAttribute.ARRANGEMENT_DESCRIPTOR_FILENAME) != null) { + if (object.getDataAttribute(ObjectDataAttribute.ARRANGEMENT_DESCRIPTOR_FILENAME) != null) { // This is what slots the created object is able to go into/use - SlotArrangementData arrangementData = (SlotArrangementData) ClientFactory.getInfoFromFile((String) object.getTemplateAttribute(ObjectDataAttribute.ARRANGEMENT_DESCRIPTOR_FILENAME), true); + SlotArrangementData arrangementData = (SlotArrangementData) ClientFactory.getInfoFromFile((String) object.getDataAttribute(ObjectDataAttribute.ARRANGEMENT_DESCRIPTOR_FILENAME), true); if (arrangementData == null) return;