Last active
February 3, 2026 02:59
-
-
Save EastArctica/755ee6a463ef6393741bd645c461d83e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param item An ItemStackHelper from the /orders page. This item must have a lore as follows: | |
| * Bones | |
| * $130.12 each | |
| * | |
| * 2.14M/5M Delivered | |
| * $279.41M/$650.6M Paid | |
| * | |
| * Click to deliver ExampleUsername Bones | |
| * 6d 21h 24m Until Order expires | |
| */ | |
| function getOrderInfo(item: ItemStackHelper) { | |
| const lore = item.getLore(); | |
| const info = { | |
| itemName: '', | |
| priceEach: 0, | |
| delivered: { current: 0, total: 0 }, | |
| paid: { current: 0, total: 0 }, | |
| username: '', | |
| timeRemaining: '', | |
| }; | |
| for (const line of lore) { | |
| const text = line.getString(); | |
| // Price each: $130.12 each | |
| const priceMatch = text.match(/^\$([0-9.]+) each$/); | |
| if (priceMatch) { | |
| info.priceEach = parseFloat(priceMatch[1]); | |
| continue; | |
| } | |
| // Delivered: 2.14M/5M Delivered | |
| const deliveredMatch = text.match(/^([0-9.]+[KMB]?)\/([0-9.]+[KMB]?) Delivered$/); | |
| if (deliveredMatch) { | |
| info.delivered.current = parseAmount(deliveredMatch[1]); | |
| info.delivered.total = parseAmount(deliveredMatch[2]); | |
| continue; | |
| } | |
| // Paid: $279.41M/$650.6M Paid | |
| const paidMatch = text.match(/^\$([0-9.]+[KMB]?)\/\$([0-9.]+[KMB]?) Paid$/); | |
| if (paidMatch) { | |
| info.paid.current = parseAmount(paidMatch[1]); | |
| info.paid.total = parseAmount(paidMatch[2]); | |
| continue; | |
| } | |
| // Click to deliver: Click to deliver ExampleUsername Bones | |
| const deliverMatch = text.match(/^Click to deliver (\w+) (.+)$/); | |
| if (deliverMatch) { | |
| info.username = deliverMatch[1]; | |
| info.itemName = deliverMatch[2]; | |
| continue; | |
| } | |
| // Time remaining: 6d 21h 24m Until Order expires | |
| const timeMatch = text.match(/^(.+) Until Order expires$/); | |
| if (timeMatch) { | |
| info.timeRemaining = timeMatch[1]; | |
| } | |
| } | |
| return info; | |
| } | |
| function parseAmount(amount: string): number { | |
| const multipliers: Record<string, number> = { K: 1000, M: 1_000_000, B: 1_000_000_000 }; | |
| const match = amount.match(/^([0-9.]+)([KMB]?)$/); | |
| if (!match) return 0; | |
| const value = parseFloat(match[1]); | |
| const suffix = match[2]; | |
| return suffix ? value * multipliers[suffix] : value; | |
| } | |
| function getBoneSlots(...containers: InvMapType.All[]): number[] { | |
| return inv() | |
| .getSlots(...containers) | |
| .filter((slot) => inv().getSlot(slot).getItemId() === 'minecraft:bone'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment