|
|
|
@ -1524,18 +1524,24 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setUserData(String key, Object data) { |
|
|
|
|
if (data == null) { |
|
|
|
|
if (userData != null) { |
|
|
|
|
userData.remove(key); |
|
|
|
|
if(userData.isEmpty()) { |
|
|
|
|
userData = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (userData == null) { |
|
|
|
|
userData = new HashMap<String, Savable>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(data == null){ |
|
|
|
|
userData.remove(key); |
|
|
|
|
}else if (data instanceof Savable) { |
|
|
|
|
if (data instanceof Savable) { |
|
|
|
|
userData.put(key, (Savable) data); |
|
|
|
|
} else { |
|
|
|
|
userData.put(key, new UserData(UserData.getObjectType(data), data)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public <T> T getUserData(String key) { |
|
|
|
|