RuneHive-Game
Loading...
Searching...
No Matches
ItemDefinition.java
Go to the documentation of this file.
1package com.runehive.util.parser.old.defs;
2
3import com.runehive.Config;
4
5/**
6 * Represents all of an in-game Item's attributes.
7 *
8 * @author Daniel | Obey
9 */
10public class ItemDefinition {
11
12 /** An array of item definitions. */
14
15 /** The item identification definition. */
16 private int id;
17
18 /** The item name definition. */
19 private String name;
20
21 /** The gameMembers item state. */
22 private boolean members;
23
24 /** The tradable item state. */
25 private boolean tradeable;
26
27 /** The stackable item state definition. */
28 private boolean stackable;
29
30 /** The droppable item state definition. */
31 private boolean droppable;
32
33 /** The item notability state definition. */
34 private boolean noteable;
35
36 /** The noted item state definition. */
37 private boolean noted;
38
39 /** The noted item identification definition. */
40 private int notedId;
41
42 /** The item street value definition. */
43 private int street_value;
44
45 /** The item base value definition. */
46 private int base_value;
47
48 /** The high alchemy value definition. */
49 private int highAlch;
50
51 /** The low alchemy value definition. */
52 private int lowAlch;
53
54 /** The item examine definition. */
55 private String examine;
56
57 /** The item destroy message definition. */
58 private String destroyMessage;
59
60 /** The item's weight definition. */
61 private double weight;
62
63 public ItemDefinition(int id, String name, boolean members, boolean tradeable, boolean stackable, boolean droppable, boolean noteable, boolean noted, int notedId, int street_value, int base_value, int highAlch, int lowAlch, String examine, String destroyMessage, double weight) {
64 this.id = id;
65 this.name = name;
66 this.members = members;
67 this.tradeable = tradeable;
68 this.stackable = stackable;
69 this.droppable = droppable;
70 this.noteable = noteable;
71 this.noted = noted;
72 this.notedId = notedId;
73 this.street_value = street_value;
74 this.base_value = base_value;
75 this.highAlch = highAlch;
76 this.lowAlch = lowAlch;
77 this.examine = examine;
78 this.destroyMessage = destroyMessage;
79 this.weight = weight;
80 }
81
82 /**
83 * Gets an item definition.
84 *
85 * @param id The definition's item id.
86 * @return The item definition for the item id, or null if the item id is
87 * out of bounds.
88 */
89 public static final ItemDefinition get(int id) {
90 if (id < 0 || id >= DEFINITIONS.length) {
91 return null;
92 }
93
94 return DEFINITIONS[id];
95 }
96
97 /**
98 * Gets the item id.
99 *
100 * @return The item id.
101 */
102 public int getId() {
103 return id;
104 }
105
106 /**
107 * Gets the item name.
108 *
109 * @return The item name.
110 */
111 public String getName() {
112 return name;
113 }
114
115 /**
116 * Gets the item examine.
117 *
118 * @return The item examine.
119 */
120 public String getExamine() {
121 return examine;
122 }
123
124 /**
125 * Gets the item destroy message.
126 *
127 * @return The item destroy message.
128 */
129 public String getDestroyMessage() {
130 return destroyMessage;
131 }
132
133 /**
134 * Gets the item note state.
135 *
136 * @return {@code True} if the item is noted;
137 */
138 public boolean isNoted() {
139 return noted;
140 }
141
142 /**
143 * Gets the item notability state.
144 *
145 * @return {@code} if the item can be turned into a note.
146 */
147 public boolean isNoteable() {
148 return noteable;
149 }
150
151 /**
152 * Gets the parent id.
153 *
154 * @return The unnoted id of this item if this item is noted, or the
155 * original item id if it is already unnoted.
156 */
157 public int getParentId() {
158 if (!noteable) {
159 return id;
160 }
161 return noted ? notedId : get(notedId).notedId;
162 }
163
164 /**
165 * Gets the item note id.
166 *
167 * @return The item note id, or the original item id if it cannot be noted.
168 */
169 public int getNotedId() {
170 if (notedId == -1) {
171 return id;
172 }
173 return notedId;
174 }
175
176 /**
177 * Gets the item stackability state.
178 *
179 * @return {@code True} if the item can be stacked.
180 */
181 public boolean isStackable() {
182 return stackable;
183 }
184
185 /**
186 * Gets the item destroyability state.
187 *
188 * @return {@code True} if the item can be destroyed.
189 */
190 public boolean isDroppable() {
191 return droppable;
192 }
193
194 /**
195 * Gets the item tradability state.
196 *
197 * @return {@code True} if the item is tradable.
198 */
199 public boolean isTradeable() {
200 return tradeable;
201 }
202
203 /**
204 * Gets the gameMembers item state.
205 *
206 * @return {@code True} if this item is a gameMembers item.
207 */
208 public boolean isMembers() {
209 return members;
210 }
211
212 /**
213 * Gets the item value.
214 *
215 * @return The value.
216 */
217 public int getStreetValue() {
218 return street_value;
219 }
220
221 /**
222 * Gets the item value.
223 *
224 * @return The value.
225 */
226 public int getBaseValue() {
227 return base_value;
228 }
229
230 /**
231 * Gets the item value.
232 *
233 * @return The value.
234 */
235 public int getValue() {
236 return getStreetValue();
237 }
238
239 /**
240 * Gets the high alchemy item value.
241 *
242 * @return The value.
243 */
244 public int getHighAlch() {
245 return highAlch;
246 }
247
248 /**
249 * Gets the low alchemy item value.
250 *
251 * @return The value.
252 */
253 public int getLowAlch() {
254 return lowAlch;
255 }
256
257 /**
258 * Gets the item's weight.
259 *
260 * @return The item weight.
261 */
262 public double getWeight() {
263 return weight;
264 }
265
266}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int ITEM_DEFINITION_LIMIT
The limit of the item identification.
Definition Config.java:181
int id
The item identification definition.
ItemDefinition(int id, String name, boolean members, boolean tradeable, boolean stackable, boolean droppable, boolean noteable, boolean noted, int notedId, int street_value, int base_value, int highAlch, int lowAlch, String examine, String destroyMessage, double weight)
boolean droppable
The droppable item state definition.
double weight
The item's weight definition.
String examine
The item examine definition.
int street_value
The item street value definition.
int base_value
The item base value definition.
int lowAlch
The low alchemy value definition.
String getDestroyMessage()
Gets the item destroy message.
String destroyMessage
The item destroy message definition.
boolean isNoted()
Gets the item note state.
boolean noted
The noted item state definition.
boolean noteable
The item notability state definition.
int highAlch
The high alchemy value definition.
boolean stackable
The stackable item state definition.
static final ItemDefinition[] DEFINITIONS
An array of item definitions.
boolean members
The gameMembers item state.
int notedId
The noted item identification definition.