# #! ________________________ # #! ___________________________________ # Shelves # © Made by HiiqhFive™ # v1.0.010 # #! ___________________________________ # #! ________________________ options: version: 1.0.010 UI_Name: &cShelf # messages shelf_created: &8[&cShelves&8] &cShelf successfully created. shelf_created_exists: &8[&cShelves&8] &cShelf already exists. Using saved inventory shelf_destroyed: &8[&cShelves&8] &cShelf destroyed. Getting items back. shelf_destroyed_not_exist: &8[&cShelves&8] &cNo Shelf-inventory exists. shelf_open_not_yours: &8[&cShelves&8] &cThat's not your shelf. shelf_open_not_exist: &8[&cShelves&8] &cNo Shelf-inventory exists. shelf_save_saved: &8[&cShelves&8] &cShelf-inventory saved. shelf_save_not_yours: &8[&cShelves&8] &cThat's not your shelf - restoring previous items. shelf_save_not_exist: &8[&cShelves&8] &cNo Shelf-inventory exists. # using debug messages | IMPORTANT: MESSAGE "shelf_open_not_yours" IS USED INDEPENDANT FROM DEBUG MODE! debug_messages: true # start functions function openShelf_Admin(location: location, executor: player) :: text: {shelves::%{_location}%::*} is set: {_executor} has permission "*": open chest with 1 row named "{@UI_Name}" to {_executor} wait a tick loop {shelves::%{_location}%::*}: set {_index} to "%loop-index%" parsed as integer set {_value} to "%loop-value%" parsed as item set slot {_index} of {_executor}'s current inventory to {_value} function destroyShelf_Admin(location: location, executor: player) :: text: {shelves::%{_location}%::*} is set: {_executor} has permission "*": loop {shelves::%{_location}%::*}: set {_item} to "%loop-value%" parsed as item add {_item} to {_executor}'s inventory delete {shelves::%{_location}%::*} delete {shelves::owner::%{_location}%} function createShelf(location: location, executor: player) :: text: {shelves::%{_location}%::*} is not set: set {shelves::%{_location}%::*} to true loop 9 times: set {shelves::%{_location}%::%loop-number - 1%} to 0 set {shelves::owner::%{_location}%} to {_executor} {@debug_messages} = true: return "{@shelf_created}" else: {shelves::owner::%{_location}%} is not {_executor}: delete {shelves::%{_location}%::*} createShelf({_location}, {_executor}) {@debug_messages} = true: return "{@shelf_created_exists}" function destroyShelf(location: location, executor: player) :: text: {shelves::%{_location}%::*} is set: {shelves::owner::%{_location}%} is {_executor}: loop {shelves::%{_location}%::*}: set {_item} to "%loop-value%" parsed as item add {_item} to {_executor}'s inventory delete {shelves::%{_location}%::*} delete {shelves::owner::%{_location}%} {@debug_messages} = true: return "{@shelf_destroyed}" else: {_executor} has permission "*": destroyShelf_Admin({_location}, {_executor}) stop return "0" else: {@debug_messages} = true: return "{@shelf_destroyed_not_exist}" function openShelf(location: location, executor: player) :: text: {shelves::%{_location}%::*} is set: {shelves::owner::%{_location}%} is {_executor}: open chest with 1 row named "{@UI_Name}" to {_executor} wait a tick loop {shelves::%{_location}%::*}: set {_index} to "%loop-index%" parsed as integer set {_value} to "%loop-value%" parsed as item set slot {_index} of {_executor}'s current inventory to {_value} send "%{_index}% -- %{_value}% " to {_executor} else: return "{@shelf_open_not_yours}" else: {@debug_messages} = true: return "{@shelf_open_not_exist}" function saveShelf(location: location, executor: player) :: text: {shelves::%{_location}%::*} is set: {shelves::owner::%{_location}%} is {_executor}: delete {shelves::%{_location}%::*} loop 9 times: set {_values.inventory::%loop-number - 1%} to slot loop-number - 1 of {_executor}'s current inventory set {shelves::%{_location}%::%loop-number - 1%} to {_values.inventory::%loop-number - 1%} delete {shelves::%{_executor}%} {@debug_messages} = true: return "{@shelf_save_saved}" else: {@debug_messages} = true: return "{@shelf_save_not_yours}" else: {@debug_messages} = true: return "{@shelf_save_not_exist}" # end functions on place of bookshelf: set {_result} to createShelf(location of event-block, player) {_result} is not "": send {_result} on right click on bookshelf: set {shelves::%player%} to location of event-block set {_result} to openShelf(location of event-block, player) {_result} is not "": send {_result} on inventory close: inventory name of player's current inventory contains "Shelf": {shelves::%player%} is set: set {_result} to saveShelf({shelves::%player%}, player) {_result} is not "": send {_result} on break of bookshelf: set {_result} to destroyShelf(location of event-block, player) {_result} is "0": cancel the event send "{@shelf_open_not_yours}" stop {_result} is not "": send {_result}