RuneHive-Game
Loading...
Searching...
No Matches
ItemDefinitionParser.java
Go to the documentation of this file.
1package com.runehive.util.parser.old;
2
3import com.google.gson.JsonObject;
4import com.runehive.util.parser.GsonParser;
5import com.runehive.util.parser.old.defs.ItemDefinition;
6
7/**
8 * Parses through the item definitions file and creates {@link ItemDefinition}s
9 * on startup.
10 *
11 * @author Daniel | Obey
12 */
13public class ItemDefinitionParser extends GsonParser {
14
16 super("def/item/item_definitions");
17 }
18
19 @Override
20 protected void parse(JsonObject data) {
21 final int id = data.get("id").getAsInt();
22 final String name = data.get("name").getAsString();
23 final boolean members = data.get("gameMembers").getAsBoolean();
24 final boolean tradeable = data.get("tradeable").getAsBoolean();
25 final boolean stackable = data.get("stackable").getAsBoolean();
26 final boolean droppable = data.get("droppable").getAsBoolean();
27 final boolean noteable = data.get("noteable").getAsBoolean();
28 final boolean noted = data.get("noted").getAsBoolean();
29 final int notedId = data.get("notedId").getAsInt();
30 final int street_value = data.get("street_value").getAsInt();
31 final int base_value = data.get("base_value").getAsInt();
32 final int high_alch = data.get("high_alch").getAsInt();
33 final int low_alch = data.get("low_alch").getAsInt();
34 final String examine = data.get("examine").getAsString();
35
36 String destroyMessage = "This item is valuable, you will not\\nget it back once lost.";
37 if (data.get("destroy_message") != null) {
38 destroyMessage = data.get("destroy_message").getAsString();
39 }
40
41 final double weight = data.get("weight").getAsDouble();
42
43 ItemDefinition.DEFINITIONS[id] = new ItemDefinition(id, name, members, tradeable, stackable, droppable, noteable, noted, notedId, street_value, base_value, high_alch, low_alch, examine, destroyMessage, weight);
44 }
45}
Represents all of an in-game Item's attributes.
static ItemDefinition[] DEFINITIONS
An array of item definitions.
GsonParser(String path)
Creates a new GsonParser.
void parse(JsonObject data)
The method allows a user to modify the data as its being parsed.