L2WarehouseItem.java 5.3 KB

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