L2WarehouseItem.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.items;
  16. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  17. import com.l2jserver.gameserver.model.items.type.L2ItemType;
  18. /**
  19. * This class contains L2ItemInstance<BR>
  20. * Use to sort L2ItemInstance of :
  21. * <ul>
  22. * <li>L2Armor</li>
  23. * <li>L2EtcItem</li>
  24. * <li>L2Weapon</li>
  25. * </ul>
  26. * @version $Revision: 1.7.2.2.2.5 $ $Date: 2005/04/06 18:25:18 $
  27. */
  28. public class L2WarehouseItem
  29. {
  30. private final L2Item _item;
  31. private final int _object;
  32. private final long _count;
  33. private final int _owner;
  34. private final int _locationSlot;
  35. private final int _enchant;
  36. private final int _grade;
  37. private boolean _isAugmented;
  38. private int _augmentationId;
  39. private final int _customType1;
  40. private final int _customType2;
  41. private final int _mana;
  42. private int _elemAtkType = -2;
  43. private int _elemAtkPower = 0;
  44. private final int[] _elemDefAttr =
  45. {
  46. 0,
  47. 0,
  48. 0,
  49. 0,
  50. 0,
  51. 0
  52. };
  53. private final int[] _enchantOptions;
  54. private final int _time;
  55. public L2WarehouseItem(L2ItemInstance item)
  56. {
  57. _item = item.getItem();
  58. _object = item.getObjectId();
  59. _count = item.getCount();
  60. _owner = item.getOwnerId();
  61. _locationSlot = item.getLocationSlot();
  62. _enchant = item.getEnchantLevel();
  63. _customType1 = item.getCustomType1();
  64. _customType2 = item.getCustomType2();
  65. _grade = item.getItem().getItemGrade();
  66. if (item.isAugmented())
  67. {
  68. _isAugmented = true;
  69. _augmentationId = item.getAugmentation().getAugmentationId();
  70. }
  71. else
  72. {
  73. _isAugmented = false;
  74. }
  75. _mana = item.getMana();
  76. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -1;
  77. _elemAtkType = item.getAttackElementType();
  78. _elemAtkPower = item.getAttackElementPower();
  79. for (byte i = 0; i < 6; i++)
  80. {
  81. _elemDefAttr[i] = item.getElementDefAttr(i);
  82. }
  83. _enchantOptions = item.getEnchantOptions();
  84. }
  85. /**
  86. * @return the item.
  87. */
  88. public L2Item getItem()
  89. {
  90. return _item;
  91. }
  92. /**
  93. * @return the unique objectId.
  94. */
  95. public final int getObjectId()
  96. {
  97. return _object;
  98. }
  99. /**
  100. * @return the owner.
  101. */
  102. public final int getOwnerId()
  103. {
  104. return _owner;
  105. }
  106. /**
  107. * @return the location slot.
  108. */
  109. public final int getLocationSlot()
  110. {
  111. return _locationSlot;
  112. }
  113. /**
  114. * @return the count.
  115. */
  116. public final long getCount()
  117. {
  118. return _count;
  119. }
  120. /**
  121. * @return the first type.
  122. */
  123. public final int getType1()
  124. {
  125. return _item.getType1();
  126. }
  127. /**
  128. * @return the second type.
  129. */
  130. public final int getType2()
  131. {
  132. return _item.getType2();
  133. }
  134. /**
  135. * @return the second type.
  136. */
  137. public final L2ItemType getItemType()
  138. {
  139. return _item.getItemType();
  140. }
  141. /**
  142. * @return the ItemId.
  143. */
  144. public final int getItemId()
  145. {
  146. return _item.getItemId();
  147. }
  148. /**
  149. * @return the part of body used with this item.
  150. */
  151. public final int getBodyPart()
  152. {
  153. return _item.getBodyPart();
  154. }
  155. /**
  156. * @return the enchant level.
  157. */
  158. public final int getEnchantLevel()
  159. {
  160. return _enchant;
  161. }
  162. /**
  163. * @return the item grade
  164. */
  165. public final int getItemGrade()
  166. {
  167. return _grade;
  168. }
  169. /**
  170. * @return {@code true} if the item is a weapon, {@code false} otherwise.
  171. */
  172. public final boolean isWeapon()
  173. {
  174. return (_item instanceof L2Weapon);
  175. }
  176. /**
  177. * @return {@code true} if the item is an armor, {@code false} otherwise.
  178. */
  179. public final boolean isArmor()
  180. {
  181. return (_item instanceof L2Armor);
  182. }
  183. /**
  184. * @return {@code true} if the item is an etc item, {@code false} otherwise.
  185. */
  186. public final boolean isEtcItem()
  187. {
  188. return (_item instanceof L2EtcItem);
  189. }
  190. /**
  191. * @return the name of the item
  192. */
  193. public String getItemName()
  194. {
  195. return _item.getName();
  196. }
  197. /**
  198. * @return {@code true} if the item is augmented, {@code false} otherwise.
  199. */
  200. public boolean isAugmented()
  201. {
  202. return _isAugmented;
  203. }
  204. /**
  205. * @return the augmentation If.
  206. */
  207. public int getAugmentationId()
  208. {
  209. return _augmentationId;
  210. }
  211. /**
  212. * @return the name of the item
  213. */
  214. public String getName()
  215. {
  216. return _item.getName();
  217. }
  218. public final int getCustomType1()
  219. {
  220. return _customType1;
  221. }
  222. public final int getCustomType2()
  223. {
  224. return _customType2;
  225. }
  226. public final int getMana()
  227. {
  228. return _mana;
  229. }
  230. public int getAttackElementType()
  231. {
  232. return _elemAtkType;
  233. }
  234. public int getAttackElementPower()
  235. {
  236. return _elemAtkPower;
  237. }
  238. public int getElementDefAttr(byte i)
  239. {
  240. return _elemDefAttr[i];
  241. }
  242. public int[] getEnchantOptions()
  243. {
  244. return _enchantOptions;
  245. }
  246. public int getTime()
  247. {
  248. return _time;
  249. }
  250. /**
  251. * @return the name of the item
  252. */
  253. @Override
  254. public String toString()
  255. {
  256. return _item.toString();
  257. }
  258. }