L2WarehouseItem.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 net.sf.l2j.gameserver.templates.item;
  16. import net.sf.l2j.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 _enchant;
  32. private int _grade;
  33. private boolean _isAugmented;
  34. private int _augmentationId;
  35. private int _customType1;
  36. private int _customType2;
  37. private int _mana;
  38. private int _elemAtkType = -2;
  39. private int _elemAtkPower = 0;
  40. private int[] _elemDefAttr =
  41. {
  42. 0, 0, 0, 0, 0, 0
  43. };
  44. private int _time;
  45. public L2WarehouseItem(L2ItemInstance item)
  46. {
  47. _item = item.getItem();
  48. _object = item.getObjectId();
  49. _count = item.getCount();
  50. _owner = item.getOwnerId();
  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. _isAugmented = false;
  62. _mana = item.getMana();
  63. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime()/1000) : -1;
  64. _elemAtkType = item.getAttackElementType();
  65. _elemAtkPower = item.getAttackElementPower();
  66. for (byte i = 0; i < 6; i++)
  67. _elemDefAttr[i] = item.getElementDefAttr(i);
  68. }
  69. /**
  70. * Returns the item.
  71. * @return L2Item
  72. */
  73. public L2Item getItem()
  74. {
  75. return _item;
  76. }
  77. /**
  78. * Returns the unique objectId
  79. * @return int
  80. */
  81. public final int getObjectId()
  82. {
  83. return _object;
  84. }
  85. /**
  86. * Returns the owner
  87. * @return int
  88. */
  89. public final int getOwnerId()
  90. {
  91. return _owner;
  92. }
  93. /**
  94. * Returns the count
  95. * @return int
  96. */
  97. public final long getCount()
  98. {
  99. return _count;
  100. }
  101. /**
  102. * Returns the first type
  103. * @return int
  104. */
  105. public final int getType1()
  106. {
  107. return _item.getType1();
  108. }
  109. /**
  110. * Returns the second type
  111. * @return int
  112. */
  113. public final int getType2()
  114. {
  115. return _item.getType2();
  116. }
  117. /**
  118. * Returns the second type
  119. * @return int
  120. */
  121. @SuppressWarnings("unchecked")
  122. public final Enum getItemType()
  123. {
  124. return _item.getItemType();
  125. }
  126. /**
  127. * Returns the ItemId
  128. * @return int
  129. */
  130. public final int getItemId()
  131. {
  132. return _item.getItemId();
  133. }
  134. /**
  135. * Returns the part of body used with this item
  136. * @return int
  137. */
  138. public final int getBodyPart()
  139. {
  140. return _item.getBodyPart();
  141. }
  142. /**
  143. * Returns the enchant level
  144. * @return int
  145. */
  146. public final int getEnchantLevel()
  147. {
  148. return _enchant;
  149. }
  150. /**
  151. * Returns the item grade
  152. * @return int
  153. */
  154. public final int getItemGrade()
  155. {
  156. return _grade;
  157. }
  158. /**
  159. * Returns true if it is a weapon
  160. * @return boolean
  161. */
  162. public final boolean isWeapon()
  163. {
  164. return (_item instanceof L2Weapon);
  165. }
  166. /**
  167. * Returns true if it is an armor
  168. * @return boolean
  169. */
  170. public final boolean isArmor()
  171. {
  172. return (_item instanceof L2Armor);
  173. }
  174. /**
  175. * Returns true if it is an EtcItem
  176. * @return boolean
  177. */
  178. public final boolean isEtcItem()
  179. {
  180. return (_item instanceof L2EtcItem);
  181. }
  182. /**
  183. * Returns the name of the item
  184. * @return String
  185. */
  186. public String getItemName()
  187. {
  188. return _item.getName();
  189. }
  190. public boolean isAugmented()
  191. {
  192. return _isAugmented;
  193. }
  194. public int getAugmentationId()
  195. {
  196. return _augmentationId;
  197. }
  198. /**
  199. * Returns the name of the item
  200. * @return String
  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. public String getName()
  204. {
  205. return _item.getName();
  206. }
  207. public final int getCustomType1()
  208. {
  209. return _customType1;
  210. }
  211. public final int getCustomType2()
  212. {
  213. return _customType2;
  214. }
  215. public final int getMana()
  216. {
  217. return _mana;
  218. }
  219. public int getAttackElementType()
  220. {
  221. return _elemAtkType;
  222. }
  223. public int getAttackElementPower()
  224. {
  225. return _elemAtkPower;
  226. }
  227. public int getElementDefAttr(byte i)
  228. {
  229. return _elemDefAttr[i];
  230. }
  231. public int getTime()
  232. {
  233. return _time;
  234. }
  235. /**
  236. * Returns the name of the item
  237. * @return String
  238. */
  239. public String toString()
  240. {
  241. return _item.toString();
  242. }
  243. }