mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-15 14:54:43 +01:00
Random refactors in Inventory
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user