Migration to org.json
This commit is contained in:
@@ -140,69 +140,68 @@ public class ItemTemplate {
|
|||||||
try {
|
try {
|
||||||
// Reading a String
|
// Reading a String
|
||||||
|
|
||||||
obj_name = (String) jsonObject.get("obj_name");
|
obj_name = jsonObject.getString("obj_name");
|
||||||
|
|
||||||
// Reading a boolean
|
// Reading a boolean
|
||||||
|
|
||||||
obj_pickable = (boolean) jsonObject.get("obj_pickable");
|
obj_pickable = jsonObject.getBoolean("obj_pickable");
|
||||||
|
|
||||||
// Reading floats from an array (note always check for empty arrays)
|
// Reading floats from an array (note always check for empty arrays)
|
||||||
|
|
||||||
JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale");
|
JSONArray scaleData = jsonObject.getJSONArray("obj_scale");
|
||||||
|
|
||||||
if (scaleData.isEmpty() == false)
|
if (scaleData.isEmpty() == false)
|
||||||
obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(),
|
obj_scale = new Vector3fImmutable(scaleData.getFloat(0), scaleData.getFloat(1),
|
||||||
((Double) scaleData.get(2)).floatValue());
|
scaleData.getFloat(2));
|
||||||
|
|
||||||
JSONArray forwardVector = (JSONArray) jsonObject.get("obj_forward_vector");
|
JSONArray forwardVector = jsonObject.getJSONArray("obj_forward_vector");
|
||||||
|
|
||||||
if (forwardVector.isEmpty() == false)
|
if (forwardVector.isEmpty() == false)
|
||||||
obj_forward_vector = new Vector3fImmutable(((Double) forwardVector.get(0)).floatValue(), ((Double) forwardVector.get(1)).floatValue(),
|
obj_forward_vector = new Vector3fImmutable(forwardVector.getFloat(0), forwardVector.getFloat(1),
|
||||||
((Double) forwardVector.get(2)).floatValue());
|
forwardVector.getFloat(2));
|
||||||
|
|
||||||
JSONArray defaultAlighment = (JSONArray) jsonObject.get("obj_default_alignment");
|
JSONArray defaultAlignment = jsonObject.getJSONArray("obj_default_alignment");
|
||||||
|
|
||||||
if (defaultAlighment.isEmpty() == false)
|
if (defaultAlignment.isEmpty() == false)
|
||||||
obj_default_alignment = new Vector3fImmutable(((Double) defaultAlighment.get(0)).floatValue(), ((Double) defaultAlighment.get(1)).floatValue(),
|
obj_default_alignment = new Vector3fImmutable(defaultAlignment.getFloat(0), defaultAlignment.getFloat(1),
|
||||||
((Double) defaultAlighment.get(2)).floatValue());
|
defaultAlignment.getFloat(2));
|
||||||
|
|
||||||
// Reading an integer value
|
// Reading an integer value
|
||||||
|
|
||||||
obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue();
|
obj_render_object = jsonObject.getInt("obj_render_object");
|
||||||
obj_icon = ((Long) jsonObject.get("obj_icon")).intValue();
|
obj_icon = jsonObject.getInt("obj_icon");
|
||||||
|
|
||||||
JSONObject obj_sparse_json = (JSONObject) jsonObject.get("obj_sparse_data");
|
JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data");
|
||||||
|
|
||||||
for (Object key : obj_sparse_json.keySet()) {
|
for (String key : obj_sparse_json.keySet()) {
|
||||||
String sparseType = (String) key;
|
String sparseValue = obj_sparse_json.getString(key);
|
||||||
Object sparseValue = obj_sparse_json.get(sparseType);
|
obj_sparse_data.put(key, sparseValue);
|
||||||
obj_sparse_data.put(sparseType, sparseValue.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Banes are defined by their sparse data field
|
// Banes are defined by their sparse data field
|
||||||
|
|
||||||
if (obj_sparse_data.get("ACTIONRESPONSE") != null)
|
if (obj_sparse_data.get("ACTIONRESPONSE") != null)
|
||||||
if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122"))
|
if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122"))
|
||||||
item_bane_rank = ((Long) jsonObject.get("item_bane_rank")).intValue();
|
item_bane_rank = jsonObject.getInt("item_bane_rank");
|
||||||
|
|
||||||
// Reading float values
|
// Reading float values
|
||||||
|
|
||||||
combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue();
|
combat_health_current = jsonObject.getFloat("combat_health_current");
|
||||||
combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue();
|
combat_health_full = jsonObject.getFloat("combat_health_full");
|
||||||
|
|
||||||
// Reading a hashmap of floats
|
// Reading a hashmap of floats
|
||||||
|
|
||||||
JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist");
|
JSONObject resist_json = jsonObject.getJSONObject("combat_attack_resist");
|
||||||
|
|
||||||
for (String key : resist_json.keySet()) {
|
for (String key : resist_json.keySet()) {
|
||||||
float resist = ((Double) resist_json.get(key)).floatValue();
|
float resist = resist_json.getFloat(key);
|
||||||
combat_attack_resist.put((String) key, resist);
|
combat_attack_resist.put(key, resist);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsing an enum
|
// Parsing an enum
|
||||||
|
|
||||||
item_type = mbEnums.ItemType.valueOf((String) jsonObject.get("item_type"));
|
item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type"));
|
||||||
item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue();
|
item_eq_slots_value = jsonObject.getInt("item_eq_slots_value");
|
||||||
item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type");
|
item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type");
|
||||||
|
|
||||||
// Parsing an enumset
|
// Parsing an enumset
|
||||||
|
|||||||
Reference in New Issue
Block a user