L2WarehouseItem.java 5.5 KB

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