L2WarehouseItem.java 5.6 KB

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