L2WarehouseItem.java 5.8 KB

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