ItemInfo.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.item.L2Item;
  17. import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
  18. /**
  19. * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
  20. *
  21. */
  22. public class ItemInfo
  23. {
  24. /** Identifier of the L2ItemInstance */
  25. private int _objectId;
  26. /** The L2Item template of the L2ItemInstance */
  27. private L2Item _item;
  28. /** The level of enchant on the L2ItemInstance */
  29. private int _enchant;
  30. /** The augmentation of the item */
  31. private int _augmentation;
  32. /** The quantity of L2ItemInstance */
  33. private long _count;
  34. /** The price of the L2ItemInstance */
  35. private int _price;
  36. /** The custom L2ItemInstance types (used loto, race tickets) */
  37. private int _type1;
  38. private int _type2;
  39. /** If True the L2ItemInstance is equipped */
  40. private int _equipped;
  41. /** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
  42. private int _change;
  43. /** The mana of this item */
  44. private int _mana;
  45. private int _time;
  46. private int _location;
  47. private int _elemAtkType = -2;
  48. private int _elemAtkPower = 0;
  49. private int[] _elemDefAttr = {0, 0, 0, 0, 0, 0};
  50. /**
  51. * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
  52. * @param item
  53. */
  54. public ItemInfo(L2ItemInstance item)
  55. {
  56. if (item == null) return;
  57. // Get the Identifier of the L2ItemInstance
  58. _objectId = item.getObjectId();
  59. // Get the L2Item of the L2ItemInstance
  60. _item = item.getItem();
  61. // Get the enchant level of the L2ItemInstance
  62. _enchant = item.getEnchantLevel();
  63. // Get the augmentation boni
  64. if (item.isAugmented()) _augmentation = item.getAugmentation().getAugmentationId();
  65. else _augmentation = 0;
  66. // Get the quantity of the L2ItemInstance
  67. _count = item.getCount();
  68. // Get custom item types (used loto, race tickets)
  69. _type1 = item.getCustomType1();
  70. _type2 = item.getCustomType2();
  71. // Verify if the L2ItemInstance is equipped
  72. _equipped = item.isEquipped() ? 1 : 0;
  73. // Get the action to do clientside
  74. switch (item.getLastChange())
  75. {
  76. case (L2ItemInstance.ADDED): { _change = 1; break; }
  77. case (L2ItemInstance.MODIFIED): { _change = 2; break; }
  78. case (L2ItemInstance.REMOVED): { _change = 3; break;}
  79. }
  80. // Get shadow item mana
  81. _mana = item.getMana();
  82. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
  83. _location = item.getLocationSlot();
  84. _elemAtkType = item.getAttackElementType();
  85. _elemAtkPower = item.getAttackElementPower();
  86. for (byte i = 0; i < 6; i++)
  87. _elemDefAttr[i] = item.getElementDefAttr(i);
  88. }
  89. public ItemInfo(L2ItemInstance item, int change)
  90. {
  91. if (item == null) return;
  92. // Get the Identifier of the L2ItemInstance
  93. _objectId = item.getObjectId();
  94. // Get the L2Item of the L2ItemInstance
  95. _item = item.getItem();
  96. // Get the enchant level of the L2ItemInstance
  97. _enchant = item.getEnchantLevel();
  98. // Get the augmentation boni
  99. if (item.isAugmented()) _augmentation = item.getAugmentation().getAugmentationId();
  100. else _augmentation = 0;
  101. // Get the quantity of the L2ItemInstance
  102. _count = item.getCount();
  103. // Get custom item types (used loto, race tickets)
  104. _type1 = item.getCustomType1();
  105. _type2 = item.getCustomType2();
  106. // Verify if the L2ItemInstance is equipped
  107. _equipped = item.isEquipped() ? 1 : 0;
  108. // Get the action to do clientside
  109. _change = change;
  110. // Get shadow item mana
  111. _mana = item.getMana();
  112. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
  113. _location = item.getLocationSlot();
  114. _elemAtkType = item.getAttackElementType();
  115. _elemAtkPower = item.getAttackElementPower();
  116. for (byte i = 0; i < 6; i++)
  117. _elemDefAttr[i] = item.getElementDefAttr(i);
  118. }
  119. public int getObjectId(){return _objectId;}
  120. public L2Item getItem(){return _item;}
  121. public int getEnchant(){return _enchant;}
  122. public int getAugmentationBonus(){return _augmentation;}
  123. public long getCount(){return _count;}
  124. public int getPrice(){return _price;}
  125. public int getCustomType1(){return _type1;}
  126. public int getCustomType2(){return _type2;}
  127. public int getEquipped(){return _equipped;}
  128. public int getChange(){return _change;}
  129. public int getMana(){return _mana;}
  130. public int getTime(){return _time;}
  131. public int getLocation(){return _location;}
  132. public int getAttackElementType(){return _elemAtkType;}
  133. public int getAttackElementPower(){return _elemAtkPower;}
  134. public int getElementDefAttr(byte i){return _elemDefAttr[i];}
  135. }