Rename and clean up MapleInventoryType
This commit is contained in:
@@ -41,14 +41,14 @@ import java.util.concurrent.locks.Lock;
|
||||
*/
|
||||
public class Inventory implements Iterable<Item> {
|
||||
protected final Map<Short, Item> inventory;
|
||||
protected final MapleInventoryType type;
|
||||
protected final InventoryType type;
|
||||
protected final Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.INVENTORY, true);
|
||||
|
||||
protected MapleCharacter owner;
|
||||
protected byte slotLimit;
|
||||
protected boolean checked = false;
|
||||
|
||||
public Inventory(MapleCharacter mc, MapleInventoryType type, byte slotLimit) {
|
||||
public Inventory(MapleCharacter mc, InventoryType type, byte slotLimit) {
|
||||
this.owner = mc;
|
||||
this.inventory = new LinkedHashMap<>();
|
||||
this.type = type;
|
||||
@@ -56,11 +56,11 @@ public class Inventory implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public boolean isExtendableInventory() { // not sure about cash, basing this on the previous one.
|
||||
return !(type.equals(MapleInventoryType.UNDEFINED) || type.equals(MapleInventoryType.EQUIPPED) || type.equals(MapleInventoryType.CASH));
|
||||
return !(type.equals(InventoryType.UNDEFINED) || type.equals(InventoryType.EQUIPPED) || type.equals(InventoryType.CASH));
|
||||
}
|
||||
|
||||
public boolean isEquipInventory() {
|
||||
return type.equals(MapleInventoryType.EQUIP) || type.equals(MapleInventoryType.EQUIPPED);
|
||||
return type.equals(InventoryType.EQUIP) || type.equals(InventoryType.EQUIPPED);
|
||||
}
|
||||
|
||||
public byte getSlotLimit() {
|
||||
@@ -223,7 +223,7 @@ public class Inventory implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public void addItemFromDB(Item item) {
|
||||
if (item.getPosition() < 0 && !type.equals(MapleInventoryType.EQUIPPED)) {
|
||||
if (item.getPosition() < 0 && !type.equals(InventoryType.EQUIPPED)) {
|
||||
return;
|
||||
}
|
||||
addSlotFromDB(item.getPosition(), item);
|
||||
@@ -246,7 +246,7 @@ public class Inventory implements Iterable<Item> {
|
||||
inventory.put(dSlot, source);
|
||||
inventory.remove(sSlot);
|
||||
} else if (target.getItemId() == source.getItemId() && !ItemConstants.isRechargeable(source.getItemId()) && isSameOwner(source, target)) {
|
||||
if (type.getType() == MapleInventoryType.EQUIP.getType() || type.getType() == MapleInventoryType.CASH.getType()) {
|
||||
if (type.getType() == InventoryType.EQUIP.getType() || type.getType() == InventoryType.CASH.getType()) {
|
||||
swap(target, source);
|
||||
} else if (source.getQuantity() + target.getQuantity() > slotMax) {
|
||||
short rest = (short) ((source.getQuantity() + target.getQuantity()) - slotMax);
|
||||
@@ -420,11 +420,11 @@ public class Inventory implements Iterable<Item> {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkItemRestricted(List<Pair<Item, MapleInventoryType>> items) {
|
||||
private static boolean checkItemRestricted(List<Pair<Item, InventoryType>> items) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
// thanks Shavit for noticing set creation that would be only effective in rare situations
|
||||
for (Pair<Item, MapleInventoryType> p : items) {
|
||||
for (Pair<Item, InventoryType> p : items) {
|
||||
int itemid = p.getLeft().getItemId();
|
||||
if (ii.isPickupRestricted(itemid) && p.getLeft().getQuantity() > 1) {
|
||||
return false;
|
||||
@@ -439,7 +439,7 @@ public class Inventory implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public static boolean checkSpot(MapleCharacter chr, List<Item> items) {
|
||||
List<Pair<Item, MapleInventoryType>> listItems = new LinkedList<>();
|
||||
List<Pair<Item, InventoryType>> listItems = new LinkedList<>();
|
||||
for (Item item : items) {
|
||||
listItems.add(new Pair<>(item, item.getInventoryType()));
|
||||
}
|
||||
@@ -447,12 +447,12 @@ public class Inventory implements Iterable<Item> {
|
||||
return checkSpotsAndOwnership(chr, listItems);
|
||||
}
|
||||
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items) {
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, InventoryType>> items) {
|
||||
return checkSpots(chr, items, false);
|
||||
}
|
||||
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items, boolean useProofInv) {
|
||||
int invTypesSize = MapleInventoryType.values().length;
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, InventoryType>> items, boolean useProofInv) {
|
||||
int invTypesSize = InventoryType.values().length;
|
||||
List<Integer> zeroedList = new ArrayList<>(invTypesSize);
|
||||
for (byte i = 0; i < invTypesSize; i++) {
|
||||
zeroedList.add(0);
|
||||
@@ -461,7 +461,7 @@ public class Inventory implements Iterable<Item> {
|
||||
return checkSpots(chr, items, zeroedList, useProofInv);
|
||||
}
|
||||
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items, List<Integer> typesSlotsUsed, boolean useProofInv) {
|
||||
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, InventoryType>> items, List<Integer> typesSlotsUsed, boolean useProofInv) {
|
||||
// assumption: no "UNDEFINED" or "EQUIPPED" items shall be tested here, all counts are >= 0.
|
||||
|
||||
if (!checkItemRestricted(items)) {
|
||||
@@ -471,7 +471,7 @@ public class Inventory implements Iterable<Item> {
|
||||
Map<Integer, List<Integer>> rcvItems = new LinkedHashMap<>();
|
||||
Map<Integer, Byte> rcvTypes = new LinkedHashMap<>();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> item : items) {
|
||||
for (Pair<Item, InventoryType> item : items) {
|
||||
Integer itemId = item.left.getItemId();
|
||||
List<Integer> qty = rcvItems.get(itemId);
|
||||
|
||||
@@ -528,11 +528,11 @@ public class Inventory implements Iterable<Item> {
|
||||
return (itemId.longValue() << 32L) + fnvHash32(owner);
|
||||
}
|
||||
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items) {
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, InventoryType>> items) {
|
||||
return checkSpotsAndOwnership(chr, items, false);
|
||||
}
|
||||
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items, boolean useProofInv) {
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, InventoryType>> items, boolean useProofInv) {
|
||||
List<Integer> zeroedList = new ArrayList<>(5);
|
||||
for (byte i = 0; i < 5; i++) {
|
||||
zeroedList.add(0);
|
||||
@@ -541,7 +541,7 @@ public class Inventory implements Iterable<Item> {
|
||||
return checkSpotsAndOwnership(chr, items, zeroedList, useProofInv);
|
||||
}
|
||||
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items, List<Integer> typesSlotsUsed, boolean useProofInv) {
|
||||
public static boolean checkSpotsAndOwnership(MapleCharacter chr, List<Pair<Item, InventoryType>> items, List<Integer> typesSlotsUsed, boolean useProofInv) {
|
||||
//assumption: no "UNDEFINED" or "EQUIPPED" items shall be tested here, all counts are >= 0 and item list to be checked is a legal one.
|
||||
|
||||
if (!checkItemRestricted(items)) {
|
||||
@@ -552,7 +552,7 @@ public class Inventory implements Iterable<Item> {
|
||||
Map<Long, Byte> rcvTypes = new LinkedHashMap<>();
|
||||
Map<Long, String> rcvOwners = new LinkedHashMap<>();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> item : items) {
|
||||
for (Pair<Item, InventoryType> item : items) {
|
||||
Long itemHash = hashKey(item.left.getItemId(), item.left.getOwner());
|
||||
List<Integer> qty = rcvItems.get(itemHash);
|
||||
|
||||
@@ -597,7 +597,7 @@ public class Inventory implements Iterable<Item> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public MapleInventoryType getType() {
|
||||
public InventoryType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ public class Inventory implements Iterable<Item> {
|
||||
boolean isRing = false;
|
||||
Equip equip = null;
|
||||
for (Item item : list()) {
|
||||
if (item.getInventoryType().equals(MapleInventoryType.EQUIP)) {
|
||||
if (item.getInventoryType().equals(InventoryType.EQUIP)) {
|
||||
equip = (Equip) item;
|
||||
isRing = equip.getRingId() > -1;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import client.MapleCharacter;
|
||||
public class InventoryProof extends Inventory {
|
||||
|
||||
public InventoryProof(MapleCharacter mc) {
|
||||
super(mc, MapleInventoryType.CANHOLD, (byte) 0);
|
||||
super(mc, InventoryType.CANHOLD, (byte) 0);
|
||||
}
|
||||
|
||||
public void cloneContents(Inventory inv) {
|
||||
|
||||
@@ -24,7 +24,7 @@ package client.inventory;
|
||||
/**
|
||||
* @author Matze
|
||||
*/
|
||||
public enum MapleInventoryType {
|
||||
public enum InventoryType {
|
||||
UNDEFINED(0),
|
||||
EQUIP(1),
|
||||
USE(2),
|
||||
@@ -33,9 +33,10 @@ public enum MapleInventoryType {
|
||||
CASH(5),
|
||||
CANHOLD(6), //Proof-guard for inserting after removal checks
|
||||
EQUIPPED(-1); //Seems nexon screwed something when removing an item T_T
|
||||
|
||||
final byte type;
|
||||
|
||||
private MapleInventoryType(int type) {
|
||||
InventoryType(int type) {
|
||||
this.type = (byte) type;
|
||||
}
|
||||
|
||||
@@ -47,8 +48,8 @@ public enum MapleInventoryType {
|
||||
return (short) (2 << type);
|
||||
}
|
||||
|
||||
public static MapleInventoryType getByType(byte type) {
|
||||
for (MapleInventoryType l : MapleInventoryType.values()) {
|
||||
public static InventoryType getByType(byte type) {
|
||||
for (InventoryType l : InventoryType.values()) {
|
||||
if (l.getType() == type) {
|
||||
return l;
|
||||
}
|
||||
@@ -56,18 +57,14 @@ public enum MapleInventoryType {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MapleInventoryType getByWZName(String name) {
|
||||
if (name.equals("Install")) {
|
||||
return SETUP;
|
||||
} else if (name.equals("Consume")) {
|
||||
return USE;
|
||||
} else if (name.equals("Etc")) {
|
||||
return ETC;
|
||||
} else if (name.equals("Cash")) {
|
||||
return CASH;
|
||||
} else if (name.equals("Pet")) {
|
||||
return CASH;
|
||||
}
|
||||
return UNDEFINED;
|
||||
public static InventoryType getByWZName(String name) {
|
||||
return switch (name) {
|
||||
case "Install" -> SETUP;
|
||||
case "Consume" -> USE;
|
||||
case "Etc" -> ETC;
|
||||
case "Cash" -> CASH;
|
||||
case "Pet" -> CASH;
|
||||
default -> UNDEFINED;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package client.inventory;
|
||||
|
||||
import client.inventory.manipulator.MapleKarmaManipulator;
|
||||
import constants.inventory.ItemConstants;
|
||||
import server.MapleItemInformationProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import client.inventory.manipulator.MapleKarmaManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
|
||||
public class Item implements Comparable<Item> {
|
||||
|
||||
@@ -104,7 +105,7 @@ public class Item implements Comparable<Item> {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public MapleInventoryType getInventoryType() {
|
||||
public InventoryType getInventoryType() {
|
||||
return ItemConstants.getInventoryType(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,16 +66,16 @@ public enum ItemFactory {
|
||||
return value;
|
||||
}
|
||||
|
||||
public List<Pair<Item, MapleInventoryType>> loadItems(int id, boolean login) throws SQLException {
|
||||
public List<Pair<Item, InventoryType>> loadItems(int id, boolean login) throws SQLException {
|
||||
if(value != 6) return loadItemsCommon(id, login);
|
||||
else return loadItemsMerchant(id, login);
|
||||
}
|
||||
|
||||
public void saveItems(List<Pair<Item, MapleInventoryType>> items, int id, Connection con) throws SQLException {
|
||||
public void saveItems(List<Pair<Item, InventoryType>> items, int id, Connection con) throws SQLException {
|
||||
saveItems(items, null, id, con);
|
||||
}
|
||||
|
||||
public void saveItems(List<Pair<Item, MapleInventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException {
|
||||
public void saveItems(List<Pair<Item, InventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException {
|
||||
// thanks Arufonsu, MedicOP, BHB for pointing a "synchronized" bottleneck here
|
||||
|
||||
if(value != 6) saveItemsCommon(items, id, con);
|
||||
@@ -126,7 +126,7 @@ public enum ItemFactory {
|
||||
query.append("WHERE accountterm.`");
|
||||
query.append(isAccount ? "accountid" : "characterid");
|
||||
query.append("` = ?");
|
||||
query.append(login ? " AND `inventorytype` = " + MapleInventoryType.EQUIPPED.getType() : "");
|
||||
query.append(login ? " AND `inventorytype` = " + InventoryType.EQUIPPED.getType() : "");
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement(query.toString())) {
|
||||
@@ -144,8 +144,8 @@ public enum ItemFactory {
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<Pair<Item, MapleInventoryType>> loadItemsCommon(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, MapleInventoryType>> items = new ArrayList<>();
|
||||
private List<Pair<Item, InventoryType>> loadItemsCommon(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, InventoryType>> items = new ArrayList<>();
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
StringBuilder query = new StringBuilder();
|
||||
@@ -153,7 +153,7 @@ public enum ItemFactory {
|
||||
query.append(account ? "accountid" : "characterid").append("` = ?");
|
||||
|
||||
if (login) {
|
||||
query.append(" AND `inventorytype` = ").append(MapleInventoryType.EQUIPPED.getType());
|
||||
query.append(" AND `inventorytype` = ").append(InventoryType.EQUIPPED.getType());
|
||||
}
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement(query.toString())) {
|
||||
@@ -162,9 +162,9 @@ public enum ItemFactory {
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
MapleInventoryType mit = MapleInventoryType.getByType(rs.getByte("inventorytype"));
|
||||
InventoryType mit = InventoryType.getByType(rs.getByte("inventorytype"));
|
||||
|
||||
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
|
||||
if (mit.equals(InventoryType.EQUIP) || mit.equals(InventoryType.EQUIPPED)) {
|
||||
items.add(new Pair<>(loadEquipFromResultSet(rs), mit));
|
||||
} else {
|
||||
int petid = rs.getInt("petid");
|
||||
@@ -186,7 +186,7 @@ public enum ItemFactory {
|
||||
return items;
|
||||
}
|
||||
|
||||
private void saveItemsCommon(List<Pair<Item, MapleInventoryType>> items, int id, Connection con) throws SQLException {
|
||||
private void saveItemsCommon(List<Pair<Item, InventoryType>> items, int id, Connection con) throws SQLException {
|
||||
Lock lock = locks[id % lockCount];
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -202,9 +202,9 @@ public enum ItemFactory {
|
||||
|
||||
try (PreparedStatement psItem = con.prepareStatement("INSERT INTO `inventoryitems` VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
if (!items.isEmpty()) {
|
||||
for (Pair<Item, MapleInventoryType> pair : items) {
|
||||
for (Pair<Item, InventoryType> pair : items) {
|
||||
Item item = pair.getLeft();
|
||||
MapleInventoryType mit = pair.getRight();
|
||||
InventoryType mit = pair.getRight();
|
||||
psItem.setInt(1, value);
|
||||
psItem.setString(2, account ? null : String.valueOf(id));
|
||||
psItem.setString(3, account ? String.valueOf(id) : null);
|
||||
@@ -219,7 +219,7 @@ public enum ItemFactory {
|
||||
psItem.setString(12, item.getGiftFrom());
|
||||
psItem.executeUpdate();
|
||||
|
||||
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
|
||||
if (mit.equals(InventoryType.EQUIP) || mit.equals(InventoryType.EQUIPPED)) {
|
||||
try (PreparedStatement psEquip = con.prepareStatement("INSERT INTO `inventoryequipment` VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
|
||||
try (ResultSet rs = psItem.getGeneratedKeys()) {
|
||||
if (!rs.next()) {
|
||||
@@ -263,8 +263,8 @@ public enum ItemFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Pair<Item, MapleInventoryType>> loadItemsMerchant(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, MapleInventoryType>> items = new ArrayList<>();
|
||||
private List<Pair<Item, InventoryType>> loadItemsMerchant(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, InventoryType>> items = new ArrayList<>();
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
StringBuilder query = new StringBuilder();
|
||||
@@ -272,7 +272,7 @@ public enum ItemFactory {
|
||||
query.append(account ? "accountid" : "characterid").append("` = ?");
|
||||
|
||||
if (login) {
|
||||
query.append(" AND `inventorytype` = ").append(MapleInventoryType.EQUIPPED.getType());
|
||||
query.append(" AND `inventorytype` = ").append(InventoryType.EQUIPPED.getType());
|
||||
}
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement(query.toString())) {
|
||||
@@ -292,9 +292,9 @@ public enum ItemFactory {
|
||||
}
|
||||
}
|
||||
|
||||
MapleInventoryType mit = MapleInventoryType.getByType(rs.getByte("inventorytype"));
|
||||
InventoryType mit = InventoryType.getByType(rs.getByte("inventorytype"));
|
||||
|
||||
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
|
||||
if (mit.equals(InventoryType.EQUIP) || mit.equals(InventoryType.EQUIPPED)) {
|
||||
items.add(new Pair<>(loadEquipFromResultSet(rs), mit));
|
||||
} else {
|
||||
if (bundles > 0) {
|
||||
@@ -318,7 +318,7 @@ public enum ItemFactory {
|
||||
return items;
|
||||
}
|
||||
|
||||
private void saveItemsMerchant(List<Pair<Item, MapleInventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException {
|
||||
private void saveItemsMerchant(List<Pair<Item, InventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException {
|
||||
Lock lock = locks[id % lockCount];
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -338,10 +338,10 @@ public enum ItemFactory {
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Pair<Item, MapleInventoryType> pair : items) {
|
||||
for (Pair<Item, InventoryType> pair : items) {
|
||||
final Item item = pair.getLeft();
|
||||
final Short bundles = bundlesList.get(i);
|
||||
final MapleInventoryType mit = pair.getRight();
|
||||
final InventoryType mit = pair.getRight();
|
||||
i++;
|
||||
|
||||
final int genKey;
|
||||
@@ -379,7 +379,7 @@ public enum ItemFactory {
|
||||
}
|
||||
|
||||
// Equipment
|
||||
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
|
||||
if (mit.equals(InventoryType.EQUIP) || mit.equals(InventoryType.EQUIPPED)) {
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO `inventoryequipment` VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
|
||||
ps.setInt(1, genKey);
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ public class MaplePet extends Item {
|
||||
owner.getMap().broadcastMessage(PacketCreator.petFoodResponse(owner.getId(), slot, enjoyed, false));
|
||||
saveToDb();
|
||||
|
||||
Item petz = owner.getInventory(MapleInventoryType.CASH).getItem(getPosition());
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ public class MaplePet extends Item {
|
||||
this.petFlag |= flag.getValue();
|
||||
saveToDb();
|
||||
|
||||
Item petz = owner.getInventory(MapleInventoryType.CASH).getItem(getPosition());
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public class MaplePet extends Item {
|
||||
this.petFlag &= 0xFFFFFFFF ^ flag.getValue();
|
||||
saveToDb();
|
||||
|
||||
Item petz = owner.getInventory(MapleInventoryType.CASH).getItem(getPosition());
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MapleInventoryManipulator {
|
||||
|
||||
public static boolean addById(MapleClient c, int itemId, short quantity, String owner, int petid, short flag, long expiration) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(itemId);
|
||||
InventoryType type = ItemConstants.getInventoryType(itemId);
|
||||
|
||||
Inventory inv = chr.getInventory(type);
|
||||
inv.lockInventory();
|
||||
@@ -75,9 +75,9 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean addByIdInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, Inventory inv, int itemId, short quantity, String owner, int petid, short flag, long expiration) {
|
||||
private static boolean addByIdInternal(MapleClient c, MapleCharacter chr, InventoryType type, Inventory inv, int itemId, short quantity, String owner, int petid, short flag, long expiration) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
if (!type.equals(InventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, itemId);
|
||||
List<Item> existing = inv.listById(itemId);
|
||||
if (!ItemConstants.isRechargeable(itemId) && petid == -1) {
|
||||
@@ -167,7 +167,7 @@ public class MapleInventoryManipulator {
|
||||
|
||||
public static boolean addFromDrop(MapleClient c, Item item, boolean show, int petId) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MapleInventoryType type = item.getInventoryType();
|
||||
InventoryType type = item.getInventoryType();
|
||||
|
||||
Inventory inv = chr.getInventory(type);
|
||||
inv.lockInventory();
|
||||
@@ -178,7 +178,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean addFromDropInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, Inventory inv, Item item, boolean show, int petId) {
|
||||
private static boolean addFromDropInternal(MapleClient c, MapleCharacter chr, InventoryType type, Inventory inv, Item item, boolean show, int petId) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
int itemid = item.getItemId();
|
||||
if (ii.isPickupRestricted(itemid) && chr.haveItemWithId(itemid, true)) {
|
||||
@@ -188,7 +188,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
short quantity = item.getQuantity();
|
||||
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
if (!type.equals(InventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, itemid);
|
||||
List<Item> existing = inv.listById(itemid);
|
||||
if (!ItemConstants.isRechargeable(itemid) && petId == -1) {
|
||||
@@ -274,19 +274,19 @@ public class MapleInventoryManipulator {
|
||||
|
||||
public static boolean checkSpace(MapleClient c, int itemid, int quantity, String owner) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(itemid);
|
||||
InventoryType type = ItemConstants.getInventoryType(itemid);
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
Inventory inv = chr.getInventory(type);
|
||||
|
||||
if (ii.isPickupRestricted(itemid)) {
|
||||
if (haveItemWithId(inv, itemid)) {
|
||||
return false;
|
||||
} else if (ItemConstants.isEquipment(itemid) && haveItemWithId(chr.getInventory(MapleInventoryType.EQUIPPED), itemid)) {
|
||||
} else if (ItemConstants.isEquipment(itemid) && haveItemWithId(chr.getInventory(InventoryType.EQUIPPED), itemid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
if (!type.equals(InventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, itemid);
|
||||
List<Item> existing = inv.listById(itemid);
|
||||
|
||||
@@ -329,19 +329,19 @@ public class MapleInventoryManipulator {
|
||||
int returnValue;
|
||||
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
MapleInventoryType type = !useProofInv ? ItemConstants.getInventoryType(itemid) : MapleInventoryType.CANHOLD;
|
||||
InventoryType type = !useProofInv ? ItemConstants.getInventoryType(itemid) : InventoryType.CANHOLD;
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
Inventory inv = chr.getInventory(type);
|
||||
|
||||
if (ii.isPickupRestricted(itemid)) {
|
||||
if (haveItemWithId(inv, itemid)) {
|
||||
return 0;
|
||||
} else if (ItemConstants.isEquipment(itemid) && haveItemWithId(chr.getInventory(MapleInventoryType.EQUIPPED), itemid)) {
|
||||
} else if (ItemConstants.isEquipment(itemid) && haveItemWithId(chr.getInventory(InventoryType.EQUIPPED), itemid)) {
|
||||
return 0; // thanks Captain & Aika & Vcoc for pointing out inventory checkup on player trades missing out one-of-a-kind items.
|
||||
}
|
||||
}
|
||||
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
if (!type.equals(InventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, itemid);
|
||||
final int numSlotsNeeded;
|
||||
|
||||
@@ -383,17 +383,17 @@ public class MapleInventoryManipulator {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public static void removeFromSlot(MapleClient c, MapleInventoryType type, short slot, short quantity, boolean fromDrop) {
|
||||
public static void removeFromSlot(MapleClient c, InventoryType type, short slot, short quantity, boolean fromDrop) {
|
||||
removeFromSlot(c, type, slot, quantity, fromDrop, false);
|
||||
}
|
||||
|
||||
public static void removeFromSlot(MapleClient c, MapleInventoryType type, short slot, short quantity, boolean fromDrop, boolean consume) {
|
||||
public static void removeFromSlot(MapleClient c, InventoryType type, short slot, short quantity, boolean fromDrop, boolean consume) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
Inventory inv = chr.getInventory(type);
|
||||
Item item = inv.getItem(slot);
|
||||
boolean allowZero = consume && ItemConstants.isRechargeable(item.getItemId());
|
||||
|
||||
if(type == MapleInventoryType.EQUIPPED) {
|
||||
if(type == InventoryType.EQUIPPED) {
|
||||
inv.lockInventory();
|
||||
try {
|
||||
chr.unequippedItem((Equip) item);
|
||||
@@ -413,14 +413,14 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
|
||||
inv.removeItem(slot, quantity, allowZero);
|
||||
if(type != MapleInventoryType.CANHOLD) {
|
||||
if(type != InventoryType.CANHOLD) {
|
||||
announceModifyInventory(c, item, fromDrop, allowZero);
|
||||
}
|
||||
|
||||
// thanks Robin Schulz for noticing pet issues when moving pets out of inventory
|
||||
} else {
|
||||
inv.removeItem(slot, quantity, allowZero);
|
||||
if(type != MapleInventoryType.CANHOLD) {
|
||||
if(type != InventoryType.CANHOLD) {
|
||||
announceModifyInventory(c, item, fromDrop, allowZero);
|
||||
}
|
||||
}
|
||||
@@ -435,13 +435,13 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeById(MapleClient c, MapleInventoryType type, int itemId, int quantity, boolean fromDrop, boolean consume) {
|
||||
public static void removeById(MapleClient c, InventoryType type, int itemId, int quantity, boolean fromDrop, boolean consume) {
|
||||
int removeQuantity = quantity;
|
||||
Inventory inv = c.getPlayer().getInventory(type);
|
||||
int slotLimit = type == MapleInventoryType.EQUIPPED ? 128 : inv.getSlotLimit();
|
||||
int slotLimit = type == InventoryType.EQUIPPED ? 128 : inv.getSlotLimit();
|
||||
|
||||
for (short i = 0; i <= slotLimit; i++) {
|
||||
Item item = inv.getItem((short) (type == MapleInventoryType.EQUIPPED ? -i : i));
|
||||
Item item = inv.getItem((short) (type == InventoryType.EQUIPPED ? -i : i));
|
||||
if (item != null) {
|
||||
if (item.getItemId() == itemId || item.getCashId() == itemId) {
|
||||
if (removeQuantity <= item.getQuantity()) {
|
||||
@@ -455,7 +455,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removeQuantity > 0 && type != MapleInventoryType.CANHOLD) {
|
||||
if (removeQuantity > 0 && type != InventoryType.CANHOLD) {
|
||||
throw new RuntimeException("[Hack] Not enough items available of Item:" + itemId + ", Quantity (After Quantity/Over Current Quantity): " + (quantity - removeQuantity) + "/" + quantity);
|
||||
}
|
||||
}
|
||||
@@ -464,7 +464,7 @@ public class MapleInventoryManipulator {
|
||||
return source.getOwner().equals(target.getOwner());
|
||||
}
|
||||
|
||||
public static void move(MapleClient c, MapleInventoryType type, short src, short dst) {
|
||||
public static void move(MapleClient c, InventoryType type, short src, short dst) {
|
||||
Inventory inv = c.getPlayer().getInventory(type);
|
||||
|
||||
if (src < 0 || dst < 0) {
|
||||
@@ -487,7 +487,7 @@ public class MapleInventoryManipulator {
|
||||
short slotMax = ii.getSlotMax(c, source.getItemId());
|
||||
inv.move(src, dst, slotMax);
|
||||
final List<ModifyInventory> mods = new ArrayList<>();
|
||||
if (!(type.equals(MapleInventoryType.EQUIP) || type.equals(MapleInventoryType.CASH)) && initialTarget != null && initialTarget.getItemId() == source.getItemId() && !ItemConstants.isRechargeable(source.getItemId()) && isSameOwner(source, initialTarget)) {
|
||||
if (!(type.equals(InventoryType.EQUIP) || type.equals(InventoryType.CASH)) && initialTarget != null && initialTarget.getItemId() == source.getItemId() && !ItemConstants.isRechargeable(source.getItemId()) && isSameOwner(source, initialTarget)) {
|
||||
if ((olddstQ + oldsrcQ) > slotMax) {
|
||||
mods.add(new ModifyInventory(1, source));
|
||||
mods.add(new ModifyInventory(1, initialTarget));
|
||||
@@ -505,8 +505,8 @@ public class MapleInventoryManipulator {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
Inventory eqpInv = chr.getInventory(MapleInventoryType.EQUIP);
|
||||
Inventory eqpdInv = chr.getInventory(MapleInventoryType.EQUIPPED);
|
||||
Inventory eqpInv = chr.getInventory(InventoryType.EQUIP);
|
||||
Inventory eqpdInv = chr.getInventory(InventoryType.EQUIPPED);
|
||||
|
||||
Equip source = (Equip) eqpInv.getItem(src);
|
||||
if (source == null || !ii.canWearEquipment(chr, source, dst)) {
|
||||
@@ -620,8 +620,8 @@ public class MapleInventoryManipulator {
|
||||
|
||||
public static void unequip(MapleClient c, short src, short dst) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
Inventory eqpInv = chr.getInventory(MapleInventoryType.EQUIP);
|
||||
Inventory eqpdInv = chr.getInventory(MapleInventoryType.EQUIPPED);
|
||||
Inventory eqpInv = chr.getInventory(InventoryType.EQUIP);
|
||||
Inventory eqpdInv = chr.getInventory(InventoryType.EQUIPPED);
|
||||
|
||||
Equip source = (Equip) eqpdInv.getItem(src);
|
||||
Equip target = (Equip) eqpInv.getItem(dst);
|
||||
@@ -679,9 +679,9 @@ public class MapleInventoryManipulator {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void drop(MapleClient c, MapleInventoryType type, short src, short quantity) {
|
||||
public static void drop(MapleClient c, InventoryType type, short src, short quantity) {
|
||||
if (src < 0) {
|
||||
type = MapleInventoryType.EQUIPPED;
|
||||
type = InventoryType.EQUIPPED;
|
||||
}
|
||||
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
@@ -730,7 +730,7 @@ public class MapleInventoryManipulator {
|
||||
map.spawnItemDrop(chr, chr, target, dropPos, true, true);
|
||||
}
|
||||
} else {
|
||||
if (type == MapleInventoryType.EQUIPPED) {
|
||||
if (type == InventoryType.EQUIPPED) {
|
||||
inv.lockInventory();
|
||||
try {
|
||||
chr.unequippedItem((Equip) source);
|
||||
|
||||
Reference in New Issue
Block a user