mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-15 06:45:04 +01:00
Fix materials not being incremented properly
This commit is contained in:
@@ -103,7 +103,7 @@ public class Inventory extends BasePlayerManager {
|
|||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
// Send packet (update)
|
// Send packet (update)
|
||||||
getPlayer().sendPacket(new PacketPlayerSyncScNotify(item));
|
getPlayer().sendPacket(new PacketPlayerSyncScNotify(result));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,30 +160,27 @@ public class Inventory extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case Material:
|
case Material:
|
||||||
switch (item.getExcel().getItemSubType()) {
|
if (tab == null) {
|
||||||
default:
|
return null;
|
||||||
if (tab == null) {
|
}
|
||||||
|
|
||||||
|
GameItem existingItem = tab.getItemById(item.getItemId());
|
||||||
|
|
||||||
|
if (existingItem == null) {
|
||||||
|
// Item type didnt exist before, we will add it to main inventory map if there is enough space
|
||||||
|
if (tab.getSize() >= tab.getMaxCapacity()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
GameItem existingItem = tab.getItemById(item.getItemId());
|
// Put item to inventory
|
||||||
if (existingItem == null) {
|
this.putItem(item, tab);
|
||||||
// Item type didnt exist before, we will add it to main inventory map if there is enough space
|
// Set ownership and save to db
|
||||||
if (tab.getSize() >= tab.getMaxCapacity()) {
|
item.save();
|
||||||
return null;
|
return item;
|
||||||
}
|
} else {
|
||||||
// Make sure item count doesnt exceed stack limit
|
// Add count
|
||||||
item.setCount(Math.min(item.getCount(), item.getExcel().getPileLimit()));
|
existingItem.setCount(Math.min(existingItem.getCount() + item.getCount(), item.getExcel().getPileLimit()));
|
||||||
// Put item to inventory
|
existingItem.save();
|
||||||
this.putItem(item, tab);
|
return existingItem;
|
||||||
// Set ownership and save to db
|
|
||||||
item.save();
|
|
||||||
return item;
|
|
||||||
} else {
|
|
||||||
// Add count
|
|
||||||
existingItem.setCount(Math.min(existingItem.getCount() + item.getCount(), item.getExcel().getPileLimit()));
|
|
||||||
existingItem.save();
|
|
||||||
return existingItem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user