Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Apr 4, 2023
1 parent 10fa575 commit c82c34f
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/core/plugins/core-inventory/server/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,42 @@ const Internal = {
return;
}

// Check Storage Capacity
const maxWeight = openStoragesWeight[player.id];
let itemsToCheck: Array<StoredItem>;

if (info.startType === 'custom') {
const maxWeight = openStoragesWeight[player.id];
if (Athena.systems.inventory.weight.isWeightExceeded([complexSwap.from], maxWeight)) {
itemsToCheck = complexSwap.from;

if (Athena.systems.inventory.weight.isWeightExceeded([complexSwap.to])) {
InventoryView.storage.resync(player);
return;
}

openStorages[player.id] = complexSwap.from;
} else {
await Athena.document.character.set(player, info.startType, complexSwap.from);
}

if (info.endType === 'custom') {
const maxWeight = openStoragesWeight[player.id];
if (Athena.systems.inventory.weight.isWeightExceeded([complexSwap.to], maxWeight)) {
itemsToCheck = complexSwap.to;

if (Athena.systems.inventory.weight.isWeightExceeded([complexSwap.from])) {
InventoryView.storage.resync(player);
return;
}
}

const isWeightExceeded = Athena.systems.inventory.weight.isWeightExceeded([itemsToCheck], maxWeight);
if (isWeightExceeded) {
InventoryView.storage.resync(player);
return;
}

// Assign Data
if (info.startType === 'custom') {
openStorages[player.id] = complexSwap.from;
} else {
await Athena.document.character.set(player, info.startType, complexSwap.from);
}

if (info.endType === 'custom') {
openStorages[player.id] = complexSwap.to;
} else {
await Athena.document.character.set(player, info.endType, complexSwap.to);
Expand Down

0 comments on commit c82c34f

Please sign in to comment.