Browse Source

Migration to org.json

combat-2
MagicBot 7 months ago
parent
commit
7604b7b07f
  1. 268
      src/engine/objects/ItemTemplate.java

268
src/engine/objects/ItemTemplate.java

@ -202,30 +202,30 @@ public class ItemTemplate {
item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type")); item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type"));
item_eq_slots_value = jsonObject.getInt("item_eq_slots_value"); 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 = jsonObject.getBoolean("item_eq_slots_type");
// Parsing an enumset // Parsing an enumset
JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or"); JSONArray eq_slots_or = jsonObject.getJSONArray("item_eq_slots_or");
if (eq_slots_or.isEmpty() == false) if (eq_slots_or.isEmpty() == false)
for (Object o : eq_slots_or) for (Object o : eq_slots_or)
item_eq_slots_or.add(mbEnums.EquipSlotType.valueOf((String) o)); item_eq_slots_or.add(mbEnums.EquipSlotType.valueOf((String) o));
JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and"); JSONArray eq_slots_and = jsonObject.getJSONArray("item_eq_slots_and");
if (eq_slots_and.isEmpty() == false) if (eq_slots_and.isEmpty() == false)
for (Object o : eq_slots_and) for (Object o : eq_slots_and)
item_eq_slots_and.add(mbEnums.EquipSlotType.valueOf((String) o)); item_eq_slots_and.add(mbEnums.EquipSlotType.valueOf((String) o));
item_takeable = (boolean) jsonObject.get("item_takeable"); item_takeable = jsonObject.getBoolean("item_takeable");
item_value = ((Long) jsonObject.get("item_value")).intValue(); item_value = (jsonObject.getInt("item_value"));
item_wt = ((Long) jsonObject.get("item_wt")).intValue(); item_wt = jsonObject.getInt("item_wt");
item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue(); item_passive_defense_mod = jsonObject.getFloat("item_passive_defense_mod");
item_base_name = (String) jsonObject.get("item_base_name"); item_base_name = jsonObject.getString("item_base_name");
item_dsc = (String) jsonObject.get("item_dsc"); item_dsc = jsonObject.getString("item_dsc");
item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); item_render_object_female = jsonObject.getInt("item_render_object_female");
item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); item_health_full = jsonObject.getFloat("item_health_full");
Object skill_used = jsonObject.get("item_skill_used"); Object skill_used = jsonObject.get("item_skill_used");
@ -239,74 +239,74 @@ public class ItemTemplate {
if (mastery_used instanceof String) if (mastery_used instanceof String)
item_skill_mastery_used = (String) mastery_used; item_skill_mastery_used = (String) mastery_used;
item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); item_parry_anim_id = jsonObject.getInt("item_parry_anim_id");
// Reading offering data // Reading offering data
JSONArray offering_data = (JSONArray) jsonObject.get("item_offering_info"); JSONArray offering_data = jsonObject.getJSONArray("item_offering_info");
for (Object entry : offering_data) { for (Object entry : offering_data) {
JSONObject offering_entry = (JSONObject) entry; JSONObject offering_entry = (JSONObject) entry;
String offering_type = ((String) offering_entry.get("offering_type")).replaceAll("-", ""); String offering_type = offering_entry.getString("offering_type").replaceAll("-", "");
int offering_value = ((Long) offering_entry.get("offering_value")).intValue(); int offering_value = offering_entry.getInt("offering_value");
item_offering_info.put(mbEnums.ShrineType.valueOf(offering_type), offering_value); item_offering_info.put(mbEnums.ShrineType.valueOf(offering_type), offering_value);
} }
// Fields only present for ARMOR // Fields only present for ARMOR
if (item_type.equals(mbEnums.ItemType.ARMOR)) { if (item_type.equals(mbEnums.ItemType.ARMOR)) {
item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue(); item_bulk_factor = jsonObject.getFloat("item_bulk_factor");
item_defense_rating = ((Long) jsonObject.get("item_defense_rating")).intValue(); item_defense_rating = jsonObject.getInt("item_defense_rating");
} }
// Fields only present for WEAPON // Fields only present for WEAPON
if (item_type.equals(mbEnums.ItemType.WEAPON)) { if (item_type.equals(mbEnums.ItemType.WEAPON)) {
JSONObject item_weapon = (JSONObject) jsonObject.get("item_weapon"); JSONObject item_weapon = jsonObject.getJSONObject("item_weapon");
item_weapon_wepspeed = ((Double) item_weapon.get("weapon_wepspeed")).floatValue(); item_weapon_wepspeed = item_weapon.getFloat("weapon_wepspeed");
item_weapon_max_range = ((Double) item_weapon.get("weapon_max_range")).floatValue(); item_weapon_max_range = item_weapon.getFloat("weapon_max_range");
item_weapon_projectile_id = ((Long) item_weapon.get("weapon_projectile_id")).intValue(); item_weapon_projectile_id = item_weapon.getInt("weapon_projectile_id");
item_weapon_projectile_speed = ((Double) item_weapon.get("weapon_projectile_speed")).floatValue(); item_weapon_projectile_speed = item_weapon.getFloat("weapon_projectile_speed");
item_weapon_combat_idle_anim = ((Long) item_weapon.get("weapon_combat_idle_anim")).intValue(); item_weapon_combat_idle_anim = item_weapon.getInt("weapon_combat_idle_anim");
JSONArray weapon_damage = (JSONArray) item_weapon.get("weapon_damage"); JSONArray weapon_damage = item_weapon.getJSONArray("weapon_damage");
if (weapon_damage.isEmpty() == false) if (weapon_damage.isEmpty() == false)
for (Object o : weapon_damage) { for (Object o : weapon_damage) {
JSONObject damage_entry = (JSONObject) o; JSONObject damage_entry = (JSONObject) o;
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(((String) damage_entry.get("damage_type"))); mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(damage_entry.getString("damage_type"));
int min = ((Long) damage_entry.get("damage_min")).intValue(); int min = damage_entry.getInt("damage_min");
int max = ((Long) damage_entry.get("damage_max")).intValue(); int max = damage_entry.getInt("damage_max");
int[] minMax = {min, max}; int[] minMax = {min, max};
item_weapon_damage.put(damageType, minMax); item_weapon_damage.put(damageType, minMax);
} }
JSONArray attack_anim_right = (JSONArray) item_weapon.get("weapon_attack_anim_right"); JSONArray attack_anim_right = item_weapon.getJSONArray("weapon_attack_anim_right");
if (attack_anim_right.isEmpty() == false) if (attack_anim_right.isEmpty() == false)
for (Object o : attack_anim_right) { for (Object o : attack_anim_right) {
JSONArray animationEntry = (JSONArray) o; JSONArray animationEntry = (JSONArray) o;
int animation = ((Long) animationEntry.get(0)).intValue(); int animation = animationEntry.getInt(0);
int duration = ((Long) animationEntry.get(1)).intValue(); int duration = animationEntry.getInt(1);
weapon_attack_anim_right.add(new int[]{animation, duration}); weapon_attack_anim_right.add(new int[]{animation, duration});
} }
JSONArray attack_anim_left = (JSONArray) item_weapon.get("weapon_attack_anim_left"); JSONArray attack_anim_left = item_weapon.getJSONArray("weapon_attack_anim_left");
if (attack_anim_left.isEmpty() == false) if (attack_anim_left.isEmpty() == false)
for (Object o : attack_anim_left) { for (Object o : attack_anim_left) {
JSONArray animationEntry = (JSONArray) o; JSONArray animationEntry = (JSONArray) o;
int animation = ((Long) animationEntry.get(0)).intValue(); int animation = animationEntry.getInt(0);
int duration = ((Long) animationEntry.get(1)).intValue(); int duration = animationEntry.getInt(1);
weapon_attack_anim_left.add(new int[]{animation, duration}); weapon_attack_anim_left.add(new int[]{animation, duration});
} }
item_primary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_primary_attr")); item_primary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_primary_attr"));
item_secondary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_secondary_attr")); item_secondary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_secondary_attr"));
} }
JSONArray itemflags = (JSONArray) jsonObject.get("item_flags"); JSONArray itemflags = jsonObject.getJSONArray("item_flags");
if (itemflags.isEmpty() == false) if (itemflags.isEmpty() == false)
for (Object o : itemflags) { for (Object o : itemflags) {
@ -315,29 +315,29 @@ public class ItemTemplate {
item_flags.add(mbEnums.ItemFlags.valueOf((String) o)); item_flags.add(mbEnums.ItemFlags.valueOf((String) o));
} }
JSONArray itemUseflags = (JSONArray) jsonObject.get("item_use_flags"); JSONArray itemUseflags = jsonObject.getJSONArray("item_use_flags");
if (itemUseflags.isEmpty() == false) if (itemUseflags.isEmpty() == false)
for (Object o : itemUseflags) for (Object o : itemUseflags)
item_use_flags.add(mbEnums.ItemUseFlags.valueOf((String) o)); item_use_flags.add(mbEnums.ItemUseFlags.valueOf((String) o));
item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue(); item_initial_charges = jsonObject.getInt("item_initial_charges");
JSONArray skill_required = (JSONArray) jsonObject.get("item_skill_req"); JSONArray skill_required = jsonObject.getJSONArray("item_skill_req");
if (skill_required.isEmpty() == false) if (skill_required.isEmpty() == false)
for (Object o : skill_required) { for (Object o : skill_required) {
JSONObject skill_req = (JSONObject) o; JSONObject skill_req = (JSONObject) o;
String skill_type = (String) skill_req.get("skill_type"); String skill_type = skill_req.getString("skill_type");
int skill_level = ((Long) skill_req.get("skill_level")).intValue(); int skill_level = skill_req.getInt("skill_level");
if (skill_type.equals("Cloth") == false) if (skill_type.equals("Cloth") == false)
item_skill_required.put(skill_type, skill_level); item_skill_required.put(skill_type, skill_level);
} }
JSONObject race_required = (JSONObject) jsonObject.get("item_race_req"); JSONObject race_required = jsonObject.getJSONObject("item_race_req");
boolean restrict = ((Boolean) race_required.get("restrict")); boolean restrict = race_required.getBoolean("restrict");
JSONArray races = (JSONArray) race_required.get("races"); JSONArray races = race_required.getJSONArray("races");
if (races.isEmpty() == false) if (races.isEmpty() == false)
for (Object o : races) { for (Object o : races) {
@ -352,9 +352,9 @@ public class ItemTemplate {
item_race_req.add(mbEnums.MonsterType.valueOf(race)); item_race_req.add(mbEnums.MonsterType.valueOf(race));
} }
JSONObject class_required = (JSONObject) jsonObject.get("item_class_req"); JSONObject class_required = jsonObject.getJSONObject("item_class_req");
restrict = ((Boolean) class_required.get("restrict")); restrict = class_required.getBoolean("restrict");
JSONArray classes = (JSONArray) class_required.get("classes"); JSONArray classes = class_required.getJSONArray("classes");
if (classes.isEmpty() == false) if (classes.isEmpty() == false)
for (Object o : classes) { for (Object o : classes) {
@ -368,9 +368,9 @@ public class ItemTemplate {
item_class_req.add(mbEnums.ClassType.valueOf(classEntry)); item_class_req.add(mbEnums.ClassType.valueOf(classEntry));
} }
JSONObject disc_required = (JSONObject) jsonObject.get("item_disc_req"); JSONObject disc_required = jsonObject.getJSONObject("item_disc_req");
restrict = ((Boolean) disc_required.get("restrict")); restrict = disc_required.getBoolean("restrict");
JSONArray discs = (JSONArray) disc_required.get("discs"); JSONArray discs = disc_required.getJSONArray("discs");
if (discs.isEmpty() == false) if (discs.isEmpty() == false)
for (Object o : discs) { for (Object o : discs) {
@ -384,62 +384,61 @@ public class ItemTemplate {
item_disc_req.add(mbEnums.DisciplineType.valueOf(disc)); item_disc_req.add(mbEnums.DisciplineType.valueOf(disc));
} }
item_level_req = ((Long) jsonObject.get("item_level_req")).intValue(); item_level_req = jsonObject.getInt("item_level_req");
item_sex_req = mbEnums.SexType.valueOf((String) jsonObject.get("item_sex_req")); item_sex_req = mbEnums.SexType.valueOf(jsonObject.getString("item_sex_req"));
JSONArray userPowerActions = (JSONArray) jsonObject.get("item_user_power_action"); JSONArray userPowerActions = jsonObject.getJSONArray("item_user_power_action");
if (userPowerActions.isEmpty() == false) if (userPowerActions.isEmpty() == false)
for (Object o : userPowerActions) { for (Object o : userPowerActions) {
JSONObject powerActionEntry = (JSONObject) o; JSONObject powerActionEntry = (JSONObject) o;
String power = (String) powerActionEntry.get("power"); String power = powerActionEntry.getString("power");
JSONArray args = (JSONArray) powerActionEntry.get("arguments"); JSONArray args = powerActionEntry.getJSONArray("arguments");
int[] arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()}; int[] arguments = {args.getInt(0), args.getInt(1)};
item_user_power_action.put(power, arguments); item_user_power_action.put(power, arguments);
} }
JSONArray powerGrantsArray = (JSONArray) jsonObject.get("item_power_grant"); JSONArray powerGrantsArray = jsonObject.getJSONArray("item_power_grant");
if (powerGrantsArray.isEmpty() == false) { if (powerGrantsArray.isEmpty() == false) {
for (Object grantArrayEntry : powerGrantsArray) { for (Object grantArrayEntry : powerGrantsArray) {
JSONObject powerGrantEntry = (JSONObject) grantArrayEntry; JSONObject powerGrantEntry = (JSONObject) grantArrayEntry;
String power_type = (String) powerGrantEntry.get("power_type"); String power_type = powerGrantEntry.getString("power_type");
int power_value = ((Long) powerGrantEntry.get("power_value")).intValue(); int power_value = powerGrantEntry.getInt("power_value");
item_power_grant.put(power_type, power_value); item_power_grant.put(power_type, power_value);
JSONArray skill_granted_array = (JSONArray) powerGrantEntry.get("power_granted_skills"); JSONArray skill_granted_array = powerGrantEntry.getJSONArray("power_granted_skills");
for (Object skillGrantEntry : skill_granted_array) { for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry; JSONArray skill_entry = (JSONArray) skillGrantEntry;
String skill_type = (String) skill_entry.get(0); String skill_type = skill_entry.getString(0);
int skill_level = ((Long) skill_entry.get(1)).intValue(); int skill_level = skill_entry.getInt(1);
power_granted_skills.put(skill_type, skill_level); power_granted_skills.put(skill_type, skill_level);
} }
} }
} }
JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action"); JSONArray item_power_actions = jsonObject.getJSONArray("item_power_action");
if (item_power_actions.isEmpty() == false) if (item_power_actions.isEmpty() == false)
for (Object o : item_power_actions) { for (Object o : item_power_actions) {
JSONObject powerActionEntry = (JSONObject) o; JSONObject powerActionEntry = (JSONObject) o;
String power = (String) powerActionEntry.get("power_type"); String power = powerActionEntry.getString("power_type");
JSONArray power_actions = (JSONArray) powerActionEntry.get("power_actions"); JSONArray power_actions = powerActionEntry.getJSONArray("power_actions");
JSONObject argument_entry = (JSONObject) power_actions.get(0); JSONObject argument_entry = power_actions.getJSONObject(0);
JSONArray power_args = (JSONArray) argument_entry.get("power_arguments"); JSONArray power_args = argument_entry.getJSONArray("power_arguments");
int[] power_arguments = {((Long) power_args.get(0)).intValue(), ((Long) power_args.get(1)).intValue()}; int[] power_arguments = {power_args.getInt(0), power_args.getInt(1)};
item_power_action.put(power, power_arguments); item_power_action.put(power, power_arguments);
} }
JSONArray resource_costs = (JSONArray) jsonObject.get("item_resource_costs"); JSONArray resource_costs = jsonObject.getJSONArray("item_resource_costs");
if (resource_costs.isEmpty() == false) if (resource_costs.isEmpty() == false)
for (Object o : resource_costs) { for (Object o : resource_costs) {
JSONObject resource_entry = (JSONObject) o; JSONObject resource_entry = (JSONObject) o;
mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(((String) resource_entry.get("resource_type")).toUpperCase()); mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(resource_entry.getString("resource_type").toUpperCase());
int resource_value = ((Long) resource_entry.get("resource_value")).intValue(); int resource_value = resource_entry.getInt("resource_value");
item_resource_cost.put(resource_type, resource_value); item_resource_cost.put(resource_type, resource_value);
} }
@ -447,69 +446,69 @@ public class ItemTemplate {
if (item_type.equals(mbEnums.ItemType.DEED)) { if (item_type.equals(mbEnums.ItemType.DEED)) {
deed_type = ((Long) jsonObject.get("deed_type")).intValue(); deed_type = jsonObject.getInt("deed_type");
deed_furniture_id = ((Long) jsonObject.get("deed_furniture_id")).intValue(); deed_furniture_id = jsonObject.getInt("deed_furniture_id");
deed_target_id = ((Long) jsonObject.get("deed_target_id")).intValue(); deed_target_id = jsonObject.getInt("deed_target_id");
deed_employment = ((Long) jsonObject.get("deed_employment")).intValue(); deed_employment = jsonObject.getInt("deed_employment");
deed_start_rank = ((Long) jsonObject.get("deed_start_rank")).intValue(); deed_start_rank = jsonObject.getInt("deed_start_rank");
deed_name_lookup = ((Long) jsonObject.get("deed_name_lookup")).intValue(); deed_name_lookup = jsonObject.getInt("deed_name_lookup");
deed_indoors = ((Boolean) jsonObject.get("deed_indoors")); deed_indoors = jsonObject.getBoolean("deed_indoors");
deed_is_fortress = ((Boolean) jsonObject.get("deed_is_fortress")); deed_is_fortress = jsonObject.getBoolean("deed_is_fortress");
deed_namelookup_val = ((Double) jsonObject.get("deed_namelookup_val")).floatValue(); deed_namelookup_val = jsonObject.getFloat("deed_namelookup_val");
deed_custom_city = ((Boolean) jsonObject.get("deed_custom_city")); deed_custom_city = jsonObject.getBoolean("deed_custom_city");
deed_structure_id = ((Long) jsonObject.get("deed_structure_id")).intValue(); deed_structure_id = jsonObject.getInt("deed_structure_id");
} }
if (item_type.equals(mbEnums.ItemType.RUNE)) { if (item_type.equals(mbEnums.ItemType.RUNE)) {
rune_type = (String) jsonObject.get("rune_type"); rune_type = jsonObject.getString("rune_type");
Object subType = jsonObject.get("rune_sub_type"); Object subType = jsonObject.get("rune_sub_type");
if (subType instanceof String) if (subType instanceof String)
rune_sub_type = (String) subType; rune_sub_type = (String) subType;
rune_is_standard_character_creation = ((Boolean) jsonObject.get("rune_is_standard_character_creation")); rune_is_standard_character_creation = jsonObject.getBoolean("rune_is_standard_character_creation");
rune_creation_cost = ((Long) jsonObject.get("rune_creation_cost")).intValue(); rune_creation_cost = jsonObject.getInt("rune_creation_cost");
rune_rank = ((Long) jsonObject.get("rune_rank")).intValue(); rune_rank = jsonObject.getInt("rune_rank");
rune_pracs_per_level = ((Long) jsonObject.get("rune_pracs_per_level")).intValue(); rune_pracs_per_level = jsonObject.getInt("rune_pracs_per_level");
rune_exp_req_to_level = ((Double) jsonObject.get("rune_exp_req_to_level")).floatValue(); rune_exp_req_to_level = jsonObject.getFloat("rune_exp_req_to_level");
rune_sex = mbEnums.SexType.valueOf((String) jsonObject.get("rune_sex")); rune_sex = mbEnums.SexType.valueOf(jsonObject.getString("rune_sex"));
rune_class_icon = ((Long) jsonObject.get("rune_class_icon")).intValue(); rune_class_icon = jsonObject.getInt("rune_class_icon");
rune_health = ((Long) jsonObject.get("rune_health")).intValue(); rune_health = jsonObject.getInt("rune_health");
rune_mana = ((Long) jsonObject.get("rune_mana")).intValue(); rune_mana = jsonObject.getInt("rune_mana");
rune_stamina = ((Long) jsonObject.get("rune_stamina")).intValue(); rune_stamina = jsonObject.getInt("rune_stamina");
rune_min_damage = ((Double) jsonObject.get("rune_min_damage")).floatValue(); rune_min_damage = jsonObject.getFloat("rune_min_damage");
rune_max_damage = ((Double) jsonObject.get("rune_max_damage")).floatValue(); rune_max_damage = jsonObject.getFloat("rune_max_damage");
rune_attack = ((Long) jsonObject.get("rune_attack")).intValue(); rune_attack = jsonObject.getInt("rune_attack");
rune_defense = ((Long) jsonObject.get("rune_defense")).intValue(); rune_defense = jsonObject.getInt("rune_defense");
rune_level = ((Long) jsonObject.get("rune_level")).intValue(); rune_level = jsonObject.getInt("rune_level");
JSONObject rune_speed_json = (JSONObject) jsonObject.get("rune_speed"); JSONObject rune_speed_json = jsonObject.getJSONObject("rune_speed");
for (String key : rune_speed_json.keySet()) { for (String key : rune_speed_json.keySet()) {
mbEnums.MovementType movementType = mbEnums.MovementType.valueOf((String) key); mbEnums.MovementType movementType = mbEnums.MovementType.valueOf(key);
float speed = ((Double) rune_speed_json.get(key)).floatValue(); float speed = rune_speed_json.getFloat(key);
rune_speed.put(movementType, speed); rune_speed.put(movementType, speed);
} }
JSONObject rune_group = (JSONObject) jsonObject.get("rune_group"); JSONObject rune_group = jsonObject.getJSONObject("rune_group");
rune_group_type = ((Long) rune_group.get("group_type")).intValue(); rune_group_type = rune_group.getInt("group_type");
rune_group_is_faction = ((Boolean) rune_group.get("group_is_faction")); rune_group_is_faction = rune_group.getBoolean("group_is_faction");
rune_group_is_guild = ((Boolean) rune_group.get("group_is_guild")); rune_group_is_guild = rune_group.getBoolean("group_is_guild");
rune_dsc = (String) jsonObject.get("rune_dsc"); rune_dsc = jsonObject.getString("rune_dsc");
rune_fx_txt = (String) jsonObject.get("rune_fx_txt"); rune_fx_txt = jsonObject.getString("rune_fx_txt");
int group_tactics_bitvector = ((Long) jsonObject.get("rune_group_tactics")).intValue(); int group_tactics_bitvector = jsonObject.getInt("rune_group_tactics");
rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class));
int group_role_bitvector = ((Long) jsonObject.get("rune_group_role_set")).intValue(); int group_role_bitvector = jsonObject.getInt("rune_group_role_set");
rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class)); rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class));
JSONArray enemy_types_json = (JSONArray) jsonObject.get("rune_enemy_monster_types"); JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types");
for (Object o : enemy_types_json) { for (Object o : enemy_types_json) {
String enemy = (String) o; String enemy = (String) o;
@ -518,7 +517,7 @@ public class ItemTemplate {
rune_enemy_monster_types.add(monsterType); rune_enemy_monster_types.add(monsterType);
} }
JSONArray not_enemy_types_json = (JSONArray) jsonObject.get("rune_not_enemy_monster_types"); JSONArray not_enemy_types_json = jsonObject.getJSONArray("rune_not_enemy_monster_types");
for (Object o : not_enemy_types_json) { for (Object o : not_enemy_types_json) {
String notenemy = (String) o; String notenemy = (String) o;
@ -527,27 +526,26 @@ public class ItemTemplate {
rune_not_enemy_monster_types.add(monsterType); rune_not_enemy_monster_types.add(monsterType);
} }
JSONArray groupee_types_json = (JSONArray) jsonObject.get("rune_groupee_monster_types"); JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types");
for (Object o : groupee_types_json) { for (Object o : groupee_types_json) {
int groupeeId = ((Long) o).intValue(); int groupeeId = ((Long) o).intValue();
rune_groupee_monster_types.add(groupeeId); rune_groupee_monster_types.add(groupeeId);
} }
JSONArray helper_types_json = (JSONArray) jsonObject.get("rune_helper_monster_types"); JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types");
for (Object o : helper_types_json) { for (Object o : helper_types_json) {
int helperId = ((Long) o).intValue(); int helperId = ((Long) o).intValue();
rune_helper_monster_types.add(helperId); rune_helper_monster_types.add(helperId);
} }
rune_renderable = ((Boolean) jsonObject.get("rune_renderable")); rune_renderable = jsonObject.getBoolean("rune_renderable");
rune_natural_power_attack = ((Long) jsonObject.get("rune_natural_power_attack")).intValue(); rune_natural_power_attack = jsonObject.getInt("rune_natural_power_attack");
JSONObject rune_sparse_json = (JSONObject) jsonObject.get("rune_sparse_data"); JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data");
for (String key : rune_sparse_json.keySet()) { for (String sparseType : rune_sparse_json.keySet()) {
String sparseType = key;
Object sparseValue = rune_sparse_json.get(sparseType); Object sparseValue = rune_sparse_json.get(sparseType);
rune_sparse_data.put(sparseType, sparseValue.toString()); rune_sparse_data.put(sparseType, sparseValue.toString());
} }
@ -556,51 +554,51 @@ public class ItemTemplate {
for (Object skillEntry : skill_adj_json) { for (Object skillEntry : skill_adj_json) {
JSONObject skill = (JSONObject) skillEntry; JSONObject skill = (JSONObject) skillEntry;
String typeString = (String) skill.get("skill_type"); String typeString = skill.getString("skill_type");
JSONArray adjArray = (JSONArray) skill.get("skill_adjusts"); JSONArray adjArray = skill.getJSONArray("skill_adjusts");
for (Object adjustList : adjArray) { for (Object adjustList : adjArray) {
JSONArray adjustEntry = (JSONArray) adjustList; JSONArray adjustEntry = (JSONArray) adjustList;
int[] adjust = {((Long) adjustEntry.get(0)).intValue(), ((Long) adjustEntry.get(1)).intValue()}; int[] adjust = {adjustEntry.getInt(0), adjustEntry.getInt(1)};
rune_skill_adj.put(typeString, adjust); rune_skill_adj.put(typeString, adjust);
} }
} }
JSONArray attr_adj_json = (JSONArray) jsonObject.get("rune_attr_adj"); JSONArray attr_adj_json = jsonObject.getJSONArray("rune_attr_adj");
for (Object attributeEntry : attr_adj_json) { for (Object attributeEntry : attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry; JSONObject attribute = (JSONObject) attributeEntry;
String typeString = (String) attribute.get("attr_type"); String typeString = attribute.getString("attr_type");
mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString);
int attributeValue = ((Long) attribute.get("attr_value")).intValue(); int attributeValue = attribute.getInt("attr_value");
rune_attr_adj.put(attributeType, attributeValue); rune_attr_adj.put(attributeType, attributeValue);
} }
JSONArray max_attr_adj_json = (JSONArray) jsonObject.get("rune_max_attr_adj"); JSONArray max_attr_adj_json = jsonObject.getJSONArray("rune_max_attr_adj");
for (Object attributeEntry : max_attr_adj_json) { for (Object attributeEntry : max_attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry; JSONObject attribute = (JSONObject) attributeEntry;
String typeString = (String) attribute.get("attr_type"); String typeString = attribute.getString("attr_type");
mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString);
int attributeValue = ((Long) attribute.get("attr_value")).intValue(); int attributeValue = attribute.getInt("attr_value");
rune_max_attr_adj.put(attributeType, attributeValue); rune_max_attr_adj.put(attributeType, attributeValue);
} }
JSONArray skill_grant_json = (JSONArray) jsonObject.get("rune_skill_grant"); JSONArray skill_grant_json = jsonObject.getJSONArray("rune_skill_grant");
if (skill_grant_json.isEmpty() == false) if (skill_grant_json.isEmpty() == false)
for (Object runeSkillEntry : skill_grant_json) { for (Object runeSkillEntry : skill_grant_json) {
JSONObject skill_granted = (JSONObject) runeSkillEntry; JSONObject skill_granted = (JSONObject) runeSkillEntry;
String typeString = (String) skill_granted.get("skill_type"); String typeString = skill_granted.getString("skill_type");
int skill_level = ((Long) skill_granted.get("skill_value")).intValue(); int skill_level = skill_granted.getInt("skill_value");
rune_skill_grant.put(typeString, skill_level); rune_skill_grant.put(typeString, skill_level);
JSONArray skill_granted_array = (JSONArray) skill_granted.get("skill_granted_skills"); JSONArray skill_granted_array = skill_granted.getJSONArray("skill_granted_skills");
for (Object skillGrantEntry : skill_granted_array) { for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry; JSONArray skill_entry = (JSONArray) skillGrantEntry;
typeString = (String) skill_entry.get(0); typeString = skill_entry.getString(0);
skill_level = ((Long) skill_entry.get(1)).intValue(); skill_level = skill_entry.getInt(1);
skill_granted_skills.put(typeString, skill_level); skill_granted_skills.put(typeString, skill_level);
} }
} }

Loading…
Cancel
Save