L2WarehouseItem.java 5.4 KB

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