Ethan Huynh

Develop a backpack plugin featuring a command system with the following commands in order: /storage list, /storage create {name} {slot #s}, /storage set {name} {item id}, /storage give {player} {name}, and /storage delete {name}. When a player right-clicks the backpack, it opens a chest interface where items can be dropped and their data is preserved; other players can also interact with its contents while the backpack item remains equipped in the offhand. Address potential glitches by ensuring that right-clicking or moving the backpack item does not create duplicates, maintaining a smooth user experience.

Kodari AI
KodariOct 30 at 1:27 am 1
BackpackStorageSystem
Creates a backpack plugin with a command system including /storage list, create, set, give, and delete. Players right-click a backpack item to open a chest interface preserving item data, while other players can interact with contents. The backpack remains in the offhand, with duplicate prevention mechanisms ensuring smooth item handling.
  1. Add a single Skript file for the /storage command system and persistent backpack contents.

  2. Prevent concurrent opens and backpack-item movement/nesting while a backpack is open.

Place storage.sk in plugins/Skript/scripts/, then run /sk reload storage. Create a template, set its item type, and give it to a player; templates require storage.admin. Backpack contents persist across restarts, and the same backpack cannot be opened by multiple players at once.

Ethan Huynh

lets change to wear instead of right click while holding it, only right click in the inventory to open it

Kodari AI
KodariOct 30 at 1:33 am 1

Plan:

  1. Remove world right-click opening and open backpacks from an inventory right-click instead.

  2. Update the backpack instructions while preserving the existing inventory lock and item protections.

Backpacks now open only when right-clicked in an inventory; world right-click no longer opens them. The item lore now says to equip it in the offhand and right-click it in an inventory. Reload with /sk reload storage.

Ethan Huynh

instead of right-clicking when holding it, only right click in the inventory to open it

Kodari AI
KodariOct 30 at 1:34 am 1

Now the backpack opens only when you right-click it in your own inventory—not by right-clicking while holding it or by clicking it in another inventory. Reload with /sk reload storage.

Ethan Huynh

rename the new file

Kodari AI
KodariOct 30 at 1:36 am 1

Renamed storage.sk to backpack.sk. Reload it with /sk reload backpack.

Ethan Huynh

e

Kodari AI
KodariOct 30 at 1:38 am 1

The generation was stopped before any content could be produced.

Ethan Huynh

line 35: cant understand this considition 'argument 2 is not set or argument 3 is not set' line: if argument 2 is not set or argument 3 is not set: line 67: cant understand this considition 'argument 2 is not set or argument 3 is not set' line: if argument 2 is not set or argument 3 is not set: line 82: cant understand this considition 'argument 2 is not set or argument 3 is not set' line: if argument 2 is not set or argument 3 is not set:

encountered 3 errors while reloading config, aliases and all skripts

Kodari AI
KodariOct 30 at 1:40 am 1

The parser error came from Skript not accepting or between those argument checks. I split each into separate checks. Reload with /sk reload backpack.

Ethan Huynh

right-click in inventory does not work

Kodari AI
KodariOct 30 at 1:42 am 1

Fixed the inventory-click handler: it no longer rejects the click based on which inventory section was clicked, and it records the open backpack after opening its GUI to avoid the initial close event clearing its state. Right-click the backpack in an inventory to open it; world right-clicks still won’t open it. Reload with /sk reload backpack.

Ethan Huynh

add right click while holding

Kodari AI
KodariOct 30 at 1:43 am 1

Plan:

  1. Add a world right-click handler for backpack items while keeping inventory right-click support.

  2. Reuse the existing lock checks so duplicate hand events cannot open the same backpack twice.

Added right-click-to-open while holding the backpack; right-clicking it in your inventory still works. The existing lock prevents duplicate opens. Reload with /sk reload backpack.

Ethan Huynh

add left click in inventory and remove right click while holding

Kodari AI
KodariOct 30 at 1:44 am 1

Plan:

  1. Allow both left- and right-clicks on backpack items in inventories.

  2. Remove the held-item right-click opening handler.

Backpacks now open with either a left- or right-click in an inventory. Right-clicking while holding one no longer opens it. Reload with /sk reload backpack.

Ethan Huynh

it does not work, does right click while holding have to be on for clicking in inventory gui works

Kodari AI
KodariOct 30 at 1:45 am 1

No. Right-clicking while holding is a separate interaction and does not need to be enabled for inventory clicks. backpack.sk handles opening through on inventory click; it currently has no held-item right-click handler.

If inventory clicks still don’t open it, send the output from /sk reload backpack so I can fix the actual trigger issue.

Ethan Huynh

[Skript] Reloading backpack.sk... [01:46:45 INFO]: Line 14: (backpack.sk) [01:46:45 INFO]: [Deprecated] The 'permission message' entry has been deprecated for removal in a future release. Commands that a player does not have permission to execute are no longer sent to their client. [01:46:45 INFO]:

Line: command /storage [<text>] [<text>] [<text>]: [01:46:45 INFO]: [01:46:45 INFO]: [Skript] Successfully reloaded backpack.sk. (91m)

Kodari AI
KodariOct 30 at 1:47 am 1

The script reloaded successfully. The permission message line is only a deprecation warning and does not prevent inventory clicks from working.

That log doesn’t show whether the click handler is detecting the backpack. Try clicking the backpack item in your player inventory; if it still doesn’t open, tell me which inventory it’s in and whether you’re clicking the backpack itself or its offhand slot.

Ethan Huynh

when the player presses E to open the inventory i want them to click either left or right click to open the chest. But when i do so, nothing happens. The right click while holding works but thats not what im looking for

Kodari AI
KodariOct 30 at 1:50 am 1

I’ll keep backpack opening limited to inventory clicks and delay opening the chest by one tick, while reserving the backpack during that delay to prevent duplicate opens.

Updated backpack.sk so left- or right-clicking a backpack in the inventory opens its chest on the next tick. The backpack is locked during that delay to prevent duplicate opens. Reload with /sk reload backpack.

Ethan Huynh

please readd the right-click while holding function and lets remove the left/right click in inventory function from the skript so the file is less cluttered

Kodari AI
KodariOct 30 at 1:51 am 1

Plan:

  1. Remove the inventory-click opener and move its backpack-opening logic to right-click while holding the backpack.

  2. Keep the inventory-click protection that prevents moving backpack items while one is open.

Moved backpack opening to right-clicking while holding it and removed the inventory-click opener. The inventory-click protection remains to prevent moving backpack items while a backpack is open. Reload with /sk reload backpack.

Ethan Huynh

Please add a function where if a player picks up an unclaimed storage, that player claims it and a lore is added that says: {player}'s {name}

Kodari AI
KodariOct 30 at 1:58 am 1
  1. Track the first player to pick up each unclaimed backpack by its unique ID.

  2. Add a lore line in the format “Player’s Storage Name” and clear claim data when that storage template is deleted.

Added first-pickup claiming to backpack.sk: the first player to pick up an unclaimed backpack is recorded, and the lore gains Player's Storage Name. Claim data is also cleared when its storage template is deleted.

Reload with /sk reload backpack.

Ethan Huynh

[01:58:35 INFO]: [Skript] Reloading backpack.sk... [01:58:35 INFO]: Line 14: (backpack.sk) [01:58:35 INFO]: [Deprecated] The 'permission message' entry has been deprecated for removal in a future release. Commands that a player does not have permission to execute are no longer sent to their client. [01:58:35 INFO]:

Line: command /storage [<text>] [<text>] [<text>]: [01:58:35 INFO]: [01:58:35 INFO]: Line 130: (backpack.sk) [01:58:35 INFO]:

There's no loop that matches 'loop-value' [01:58:35 INFO]:

Line: delete {storage.owner::%loop-value%} [01:58:35 INFO]: [01:58:35 INFO]: [Skript] Encountered 1 error while reloading backpack.sk! (148ms)

Kodari AI
KodariOct 30 at 1:59 am 1

Fixed the indentation: deleting {storage.owner::%loop-value%} now happens inside the loop over issued backpacks. Reload with /sk reload backpack.

Ethan Huynh

and when a storage is deleted, do not make the storage invalid, let players keep whatever is in there. Also add a storage view command that sees how many storages they have and access them

Kodari AI
KodariOct 30 at 2:05 am 1

Plan:

  1. Make deleting a storage template leave already-issued backpacks usable with their contents intact.

  2. Add a storage-view command that lists a player’s backpacks and lets them open one.

Updated backpack.sk: deleting a template now leaves issued backpacks and their contents intact. Players can use /storage view to see their claimed backpacks and /storage view <number> to open one. Storage management commands still require storage.admin.

Reload with /sk reload backpack.

Ethan Huynh

make the storage view command: /storage {player} #this opens a gui with the storage name and its assigned item set. admins can right-click and view it and add or remove items

Kodari AI
KodariOct 30 at 2:09 am 1

Plan:

  1. Replace /storage view with admin-only /storage <player> listing that player’s claimed storages.

  2. Show each storage’s name and assigned item; right-click an entry to open and edit its contents.

  3. Keep inventory changes saved through the existing backpack close handler.

Updated backpack.sk: admins can use /storage <player> to open a GUI listing that online player’s claimed storages. Each entry shows the storage name and assigned item; right-click an entry to open and edit its contents. Changes save when the storage GUI closes.

Reload with /sk reload backpack.

Ethan Huynh

when doing the command. it says a player has no claimed storage despite having one with no attempt to open a gui that views available storage and the permission to click and open its inventory

Kodari AI
KodariOct 30 at 2:12 am 1
  1. Claim storages for the recipient when /storage give creates them, since directly giving an item does not trigger pickup.

  2. On /storage <player>, recognize and claim older unclaimed storage items already in that player’s inventory so the admin GUI can find them.

Fixed /storage <player> not finding storages given directly: /storage give now assigns ownership immediately, and the command claims older unclaimed backpacks found in that player’s inventory. The GUI should now list them; admins with storage.admin can right-click a listed storage to view and edit it.

Reload with /sk reload backpack.

Ethan Huynh

lets remove the storage view function. and add when a player picks up another players claimed storage. They claim ownership and the lore changes to their name

Kodari AI
KodariOct 30 at 2:17 am 1
  1. Remove the /storage <player> view GUI and its click-handling code.

  2. Make picking up another player’s claimed storage transfer ownership and update its lore.

Removed the /storage <player> admin view GUI and its click handler. Picking up any storage now assigns it to the player and updates the ownership lore, replacing the previous owner line.

Reload with /sk reload backpack.

Ethan Huynh

/storage {player}. Checks if player has storage. Opens Chest GUI. If have storage, display the item set and its name per storage claimed. If not have storage, show an empty inventory

Kodari AI
KodariOct 30 at 2:25 am 1
  1. Add /storage <player> for admins, showing each storage’s configured item and name.

  2. Open the selected storage when clicked; show an empty chest GUI when the player has none.

Added /storage <player> for admins with storage.admin. It opens a chest GUI showing that player’s claimed storages by assigned item and storage name; clicking an entry opens that storage’s inventory. If they have none, the GUI is empty.

Reload with /sk reload backpack.

Ethan Huynh

make the inventory view double chest sized. keep the last row untouched but add previous page on slot 48 (if applicable), exit on slot 49, and next page on slot 50 (if applicable). For now select any item as placeholders

Kodari AI
KodariOct 30 at 2:30 am 1

Plan:

  1. Make the storage list a fixed 54-slot GUI, showing up to 45 storages per page.

  2. Add page controls in slots 48–50 and preserve the GUI state while switching pages.

Updated /storage <player> to use a 54-slot GUI with up to 45 storages per page. The last row has a previous-page arrow in slot 48 when applicable, an exit button in slot 49, and a next-page arrow in slot 50 when applicable.

Reload with /sk reload backpack.

Ethan Huynh

give each claimed backpack an id in a 4 digit range starting from 1. Add that under the lore of backpacks only when viewed in the view gui as an admin. Then add a delete button in the last slot of the double chest. When clicked, have an anvil pop up. when admins enter the digit. itll delete that specific backpack

Kodari AI
KodariOct 30 at 2:40 am 1
  1. Assign sequential storage IDs from 0001 through 9999 and show them only on admin-view items.

  2. Add a slot-53 delete button that opens an anvil prompt; confirm the entered ID belongs to the viewed player, then remove that backpack and its stored data.

Updated backpack.sk: admin storage entries now show IDs 0001–9999, and slot 53 opens an anvil prompt to delete the matching backpack for the viewed player. Deleting it removes the backpack from that player’s inventory and deletes its stored contents.

Reload with /sk reload backpack.

Ethan Huynh

Im looking to keep the data of the storage if the item is present in the world. If in creative I delete, or the item disinegrates in lava, fire, cactus, anything, or despawns. the storage is deleted from the database

Kodari AI
KodariOct 30 at 2:46 am 1

Updated backpack.sk so storage contents are preserved while the backpack exists in a player’s inventory or as a dropped item. Its data is removed when it despawns, is destroyed by damage such as lava, fire, or cactus, or is deleted from a player’s inventory in Creative mode.

Reload with /sk reload backpack.

Ethan Huynh

[02:47:23 INFO]: [Skript] Reloading backpack.sk... [02:47:23 INFO]: Line 246: (backpack.sk) [02:47:23 INFO]:

There's no entity in an on damage event. [02:47:23 INFO]:

Line: if event-entity is not a dropped item: [02:47:23 INFO]: [02:47:23 INFO]: Line 248: (backpack.sk) [02:47:23 INFO]:

There's no entity in an on damage event. [02:47:23 INFO]:

Line: set {_id} to storageId(item of event-entity) [02:47:23 INFO]: [02:47:24 INFO]: [Skript] Encountered 2 errors while reloading backpack.sk! (286ms)

Kodari AI
KodariOct 30 at 2:48 am 1

Fixed the damage-event references to use victim instead of event-entity. Reload with /sk reload backpack.

Ethan Huynh

add delete all in the bottom left

Kodari AI
KodariOct 30 at 2:49 am 1

Added Delete All Storages in the bottom-left slot of the admin storage GUI. Clicking it removes all storage records and backpack items owned by the viewed player, then refreshes the GUI.

Reload with /sk reload backpack.

Ethan Huynh

When the item is dragged across slots. the data is deleted when the mouse cursor is holding onto it. How can this be prevented? I only want the data to delete if the player destroys it in survival like lava, fire, explosions, other means and despawn

Kodari AI
KodariOct 30 at 2:53 am 1

I’ll check the backpack deletion handlers and adjust them so moving an item—including holding it on the cursor—doesn’t count as destroying it.

Removed the Creative inventory-click cleanup handler. It was deleting storage data when an item was briefly absent during a click or drag. Moving a backpack or holding it on the cursor will no longer trigger deletion; despawn and dropped-item damage cleanup remain in place.

Reload with /sk reload backpack.

Ethan Huynh

seems to not work, now the storages are present even after deletion. lets remove the function overall. and also add a /storage all. to view every storage ever claimed

Kodari AI
KodariOct 30 at 3:00 am 1
  1. Remove automatic storage-data deletion tied to item destruction or despawn.

  2. Add /storage all to open an admin GUI listing every claimed storage.

Removed automatic storage-data deletion on item damage or despawn, so destroying or losing a backpack will no longer erase its stored contents.

Added /storage all for admins with storage.admin. It opens a paginated GUI of all currently registered claimed storages, showing each storage’s name, assigned item, owner UUID, and ID. You can click an entry to open it; individual deletion by ID remains available.

Reload with /sk reload backpack.

Ethan Huynh

[03:00:37 INFO]: [Skript] Reloading backpack.sk... [03:00:37 INFO]: Line 31: (backpack.sk) [03:00:37 INFO]:

Variables cannot be used here. [03:00:37 INFO]:

Line: if loop-value is {_owner} or {_owner} is "all": [03:00:37 INFO]: [03:00:37 INFO]: [Skript] Encountered 1 error while reloading backpack.sk! (225ms)

Kodari AI
KodariOct 30 at 3:01 am 1

Fixed the invalid condition by checking the “all storages” case separately from matching a specific owner. Reload with /sk reload backpack.

Ethan Huynh

replace owner uuid in /storage all to the players name and how long theyve had it and if its in their inventory or in a chest or bin or ground

Kodari AI
KodariOct 30 at 3:07 am 1
  1. Update /storage all entries to show owner name and claimed duration.

  2. Determine each backpack’s current location: player inventory, container, or ground.

Updated /storage all to show the owner’s name, how long they’ve had the backpack, and its tracked location: player inventory, chest/bin, or ground. New claims start the timer; picking up a backpack transfers ownership and resets it. Older storages without claim history or a known location show “Unknown.”

Reload with /sk reload backpack.

Ethan Huynh

remove how long theyve had it and if its in their inventory or in a chest or bin or ground

Kodari AI
KodariOct 30 at 3:17 am 1

I’ll remove the claim-duration and location details from the /storage all item lore, leaving the owner and ID visible.

Removed the claimed-duration and location details from /storage all. Entries still show the storage name, owner, and ID. Reload with /sk reload backpack.

Ethan Huynh

This is the skript i wanna base this off of. Error:

📎 2 files 23,765 chars
📄
pasted-code-1793330441624.txt
txt 485 lines
▶
options:
    prefix: &6[Storage]&r

function storageId(item: item) :: text:
    if {_item} is not set:
        return ""
    loop lore of {_item}:
        set {_line} to uncolored loop-value
        if {_line} starts with "KodariStorage:":
            replace all "KodariStorage:" with "" in {_line}
            return {_line}
    return ""

function removeStorageRecord(id: text):
    set {_name} to {storage.idname::%{_id}%}
    set {storage.deleted::%{_id}%} to true
    remove {_id} from {storage.issued::%{_name}%::*}
    delete {storage.idname::%{_id}%}
    delete {storage.idslots::%{_id}%}
    delete {storage.iditem::%{_id}%}
    delete {storage.owner::%{_id}%}
    delete {storage.owner-name::%{_id}%}
    delete {storage.claimed-at::%{_id}%}
    delete {storage.location::%{_id}%}
    delete {storage.data::%{_id}%::*}
    delete {storage.lock::%{_id}%}

function updateStorageLocation(id: text, viewer: player, container: inventory):
    set {_location} to "Not found"
    if storageId({_viewer}'s cursor slot) is {_id}:
        set {_location} to "Player inventory"
    loop integers from 0 to 40:
        if storageId(slot loop-number of {_viewer}'s inventory) is {_id}:
            set {_location} to "Player inventory"
    if {_location} is not "Player inventory":
        if {_container} is not {_viewer}'s inventory:
            loop all items in {_container}:
                if storageId(loop-item) is {_id}:
                    set {_location} to "Chest/bin"
    set {storage.location::%{_id}%} to {_location}

function openStorageView(viewer: player, owner: text, targetName: text, page: integer):
    set {_inventory} to a chest inventory with 6 rows named "&8Storages: &f%{_targetName}%"
    set {_offset} to ({_page} - 1) * 45
    set {_slot} to 0
    set {_count} to 0
    loop {storage.owner::*}:
        set {_include} to false
        if {_owner} is "all":
            set {_include} to true
        else if loop-value is {_owner}:
            set {_include} to true
        if {_include} is true:
            add 1 to {_count}
            if {_count} > {_offset}:
                if {_count} <= {_offset} + 45:
                    set {_id} to loop-index
                    set {_name} to {storage.idname::%{_id}%}
                    set {_item} to {storage.iditem::%{_id}%}
                    set {_ownerUuid} to loop-value
                    set {_ownerName} to {storage.owner-name::%{_id}%}
                    if {_ownerName} is not set:
                        loop all players:
                            if uuid of loop-player is {_ownerUuid}:
                                set {_ownerName} to name of loop-player
                    if {_ownerName} is not set:
                        set {_ownerName} to "Unknown (offline)"
                    set {_numericId} to {_id} parsed as integer
                    set {_displayId} to "%{_id}%"
                    if {_numericId} < 10:
                        set {_displayId} to "000%{_id}%"
                    else if {_numericId} < 100:
                        set {_displayId} to "00%{_id}%"
                    else if {_numericId} < 1000:
                        set {_displayId} to "0%{_id}%"
                    set name of {_item} to "&6%{_name}%"
                    if {_owner} is "all":
                        set lore of {_item} to "&7Storage: &f%{_name}%" and "&7Owner: &f%{_ownerName}%" and "&7ID: &f%{_displayId}%" and "&0KodariStorage:%{_id}%"
                    else:
                        set lore of {_item} to "&7Storage: &f%{_name}%" and "&7Owner: &f%{_targetName}%" and "&7ID: &f%{_displayId}%" and "&0KodariStorage:%{_id}%"
                    set slot {_slot} of {_inventory} to {_item}
                    add 1 to {_slot}
    set {storage.view.owner::%uuid of {_viewer}%} to {_owner}
    set {storage.view.name::%uuid of {_viewer}%} to {_targetName}
    set {storage.view.page::%uuid of {_viewer}%} to {_page}
    set {storage.view.count::%uuid of {_viewer}%} to {_count}
    set {_deleteAllButton} to barrier named "&cDelete All Storages"
    set lore of {_deleteAllButton} to "&7Delete every storage owned by this player"
    if {_owner} is "all":
        set {_deleteAllButton} to gray stained glass pane named "&7All Storages"
    set slot 45 of {_inventory} to {_deleteAllButton}
    if {_page} > 1:
        set slot 48 of {_inventory} to arrow named "&ePrevious Page"
    set slot 49 of {_inventory} to barrier named "&cExit"
    if {_count} > {_page} * 45:
        set slot 50 of {_inventory} to arrow named "&eNext Page"
    set {_deleteButton} to barrier named "&cDelete Backpack"
    set lore of {_deleteButton} to "&7Enter its 4-digit ID"
    set slot 53 of {_inventory} to {_deleteButton}
    open {_inventory} to {_viewer}

command /storage [] [] []:
    trigger:
        if sender does not have permission "storage.admin":
            send "{@prefix} &cYou don't have permission to manage storage." to sender
            stop
        if argument 1 is not set:
            send "{@prefix} &eUsage: /storage list, create  , set  , give  , delete " to sender
            stop

        if argument 1 is "list":
            if {storage.names::*} is not set:
                send "{@prefix} &7No storage templates exist." to sender
                stop
            send "{@prefix} &eStorage templates:" to sender
            loop {storage.names::*}:
                if {storage.config::%loop-value%::item} is set:
                    send "&7- &f%loop-value% &8(&e%{storage.config::%loop-value%::slots}% slots&8)" to sender
                else:
                    send "&7- &f%loop-value% &8(&citem not configured&8)" to sender
            stop

        if argument 1 is "create":
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage create  " to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage create  " to sender
                stop
            if {storage.config::%argument 2%::slots} is set:
                send "{@prefix} &cA storage template named %argument 2% already exists." to sender
                stop
            set {_size} to argument 3 parsed as integer
            if {_size} is not set:
                send "{@prefix} &cSlots must be a number from 9 to 54." to sender
                stop
            set {_valid} to false
            if {_size} is 9:
                set {_valid} to true
            if {_size} is 18:
                set {_valid} to true
            if {_size} is 27:
                set {_valid} to true
            if {_size} is 36:
                set {_valid} to true
            if {_size} is 45:
                set {_valid} to true
            if {_size} is 54:
                set {_valid} to true
            if {_valid} is false:
                send "{@prefix} &cSlots must be 9, 18, 27, 36, 45, or 54." to sender
                stop
            set {storage.config::%argument 2%::slots} to {_size}
            add argument 2 to {storage.names::*}
            send "{@prefix} &aCreated %argument 2% with %{_size}% slots. Set its item with /storage set." to sender
            stop

        if argument 1 is "set":
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage set  " to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage set  " to sender
                stop
            if {storage.config::%argument 2%::slots} is not set:
                send "{@prefix} &cThat storage template does not exist." to sender
                stop
            set {_itemType} to argument 3 parsed as item type
            if {_itemType} is not set:
                send "{@prefix} &cThat item id is not valid." to sender
                stop
            set {storage.config::%argument 2%::item} to {_itemType}
            send "{@prefix} &aSet the backpack item for %argument 2%." to sender
            stop

        if argument 1 is "give":
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage give  " to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage give  " to sender
                stop
            if {storage.config::%argument 3%::slots} is not set:
                send "{@prefix} &cThat storage template does not exist." to sender
                stop
            if {storage.config::%argument 3%::item} is not set:
                send "{@prefix} &cSet its item first with /storage set %argument 3% ." to sender
                stop
            set {_target} to argument 2 parsed as player
            if {_target} is not set:
                send "{@prefix} &cThat player is not online." to sender
                stop
            if {storage.next-id} is not set:
                set {storage.next-id} to 0
            if {storage.next-id} >= 9999:
                send "{@prefix} &cThe 4-digit storage ID range is full." to sender
                stop
            add 1 to {storage.next-id}
            set {_id} to "%{storage.next-id}%"
            set {_name} to argument 3
            set {storage.idname::%{_id}%} to {_name}
            set {storage.idslots::%{_id}%} to {storage.config::%{_name}%::slots}
            set {storage.iditem::%{_id}%} to {storage.config::%{_name}%::item}
            set {storage.owner::%{_id}%} to uuid of {_target}
            set {storage.owner-name::%{_id}%} to name of {_target}
            set {storage.claimed-at::%{_id}%} to now
            set {storage.location::%{_id}%} to "Player inventory"
            add {_id} to {storage.issued::%{_name}%::*}
            set {_item} to {storage.config::%{_name}%::item}
            set name of {_item} to "&6%{_name}% Backpack"
            set lore of {_item} to "&7Equip in your offhand" and "&7Click in an inventory to open" and "&e%name of {_target}%'s %{_name}%" and "&0KodariStorage:%{_id}%"
            give {_item} to {_target}
            send "{@prefix} &aGave a %argument 3% backpack to %name of {_target}%." to sender
            send "{@prefix} &aYou received a %argument 3% backpack." to {_target}
            stop

        if argument 1 is "delete":
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage delete " to sender
                stop
            if {storage.config::%argument 2%::slots} is not set:
                send "{@prefix} &cThat storage template does not exist." to sender
                stop
            delete {storage.config::%argument 2%::*}
            remove argument 2 from {storage.names::*}
            send "{@prefix} &aDeleted the %argument 2% template. Issued backpacks and their contents remain usable." to sender
            stop

        if argument 1 is "all":
            if sender is not a player:
                send "{@prefix} &cThis command must be used by a player to open the storage GUI." to sender
                stop
            set {storage.view::%uuid of player%} to true
            delete {storage.view.target::%uuid of player%}
            openStorageView(player, "all", "All Claimed Storages", 1)
            stop

        set {_target} to argument 1 parsed as player
        if {_target} is not set:
            send "{@prefix} &cUsage: /storage " to sender
            stop
        if sender is not a player:
            send "{@prefix} &cThis command must be used by a player to open the storage GUI." to sender
            stop

        set {_owner} to "%uuid of {_target}%"
        set {_targetName} to name of {_target}
        set {storage.view::%uuid of player%} to true
        set {storage.view.target::%uuid of player%} to {_target}
        openStorageView(player, {_owner}, {_targetName}, 1)
        stop

on pickup:
    set {_id} to storageId(event-item)
    if {_id} is "":
        stop
    if {storage.idname::%{_id}%} is not set:
        stop
    set {storage.owner::%{_id}%} to uuid of player
    set {storage.owner-name::%{_id}%} to name of player
    set {storage.claimed-at::%{_id}%} to now
    set {storage.location::%{_id}%} to "Player inventory"
    set {_name} to {storage.idname::%{_id}%}
    loop lore of event-item:
        set {_line} to uncolored loop-value
        if {_line} does not contain "'s %{_name}%":
            add loop-value to {_lore::*}
    add "&e%name of player%'s %{_name}%" to {_lore::*}
    set lore of event-item to {_lore::*}

on right click:
    set {_id} to storageId(player's tool)
    if {_id} is "":
        stop
    cancel event
    if {storage.open::%uuid of player%} is set:
        send "{@prefix} &cClose your current backpack before opening another." to player
        stop
    if {storage.lock::%{_id}%} is set:
        send "{@prefix} &cThis backpack is already open." to player
        stop

    set {_name} to {storage.idname::%{_id}%}
    set {_size} to {storage.idslots::%{_id}%}
    if {_size} is not set:
        set {_size} to {storage.config::%{_name}%::slots}
    if {_size} is not set:
        send "{@prefix} &cThis backpack is no longer valid." to player
        stop
    set {_rows} to {_size} / 9
    set {_inventory} to a chest inventory with {_rows} rows named "&8Backpack: &f%{_name}%"
    loop integers from 0 to {_size} - 1:
        if {storage.data::%{_id}%::%loop-number%} is set:
            set slot loop-number of {_inventory} to {storage.data::%{_id}%::%loop-number%}
    set {storage.lock::%{_id}%} to uuid of player
    wait 1 tick
    open {_inventory} to player
    set {storage.open::%uuid of player%} to {_id}

on inventory close:
    if {storage.view.switch::%uuid of player%} is set:
        delete {storage.view.switch::%uuid of player%}
        stop
    if {storage.view::%uuid of player%} is set:
        delete {storage.view::%uuid of player%}
        delete {storage.view.owner::%uuid of player%}
        delete {storage.view.name::%uuid of player%}
        delete {storage.view.page::%uuid of player%}
        delete {storage.view.count::%uuid of player%}
        delete {storage.view.target::%uuid of player%}
    delete {storage.delete.pending::%uuid of player%}
    delete {storage.delete.owner::%uuid of player%}
    set {_id} to {storage.open::%uuid of player%}
    if {_id} is not set:
        stop
    if {storage.deleted::%{_id}%} is set:
        delete {storage.lock::%{_id}%}
        delete {storage.open::%uuid of player%}
        stop
    set {_size} to {storage.idslots::%{_id}%}
    if {_size} is not set:
        set {_name} to {storage.idname::%{_id}%}
        set {_size} to {storage.config::%{_name}%::slots}
    if {_size} is set:
        loop integers from 0 to {_size} - 1:
            set {storage.data::%{_id}%::%loop-number%} to slot loop-number of event-inventory
    if {storage.lock::%{_id}%} is uuid of player:
        delete {storage.lock::%{_id}%}
    delete {storage.open::%uuid of player%}

on inventory click:
    if {storage.delete.pending::%uuid of player%} is set:
        cancel event
        if clicked slot is not 2:
            stop
        set {_enteredId} to uncolored name of event-item
        set {_parsedId} to {_enteredId} parsed as integer
        if {_parsedId} is not set:
            send "{@prefix} &cEnter a valid 4-digit storage ID." to player
            stop
        set {_id} to "%{_parsedId}%"
        if {storage.delete.owner::%uuid of player%} is not "all":
            if {storage.owner::%{_id}%} is not {storage.delete.owner::%uuid of player%}:
                send "{@prefix} &cThat storage ID does not belong to the viewed player." to player
                stop
        set {_storageName} to {storage.idname::%{_id}%}
        set {_owner} to {storage.view.owner::%uuid of player%}
        set {_targetName} to {storage.view.name::%uuid of player%}
        set {_target} to {storage.view.target::%uuid of player%}
        set {_page} to {storage.view.page::%uuid of player%}
        if {_owner} is "all":
            loop all players:
                loop integers from 0 to 40:
                    set {_candidate} to slot loop-number of loop-player's inventory
                    if storageId({_candidate}) is {_id}:
                        set slot loop-number of loop-player's inventory to air
        else:
            loop integers from 0 to 40:
                set {_candidate} to slot loop-number of {_target}'s inventory
                if storageId({_candidate}) is {_id}:
                    set slot loop-number of {_target}'s inventory to air
        removeStorageRecord({_id})
        send "{@prefix} &aDeleted storage ID %{_parsedId}%." to player
        if {storage.view.count::%uuid of player%} <= ({_page} - 1) * 45 + 1:
            if {_page} > 1:
                remove 1 from {_page}
        delete {storage.delete.pending::%uuid of player%}
        delete {storage.delete.owner::%uuid of player%}
        set {storage.view.switch::%uuid of player%} to true
        openStorageView(player, {_owner}, {_targetName}, {_page})
        stop
    if {storage.view::%uuid of player%} is set:
        cancel event
        if clicked slot is 45:
            if {storage.view.owner::%uuid of player%} is "all":
                stop
            set {_owner} to {storage.view.owner::%uuid of player%}
            set {_target} to {storage.view.target::%uuid of player%}
            delete {_ids::*}
            loop {storage.owner::*}:
                if loop-value is {_owner}:
                    add loop-index to {_ids::*}
            loop {_ids::*}:
                set {_id} to loop-value
                loop integers from 0 to 40:
                    if storageId(slot loop-number of {_target}'s inventory) is {_id}:
                        set slot loop-number of {_target}'s inventory to air
                removeStorageRecord({_id})
            send "{@prefix} &aDeleted all storages owned by %name of {_target}%." to player
            set {storage.view.switch::%uuid of player%} to true
            openStorageView(player, {_owner}, {storage.view.name::%uuid of player%}, 1)
            stop
        if clicked slot is 49:
            close player's inventory
            stop
        if clicked slot is 48:
            if {storage.view.page::%uuid of player%} > 1:
                remove 1 from {storage.view.page::%uuid of player%}
                set {storage.view.switch::%uuid of player%} to true
                openStorageView(player, {storage.view.owner::%uuid of player%}, {storage.view.name::%uuid of player%}, {storage.view.page::%uuid of player%})
            stop
        if clicked slot is 50:
            if {storage.view.count::%uuid of player%} > {storage.view.page::%uuid of player%} * 45:
                add 1 to {storage.view.page::%uuid of player%}
                set {storage.view.switch::%uuid of player%} to true
                openStorageView(player, {storage.view.owner::%uuid of player%}, {storage.view.name::%uuid of player%}, {storage.view.page::%uuid of player%})
            stop
        if clicked slot is 53:
            set {storage.delete.pending::%uuid of player%} to true
            set {storage.delete.owner::%uuid of player%} to {storage.view.owner::%uuid of player%}
            set {storage.view.switch::%uuid of player%} to true
            open anvil inventory to player
            wait 1 tick
            set slot 0 of player's current inventory to paper named "&7Enter 4-digit storage ID"
            stop
        set {_id} to storageId(event-item)
        if {_id} is "":
            stop
        if {storage.open::%uuid of player%} is set:
            send "{@prefix} &cClose your current backpack before opening another." to player
            stop
        if {storage.lock::%{_id}%} is set:
            send "{@prefix} &cThis backpack is already open." to player
            stop
        set {_name} to {storage.idname::%{_id}%}
        set {_size} to {storage.idslots::%{_id}%}
        if {_size} is not set:
            set {_size} to {storage.config::%{_name}%::slots}
        if {_size} is not set:
            send "{@prefix} &cThis backpack is no longer valid." to player
            stop
        set {_rows} to {_size} / 9
        set {_inventory} to a chest inventory with {_rows} rows named "&8Backpack: &f%{_name}%"
        loop integers from 0 to {_size} - 1:
            if {storage.data::%{_id}%::%loop-number%} is set:
                set slot loop-number of {_inventory} to {storage.data::%{_id}%::%loop-number%}
        delete {storage.view::%uuid of player%}
        set {storage.lock::%{_id}%} to uuid of player
        wait 1 tick
        open {_inventory} to player
        set {storage.open::%uuid of player%} to {_id}
        stop
    set {_clickedId} to storageId(event-item)
    set {_cursorId} to storageId(player's cursor slot)
    if {storage.open::%uuid of player%} is set:
        if {_clickedId} is not "":
            cancel event
        if {_cursorId} is not "":
            cancel event
    delete {_trackedIds::*}
    if {_clickedId} is not "":
        add {_clickedId} to {_trackedIds::*}
    if {_cursorId} is not "":
        if {_cursorId} is not {_clickedId}:
            add {_cursorId} to {_trackedIds::*}
    if {_trackedIds::*} is set:
        set {_container} to event-inventory
        wait 1 tick
        loop {_trackedIds::*}:
            updateStorageLocation(loop-value, player, {_container})

on inventory drag:
    set {_id} to storageId(player's cursor slot)
    if {storage.open::%uuid of player%} is set:
        if {_id} is not "":
            cancel event
            stop
    if {_id} is "":
        stop
    set {_container} to event-inventory
    wait 1 tick
    updateStorageLocation({_id}, player, {_container})

on swap hand items:
    if {storage.open::%uuid of player%} is set:
        cancel event

on drop:
    set {_id} to storageId(event-item)
    if {_id} is "":
        stop
    if {storage.open::%uuid of player%} is set:
        cancel event
        stop
    set {storage.location::%{_id}%} to "Ground"
📄
pasted-code-1793330471831.txt
txt 26 lines
▶
[03:20:30 INFO]: [Skript] Loaded 5998 aliases in 255ms
sk reload all
[03:20:59 INFO]: [Skript] Reloading the config, aliases and all scripts...
[03:20:59 INFO]: [Skript] Loaded 5998 aliases in 217ms
[03:20:59 INFO]: Line 4: (storage.sk)
[03:20:59 INFO]:     Function 'storageId' with the same argument types already exists in script 'backpack.sk'.
[03:20:59 INFO]:     Line: function storageId(item: item) :: text:
[03:20:59 INFO]:  
[03:20:59 INFO]: Line 14: (storage.sk)
[03:20:59 INFO]:     Function 'removeStorageRecord' with the same argument types already exists in script 'backpack.sk'.
[03:20:59 INFO]:     Line: function removeStorageRecord(id: text):
[03:20:59 INFO]:  
[03:20:59 INFO]: Line 28: (storage.sk)
[03:20:59 INFO]:     Function 'updateStorageLocation' with the same argument types already exists in script 'backpack.sk'.
[03:20:59 INFO]:     Line: function updateStorageLocation(id: text, viewer: player, container: inventory):
[03:20:59 INFO]:  
[03:20:59 INFO]: Line 42: (storage.sk)
[03:20:59 INFO]:     Function 'openStorageView' with the same argument types already exists in script 'backpack.sk'.
[03:20:59 INFO]:     Line: function openStorageView(viewer: player, owner: text, targetName: text, page: integer):
[03:20:59 INFO]:  
[03:20:59 INFO]: Line 102: (storage.sk)
[03:20:59 INFO]:     A command with the name /storage is already defined in the script 'backpack.sk'
[03:20:59 INFO]:     Line: command /storage [] [] []:
[03:20:59 INFO]:  
[03:20:59 INFO]: [Skript] Encountered 5 errors while reloading the config, aliases and all scripts! (421ms)
Kodari AI
KodariOct 30 at 3:22 am 1

The error is from Skript loading the same storage system twice: the functions and /storage command in storage.sk duplicate those in backpack.sk.

Keep one copy. Since the project file is backpack.sk, remove or disable storage.sk from plugins/Skript/scripts/, then run /sk reload all. No code change is needed.

Ethan Huynh

Create permissions for each commands. and admin for everything and delete in view portal.

Kodari AI
KodariOct 30 at 3:27 am 1

Updated backpack.sk with separate permissions for /storage list, create, set, give, delete, and viewing storage. storage.admin bypasses all permission checks.

Deleting backpacks or all of a player’s storages from the view GUI requires storage.view.delete. The delete controls are disabled for viewers without that permission.

Place the file in plugins/Skript/scripts/ and run /sk reload backpack.

Ethan Huynh

no permission is needed to open a backpack whiling holding it and claiming it

Kodari AI
KodariOct 30 at 3:28 am 1

Opening a backpack while holding it and claiming one on pickup require no permission. In backpack.sk, permissions only gate /storage commands and deleting from the view portal.

Ethan Huynh

however, admins bypass the claim name change incase they have to view another players storage holding

Kodari AI
KodariOct 30 at 3:29 am 1

Updated backpack.sk: when an admin picks up a backpack already claimed by another player, its owner and claim-name lore stay unchanged. Admins can still claim unclaimed backpacks normally.

Kodari can make mistakes. Review important code before using.
Files
backpack.sk
Code
1 530
backpack.sk
options:
    prefix: &6[Storage]&r

function storageId(item: item) :: text:
    if {_item} is not set:
        return ""
    loop lore of {_item}:
        set {_line} to uncolored loop-value
        if {_line} starts with "KodariStorage:":
            replace all "KodariStorage:" with "" in {_line}
            return {_line}
    return ""

function removeStorageRecord(id: text):
    set {_name} to {storage.idname::%{_id}%}
    set {storage.deleted::%{_id}%} to true
    remove {_id} from {storage.issued::%{_name}%::*}
    delete {storage.idname::%{_id}%}
    delete {storage.idslots::%{_id}%}
    delete {storage.iditem::%{_id}%}
    delete {storage.owner::%{_id}%}
    delete {storage.owner-name::%{_id}%}
    delete {storage.claimed-at::%{_id}%}
    delete {storage.location::%{_id}%}
    delete {storage.data::%{_id}%::*}
    delete {storage.lock::%{_id}%}

function updateStorageLocation(id: text, viewer: player, container: inventory):
    set {_location} to "Not found"
    if storageId({_viewer}'s cursor slot) is {_id}:
        set {_location} to "Player inventory"
    loop integers from 0 to 40:
        if storageId(slot loop-number of {_viewer}'s inventory) is {_id}:
            set {_location} to "Player inventory"
    if {_location} is not "Player inventory":
        if {_container} is not {_viewer}'s inventory:
            loop all items in {_container}:
                if storageId(loop-item) is {_id}:
                    set {_location} to "Chest/bin"
    set {storage.location::%{_id}%} to {_location}

function openStorageView(viewer: player, owner: text, targetName: text, page: integer):
    set {_inventory} to a chest inventory with 6 rows named "&8Storages: &f%{_targetName}%"
    set {_offset} to ({_page} - 1) * 45
    set {_slot} to 0
    set {_count} to 0
    loop {storage.owner::*}:
        set {_include} to false
        if {_owner} is "all":
            set {_include} to true
        else if loop-value is {_owner}:
            set {_include} to true
        if {_include} is true:
            add 1 to {_count}
            if {_count} > {_offset}:
                if {_count} <= {_offset} + 45:
                    set {_id} to loop-index
                    set {_name} to {storage.idname::%{_id}%}
                    set {_item} to {storage.iditem::%{_id}%}
                    set {_ownerUuid} to loop-value
                    set {_ownerName} to {storage.owner-name::%{_id}%}
                    if {_ownerName} is not set:
                        loop all players:
                            if uuid of loop-player is {_ownerUuid}:
                                set {_ownerName} to name of loop-player
                    if {_ownerName} is not set:
                        set {_ownerName} to "Unknown (offline)"
                    set {_numericId} to {_id} parsed as integer
                    set {_displayId} to "%{_id}%"
                    if {_numericId} < 10:
                        set {_displayId} to "000%{_id}%"
                    else if {_numericId} < 100:
                        set {_displayId} to "00%{_id}%"
                    else if {_numericId} < 1000:
                        set {_displayId} to "0%{_id}%"
                    set name of {_item} to "&6%{_name}%"
                    if {_owner} is "all":
                        set lore of {_item} to "&7Storage: &f%{_name}%" and "&7Owner: &f%{_ownerName}%" and "&7ID: &f%{_displayId}%" and "&0KodariStorage:%{_id}%"
                    else:
                        set lore of {_item} to "&7Storage: &f%{_name}%" and "&7Owner: &f%{_targetName}%" and "&7ID: &f%{_displayId}%" and "&0KodariStorage:%{_id}%"
                    set slot {_slot} of {_inventory} to {_item}
                    add 1 to {_slot}
    set {storage.view.owner::%uuid of {_viewer}%} to {_owner}
    set {storage.view.name::%uuid of {_viewer}%} to {_targetName}
    set {storage.view.page::%uuid of {_viewer}%} to {_page}
    set {storage.view.count::%uuid of {_viewer}%} to {_count}
    set {_deleteAllButton} to barrier named "&cDelete All Storages"
    set lore of {_deleteAllButton} to "&7Delete every storage owned by this player"
    if {_owner} is "all":
        set {_deleteAllButton} to gray stained glass pane named "&7All Storages"
    else if {_viewer} does not have permission "storage.admin":
        if {_viewer} does not have permission "storage.view.delete":
            set {_deleteAllButton} to gray stained glass pane named "&7No delete permission"
    set slot 45 of {_inventory} to {_deleteAllButton}
    if {_page} > 1:
        set slot 48 of {_inventory} to arrow named "&ePrevious Page"
    set slot 49 of {_inventory} to barrier named "&cExit"
    if {_count} > {_page} * 45:
        set slot 50 of {_inventory} to arrow named "&eNext Page"
    set {_deleteButton} to barrier named "&cDelete Backpack"
    set lore of {_deleteButton} to "&7Enter its 4-digit ID"
    if {_viewer} does not have permission "storage.admin":
        if {_viewer} does not have permission "storage.view.delete":
            set {_deleteButton} to gray stained glass pane named "&7No delete permission"
    set slot 53 of {_inventory} to {_deleteButton}
    open {_inventory} to {_viewer}

command /storage [<text>] [<text>] [<text>]:
    trigger:
        if argument 1 is not set:
            send "{@prefix} &eUsage: /storage list, create <name> <slots>, set <name> <item id>, give <player> <name>, delete <name>" to sender
            stop

        if argument 1 is "list":
            if sender does not have permission "storage.admin":
                if sender does not have permission "storage.list":
                    send "{@prefix} &cYou don't have permission to list storage templates." to sender
                    stop
            if {storage.names::*} is not set:
                send "{@prefix} &7No storage templates exist." to sender
                stop
            send "{@prefix} &eStorage templates:" to sender
            loop {storage.names::*}:
                if {storage.config::%loop-value%::item} is set:
                    send "&7- &f%loop-value% &8(&e%{storage.config::%loop-value%::slots}% slots&8)" to sender
                else:
                    send "&7- &f%loop-value% &8(&citem not configured&8)" to sender
            stop

        if argument 1 is "create":
            if sender does not have permission "storage.admin":
                if sender does not have permission "storage.create":
                    send "{@prefix} &cYou don't have permission to create storage templates." to sender
                    stop
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage create <name> <slots>" to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage create <name> <slots>" to sender
                stop
            if {storage.config::%argument 2%::slots} is set:
                send "{@prefix} &cA storage template named %argument 2% already exists." to sender
                stop
            set {_size} to argument 3 parsed as integer
            if {_size} is not set:
                send "{@prefix} &cSlots must be a number from 9 to 54." to sender
                stop
            set {_valid} to false
            if {_size} is 9:
                set {_valid} to true
            if {_size} is 18:
                set {_valid} to true
            if {_size} is 27:
                set {_valid} to true
            if {_size} is 36:
                set {_valid} to true
            if {_size} is 45:
                set {_valid} to true
            if {_size} is 54:
                set {_valid} to true
            if {_valid} is false:
                send "{@prefix} &cSlots must be 9, 18, 27, 36, 45, or 54." to sender
                stop
            set {storage.config::%argument 2%::slots} to {_size}
            add argument 2 to {storage.names::*}
            send "{@prefix} &aCreated %argument 2% with %{_size}% slots. Set its item with /storage set." to sender
            stop

        if argument 1 is "set":
            if sender does not have permission "storage.admin":
                if sender does not have permission "storage.set":
                    send "{@prefix} &cYou don't have permission to configure storage templates." to sender
                    stop
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage set <name> <item id>" to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage set <name> <item id>" to sender
                stop
            if {storage.config::%argument 2%::slots} is not set:
                send "{@prefix} &cThat storage template does not exist." to sender
                stop
            set {_itemType} to argument 3 parsed as item type
            if {_itemType} is not set:
                send "{@prefix} &cThat item id is not valid." to sender
                stop
            set {storage.config::%argument 2%::item} to {_itemType}
            send "{@prefix} &aSet the backpack item for %argument 2%." to sender
            stop

        if argument 1 is "give":
            if sender does not have permission "storage.admin":
                if sender does not have permission "storage.give":
                    send "{@prefix} &cYou don't have permission to give storage." to sender
                    stop
            if argument 2 is not set:
                send "{@prefix} &cUsage: /storage give <player> <name>" to sender
                stop
            if argument 3 is not set:
                send "{@prefix} &cUsage: /storage give <player> <name>" to sender