Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6d376a2f9 | ||
|
|
cb75e2bca7 |
No files matched your search
@@ -8,7 +8,7 @@
|
|||||||
<groupId>com.rsscripting</groupId>
|
<groupId>com.rsscripting</groupId>
|
||||||
<artifactId>RS-Warehouse</artifactId>
|
<artifactId>RS-Warehouse</artifactId>
|
||||||
<name>RS-Warehouse</name>
|
<name>RS-Warehouse</name>
|
||||||
<version>1.0.0</version>
|
<version>1.2.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
int highestAssignedPage = -1;
|
int highestAssignedPage = -1;
|
||||||
int unassigned = 0;
|
int unassigned = 0;
|
||||||
|
int lastPageHighestSlot = 8;
|
||||||
|
|
||||||
for (WarehouseItem item : items) {
|
for (WarehouseItem item : items) {
|
||||||
|
|
||||||
@@ -46,52 +47,52 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int consumed = 0;
|
if (highestAssignedPage < 0) {
|
||||||
|
|
||||||
for (int assignedPage = 0;
|
int pages =
|
||||||
assignedPage <= highestAssignedPage;
|
(unassigned + 44) / 45;
|
||||||
assignedPage++) {
|
|
||||||
|
|
||||||
int highestSlot = 8;
|
return Math.max(
|
||||||
|
0,
|
||||||
for (WarehouseItem item : items) {
|
pages - 1
|
||||||
|
);
|
||||||
if (
|
|
||||||
item.page() != null
|
|
||||||
&&
|
|
||||||
item.slot() != null
|
|
||||||
&&
|
|
||||||
item.page() == assignedPage + 1
|
|
||||||
) {
|
|
||||||
|
|
||||||
highestSlot =
|
|
||||||
Math.max(
|
|
||||||
highestSlot,
|
|
||||||
item.slot()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
consumed +=
|
|
||||||
Math.max(
|
|
||||||
0,
|
|
||||||
53 - highestSlot
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consumed =
|
for (WarehouseItem item : items) {
|
||||||
Math.min(
|
|
||||||
consumed,
|
if (
|
||||||
unassigned
|
item.page() != null
|
||||||
|
&&
|
||||||
|
item.slot() != null
|
||||||
|
&&
|
||||||
|
item.page() == highestAssignedPage + 1
|
||||||
|
) {
|
||||||
|
|
||||||
|
lastPageHighestSlot =
|
||||||
|
Math.max(
|
||||||
|
lastPageHighestSlot,
|
||||||
|
item.slot()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int availableOnLastAssignedPage =
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
53 - lastPageHighestSlot
|
||||||
);
|
);
|
||||||
|
|
||||||
unassigned -= consumed;
|
int remainingUnassigned =
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
unassigned - availableOnLastAssignedPage
|
||||||
|
);
|
||||||
|
|
||||||
int overflowPages =
|
int overflowPages =
|
||||||
(unassigned + 44) / 45;
|
(remainingUnassigned + 44) / 45;
|
||||||
|
|
||||||
return Math.max(
|
return Math.max(
|
||||||
0,
|
0,
|
||||||
@@ -175,59 +176,27 @@ public class ItemsPagination {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out how many unassigned items have
|
* Unassigned items begin only on the last assigned page.
|
||||||
* already been consumed by previous assigned pages.
|
|
||||||
*/
|
*/
|
||||||
int consumed = 0;
|
if (page == highestAssignedPage) {
|
||||||
|
|
||||||
for (int previousPage = 0;
|
int remainingSlots =
|
||||||
previousPage < page;
|
|
||||||
previousPage++) {
|
|
||||||
|
|
||||||
int previousHighestSlot = 8;
|
|
||||||
|
|
||||||
for (WarehouseItem item : assigned) {
|
|
||||||
|
|
||||||
if (item.page() == (previousPage + 1)) {
|
|
||||||
|
|
||||||
previousHighestSlot =
|
|
||||||
Math.max(
|
|
||||||
previousHighestSlot,
|
|
||||||
item.slot()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
consumed +=
|
|
||||||
Math.max(
|
Math.max(
|
||||||
0,
|
0,
|
||||||
53 - previousHighestSlot
|
53 - highestSlot
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
for (int i = 0;
|
||||||
|
i < remainingSlots && i < unassigned.size();
|
||||||
|
i++) {
|
||||||
|
|
||||||
int remainingSlots =
|
results.add(
|
||||||
Math.max(
|
unassigned.get(
|
||||||
0,
|
i
|
||||||
53 - highestSlot
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
while (
|
}
|
||||||
remainingSlots > 0
|
|
||||||
&&
|
|
||||||
consumed < unassigned.size()
|
|
||||||
) {
|
|
||||||
|
|
||||||
results.add(
|
|
||||||
unassigned.get(
|
|
||||||
consumed
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
consumed++;
|
|
||||||
remainingSlots--;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,46 +204,37 @@ public class ItemsPagination {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int consumed = 0;
|
/*
|
||||||
|
* Overflow pages contain only unassigned items.
|
||||||
|
*/
|
||||||
|
int lastPageHighestSlot = 8;
|
||||||
|
|
||||||
for (int assignedPage = 0;
|
for (WarehouseItem item : assigned) {
|
||||||
assignedPage <= highestAssignedPage;
|
|
||||||
assignedPage++) {
|
|
||||||
|
|
||||||
int highestSlot = 8;
|
if (item.page() == highestAssignedPage + 1) {
|
||||||
|
|
||||||
for (WarehouseItem item : assigned) {
|
lastPageHighestSlot =
|
||||||
|
Math.max(
|
||||||
if (item.page() == assignedPage + 1) {
|
lastPageHighestSlot,
|
||||||
|
item.slot()
|
||||||
highestSlot =
|
);
|
||||||
Math.max(
|
|
||||||
highestSlot,
|
|
||||||
item.slot()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consumed +=
|
|
||||||
Math.max(
|
|
||||||
0,
|
|
||||||
53 - highestSlot
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int consumed =
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
53 - lastPageHighestSlot
|
||||||
|
);
|
||||||
|
|
||||||
consumed =
|
consumed =
|
||||||
Math.min(
|
Math.min(
|
||||||
consumed,
|
consumed,
|
||||||
unassigned.size()
|
unassigned.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* Overflow pages
|
|
||||||
*/
|
|
||||||
|
|
||||||
int overflowPage =
|
int overflowPage =
|
||||||
page
|
page
|
||||||
- highestAssignedPage
|
- highestAssignedPage
|
||||||
|
|||||||
+2
-2
@@ -310,8 +310,8 @@ public class EnchantedVariantsTransactionMenuListener
|
|||||||
|
|
||||||
EnchantedVariantsTransactionMenu.open(
|
EnchantedVariantsTransactionMenu.open(
|
||||||
player,
|
player,
|
||||||
warehouseItemId,
|
enchantedVariantId,
|
||||||
0
|
amount
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user