Staff Pick: PlayerVaults
By
MwthornCreated: 2018/08/06 16:29:15 UTC-07:00 (6 years and 139 days ago)
Edited: 2018/08/06 16:29:15 UTC-07:00 (6 years and 139 days ago)
Likes: 0
Staff pick as of: 2019/02/15 00:05:52 UTC-08:00 (5 years and 311 days ago)
Denizen Version: 1.0.2
Script Version: 1.0
Description:
A virtual chest system to store items, just like having multiple enderchests.
Commands:
/pv
/pv (number)
Give players the permission:
- playervaults.vault.(number)
Example:
- playervaults.vault.1
- playervaults.vault.3
This will give a player acess to vault 1 and 3 but NOT 2.
Known Issues:
- Items with custom NBT are not supported, however everything else like lore, display, enchantments and script items are fine.
Download script |
View raw scriptPlayerVault_Events:
type: world
events:
on server start:
- inject PlayerVault_Load_Config_Task
on reload scripts:
- inject PlayerVault_Load_Config_Task
on player closes inventory:
- if <context.inventory.replace[<player.uuid>].starts_with[in@pvault].not||true> {
- queue clear
}
- define vault_id <context.inventory.after[_]>
- define dvlist <context.inventory.list_contents>
- yaml set id:pvaultkey "<player.uuid>.<def[vault_id]>:<def[dvlist]>"
- yaml "savefile:data/pvault/pvaultkey.yml" "id:pvaultkey"
- define id "<player.uuid>pvault_<def[vault_id]>"
- note remove as:<def[id]>
PlayerVault_Load_Config_Task:
type: task
script:
- if <server.has_file[data/pvault/pvaultkey.yml].not> {
- yaml create "id:pvaultkey"
- yaml "savefile:data/pvault/pvaultkey.yml" "id:pvaultkey"
}
else {
- yaml "load:data/pvault/pvaultkey.yml" "id:pvaultkey"
}
PlayerVault_Command:
type: command
name: playervault
aliases:
- vc
- pv
- pvs
- playervaults
script:
- if <context.args.size> > 0 {
- define vault_id <context.args.get[1].as_int||1>
}
else {
- define vault_id 1
}
- if <player.has_permission[playervaults.vault.<def[vault_id]>].global.not> {
- narrate "<&c>Sorry, no access to PV <def[vault_id]>"
- queue clear
}
- define lines 6
- define pvault <player.uuid>pvault_<def[vault_id]>
- define title "<&3>PV <&co> <def[vault_id]>"
- note "in@generic[title=<def[title]>;size=<def[lines].mul_int[9]>]" as:<def[pvault]>
- define items <yaml[pvaultkey].read[<player.uuid>.<def[vault_id]>]||null>
- if <def[items]> != null {
- inventory set d:in@<def[pvault]> o:<def[items]>
}
- inventory open d:in@<def[pvault]>
View History