ItemInfo.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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;
  16. import com.l2jserver.gameserver.model.items.L2Item;
  17. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  18. /**
  19. * Get all information from L2ItemInstance to generate ItemInfo.
  20. */
  21. public class ItemInfo
  22. {
  23. /** Identifier of the L2ItemInstance */
  24. private int _objectId;
  25. /** The L2Item template of the L2ItemInstance */
  26. private L2Item _item;
  27. /** The level of enchant on the L2ItemInstance */
  28. private int _enchant;
  29. /** The augmentation of the item */
  30. private int _augmentation;
  31. /** The quantity of L2ItemInstance */
  32. private long _count;
  33. /** The price of the L2ItemInstance */
  34. private int _price;
  35. /** The custom L2ItemInstance types (used loto, race tickets) */
  36. private int _type1;
  37. private int _type2;
  38. /** If True the L2ItemInstance is equipped */
  39. private int _equipped;
  40. /** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
  41. private int _change;
  42. /** The mana of this item */
  43. private int _mana;
  44. private int _time;
  45. private int _location;
  46. private int _elemAtkType = -2;
  47. private int _elemAtkPower = 0;
  48. private final int[] _elemDefAttr =
  49. {
  50. 0,
  51. 0,
  52. 0,
  53. 0,
  54. 0,
  55. 0
  56. };
  57. private int[] _option;
  58. /**
  59. * Get all information from L2ItemInstance to generate ItemInfo.
  60. * @param item
  61. */
  62. public ItemInfo(L2ItemInstance item)
  63. {
  64. if (item == null)
  65. {
  66. return;
  67. }
  68. // Get the Identifier of the L2ItemInstance
  69. _objectId = item.getObjectId();
  70. // Get the L2Item of the L2ItemInstance
  71. _item = item.getItem();
  72. // Get the enchant level of the L2ItemInstance
  73. _enchant = item.getEnchantLevel();
  74. // Get the augmentation boni
  75. if (item.isAugmented())
  76. {
  77. _augmentation = item.getAugmentation().getAugmentationId();
  78. }
  79. else
  80. {
  81. _augmentation = 0;
  82. }
  83. // Get the quantity of the L2ItemInstance
  84. _count = item.getCount();
  85. // Get custom item types (used loto, race tickets)
  86. _type1 = item.getCustomType1();
  87. _type2 = item.getCustomType2();
  88. // Verify if the L2ItemInstance is equipped
  89. _equipped = item.isEquipped() ? 1 : 0;
  90. // Get the action to do clientside
  91. switch (item.getLastChange())
  92. {
  93. case (L2ItemInstance.ADDED):
  94. {
  95. _change = 1;
  96. break;
  97. }
  98. case (L2ItemInstance.MODIFIED):
  99. {
  100. _change = 2;
  101. break;
  102. }
  103. case (L2ItemInstance.REMOVED):
  104. {
  105. _change = 3;
  106. break;
  107. }
  108. }
  109. // Get shadow item mana
  110. _mana = item.getMana();
  111. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
  112. _location = item.getLocationSlot();
  113. _elemAtkType = item.getAttackElementType();
  114. _elemAtkPower = item.getAttackElementPower();
  115. for (byte i = 0; i < 6; i++)
  116. {
  117. _elemDefAttr[i] = item.getElementDefAttr(i);
  118. }
  119. _option = item.getEnchantOptions();
  120. }
  121. public ItemInfo(L2ItemInstance item, int change)
  122. {
  123. if (item == null)
  124. {
  125. return;
  126. }
  127. // Get the Identifier of the L2ItemInstance
  128. _objectId = item.getObjectId();
  129. // Get the L2Item of the L2ItemInstance
  130. _item = item.getItem();
  131. // Get the enchant level of the L2ItemInstance
  132. _enchant = item.getEnchantLevel();
  133. // Get the augmentation boni
  134. if (item.isAugmented())
  135. {
  136. _augmentation = item.getAugmentation().getAugmentationId();
  137. }
  138. else
  139. {
  140. _augmentation = 0;
  141. }
  142. // Get the quantity of the L2ItemInstance
  143. _count = item.getCount();
  144. // Get custom item types (used loto, race tickets)
  145. _type1 = item.getCustomType1();
  146. _type2 = item.getCustomType2();
  147. // Verify if the L2ItemInstance is equipped
  148. _equipped = item.isEquipped() ? 1 : 0;
  149. // Get the action to do clientside
  150. _change = change;
  151. // Get shadow item mana
  152. _mana = item.getMana();
  153. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
  154. _location = item.getLocationSlot();
  155. _elemAtkType = item.getAttackElementType();
  156. _elemAtkPower = item.getAttackElementPower();
  157. for (byte i = 0; i < 6; i++)
  158. {
  159. _elemDefAttr[i] = item.getElementDefAttr(i);
  160. }
  161. _option = item.getEnchantOptions();
  162. }
  163. public int getObjectId()
  164. {
  165. return _objectId;
  166. }
  167. public L2Item getItem()
  168. {
  169. return _item;
  170. }
  171. public int getEnchant()
  172. {
  173. return _enchant;
  174. }
  175. public int getAugmentationBonus()
  176. {
  177. return _augmentation;
  178. }
  179. public long getCount()
  180. {
  181. return _count;
  182. }
  183. public int getPrice()
  184. {
  185. return _price;
  186. }
  187. public int getCustomType1()
  188. {
  189. return _type1;
  190. }
  191. public int getCustomType2()
  192. {
  193. return _type2;
  194. }
  195. public int getEquipped()
  196. {
  197. return _equipped;
  198. }
  199. public int getChange()
  200. {
  201. return _change;
  202. }
  203. public int getMana()
  204. {
  205. return _mana;
  206. }
  207. public int getTime()
  208. {
  209. return _time;
  210. }
  211. public int getLocation()
  212. {
  213. return _location;
  214. }
  215. public int getAttackElementType()
  216. {
  217. return _elemAtkType;
  218. }
  219. public int getAttackElementPower()
  220. {
  221. return _elemAtkPower;
  222. }
  223. public int getElementDefAttr(byte i)
  224. {
  225. return _elemDefAttr[i];
  226. }
  227. public int[] getEnchantOptions()
  228. {
  229. return _option;
  230. }
  231. }