Ingredient.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.multisell;
  16. import com.l2jserver.gameserver.datatables.ItemTable;
  17. import com.l2jserver.gameserver.model.items.L2Armor;
  18. import com.l2jserver.gameserver.model.items.L2Item;
  19. import com.l2jserver.gameserver.model.items.L2Weapon;
  20. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  21. /**
  22. * @author DS
  23. */
  24. public class Ingredient
  25. {
  26. private int _itemId;
  27. private long _itemCount;
  28. private boolean _isTaxIngredient;
  29. private boolean _maintainIngredient;
  30. private L2Item _template = null;
  31. private ItemInfo _itemInfo = null;
  32. public Ingredient(int itemId, long itemCount, boolean isTaxIngredient, boolean maintainIngredient)
  33. {
  34. _itemId = itemId;
  35. _itemCount = itemCount;
  36. _isTaxIngredient = isTaxIngredient;
  37. _maintainIngredient = maintainIngredient;
  38. if (_itemId > 0)
  39. {
  40. _template = ItemTable.getInstance().getTemplate(_itemId);
  41. }
  42. }
  43. /**
  44. * @return a new Ingredient instance with the same values as this.
  45. */
  46. public Ingredient getCopy()
  47. {
  48. return new Ingredient(_itemId, _itemCount, _isTaxIngredient, _maintainIngredient);
  49. }
  50. public final L2Item getTemplate()
  51. {
  52. return _template;
  53. }
  54. public final void setItemInfo(L2ItemInstance item)
  55. {
  56. _itemInfo = new ItemInfo(item);
  57. }
  58. public final void setItemInfo(ItemInfo info)
  59. {
  60. _itemInfo = info;
  61. }
  62. public final ItemInfo getItemInfo()
  63. {
  64. return _itemInfo;
  65. }
  66. public final int getEnchantLevel()
  67. {
  68. return _itemInfo != null ? _itemInfo.getEnchantLevel() : 0;
  69. }
  70. public final void setItemId(int itemId)
  71. {
  72. _itemId = itemId;
  73. }
  74. public final int getItemId()
  75. {
  76. return _itemId;
  77. }
  78. public final void setItemCount(long itemCount)
  79. {
  80. _itemCount = itemCount;
  81. }
  82. public final long getItemCount()
  83. {
  84. return _itemCount;
  85. }
  86. public final void setIsTaxIngredient(boolean isTaxIngredient)
  87. {
  88. _isTaxIngredient = isTaxIngredient;
  89. }
  90. public final boolean isTaxIngredient()
  91. {
  92. return _isTaxIngredient;
  93. }
  94. public final void setMaintainIngredient(boolean maintainIngredient)
  95. {
  96. _maintainIngredient = maintainIngredient;
  97. }
  98. public final boolean getMaintainIngredient()
  99. {
  100. return _maintainIngredient;
  101. }
  102. public final boolean isStackable()
  103. {
  104. return _template == null ? true : _template.isStackable();
  105. }
  106. public final boolean isArmorOrWeapon()
  107. {
  108. return _template == null ? false : (_template instanceof L2Armor) || (_template instanceof L2Weapon);
  109. }
  110. public final int getWeight()
  111. {
  112. return _template == null ? 0 : _template.getWeight();
  113. }
  114. }