Random refactors in Inventory

This commit is contained in:
Melledy
2023-10-05 03:12:25 -07:00
parent 604d1fe62d
commit 3bb7b59ea7
2 changed files with 8 additions and 5 deletions

View File

@@ -117,7 +117,7 @@ public class PlayerCommands {
} }
if (itemData.isEquippable()) { if (itemData.isEquippable()) {
List<GameItem> items = new LinkedList<>(); //List<GameItem> items = new LinkedList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
item = new GameItem(itemData); item = new GameItem(itemData);
//items.add(item); //items.add(item);

View File

@@ -102,7 +102,7 @@ public class Inventory extends BasePlayerManager {
GameItem result = putItem(item); GameItem result = putItem(item);
if (result != null) { if (result != null) {
// TODO Send packet (update) // Send packet (update)
getPlayer().sendPacket(new PacketPlayerSyncScNotify(item)); getPlayer().sendPacket(new PacketPlayerSyncScNotify(item));
return true; return true;
} }
@@ -129,7 +129,7 @@ public class Inventory extends BasePlayerManager {
return null; return null;
} }
// Duplicates cause problems // Duplicates cause problems
item.setCount(Math.max(item.getCount(), 1)); item.setCount(1);
// Adds to inventory // Adds to inventory
this.putItem(item, tab); this.putItem(item, tab);
// Set ownership and save to database // Set ownership and save to database
@@ -164,6 +164,9 @@ public class Inventory extends BasePlayerManager {
if (tab.getSize() >= tab.getMaxCapacity()) { if (tab.getSize() >= tab.getMaxCapacity()) {
return null; return null;
} }
// Make sure item count doesnt exceed stack limit
item.setCount(Math.min(item.getCount(), item.getExcel().getPileLimit()));
// Put item to inventory
this.putItem(item, tab); this.putItem(item, tab);
// Set ownership and save to db // Set ownership and save to db
item.save(); item.save();
@@ -263,10 +266,10 @@ public class Inventory extends BasePlayerManager {
} }
// Remove from inventory if less than 0 // Remove from inventory if less than 0
deleteItem(item, tab); deleteItem(item, tab);
// TODO Send packet (delete) // Send packet (delete)
getPlayer().sendPacket(new PacketPlayerSyncScNotify(item)); getPlayer().sendPacket(new PacketPlayerSyncScNotify(item));
} else { } else {
// TODO Send packet (update) // Send packet (update)
getPlayer().sendPacket(new PacketPlayerSyncScNotify(item)); getPlayer().sendPacket(new PacketPlayerSyncScNotify(item));
} }