L2WarehouseItem.java 5.6 KB

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