2
0

ItemInfo.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.templates.item.L2Item;
  17. /**
  18. * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
  19. *
  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 int[] _elemDefAttr = {0, 0, 0, 0, 0, 0};
  49. /**
  50. * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
  51. * @param item
  52. */
  53. public ItemInfo(L2ItemInstance item)
  54. {
  55. if (item == null) return;
  56. // Get the Identifier of the L2ItemInstance
  57. _objectId = item.getObjectId();
  58. // Get the L2Item of the L2ItemInstance
  59. _item = item.getItem();
  60. // Get the enchant level of the L2ItemInstance
  61. _enchant = item.getEnchantLevel();
  62. // Get the augmentation boni
  63. if (item.isAugmented()) _augmentation = item.getAugmentation().getAugmentationId();
  64. else _augmentation = 0;
  65. // Get the quantity of the L2ItemInstance
  66. _count = item.getCount();
  67. // Get custom item types (used loto, race tickets)
  68. _type1 = item.getCustomType1();
  69. _type2 = item.getCustomType2();
  70. // Verify if the L2ItemInstance is equipped
  71. _equipped = item.isEquipped() ? 1 : 0;
  72. // Get the action to do clientside
  73. switch (item.getLastChange())
  74. {
  75. case (L2ItemInstance.ADDED): { _change = 1; break; }
  76. case (L2ItemInstance.MODIFIED): { _change = 2; break; }
  77. case (L2ItemInstance.REMOVED): { _change = 3; break;}
  78. }
  79. // Get shadow item mana
  80. _mana = item.getMana();
  81. _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
  82. _location = item.getLocationSlot();
  83. _elemAtkType = item.getAttackElementType();
  84. _elemAtkPower = item.getAttackElementPower();
  85. for (byte i = 0; i < 6; i++)
  86. _elemDefAttr[i] = item.getElementDefAttr(i);
  87. }
  88. public ItemInfo(L2ItemInstance item, int change)
  89. {
  90. if (item == null) return;
  91. // Get the Identifier of the L2ItemInstance
  92. _objectId = item.getObjectId();
  93. // Get the L2Item of the L2ItemInstance
  94. _item = item.getItem();
  95. // Get the enchant level of the L2ItemInstance
  96. _enchant = item.getEnchantLevel();
  97. // Get the augmentation boni
  98. if (item.isAugmented()) _augmentation = item.getAugmentation().getAugmentationId();
  99. else _augmentation = 0;
  100. // Get the quantity of the L2ItemInstance
  101. _count = item.getCount();
  102. // Get custom item types (used loto, race tickets)
  103. _type1 = item.getCustomType1();
  104. _type2 = item.getCustomType2();
  105. // Verify if the L2ItemInstance is equipped
  106. _equipped = item.isEquipped() ? 1 : 0;
  107. // Get the action to do clientside
  108. _change = change;
  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. _elemDefAttr[i] = item.getElementDefAttr(i);
  117. }
  118. public int getObjectId(){return _objectId;}
  119. public L2Item getItem(){return _item;}
  120. public int getEnchant(){return _enchant;}
  121. public int getAugmentationBonus(){return _augmentation;}
  122. public long getCount(){return _count;}
  123. public int getPrice(){return _price;}
  124. public int getCustomType1(){return _type1;}
  125. public int getCustomType2(){return _type2;}
  126. public int getEquipped(){return _equipped;}
  127. public int getChange(){return _change;}
  128. public int getMana(){return _mana;}
  129. public int getTime(){return _time;}
  130. public int getLocation(){return _location;}
  131. public int getAttackElementType(){return _elemAtkType;}
  132. public int getAttackElementPower(){return _elemAtkPower;}
  133. public int getElementDefAttr(byte i){return _elemDefAttr[i];}
  134. }