########################################### # Made by Smellyonionman for Smellycraft. # # onion@smellycraft.com # # Tested on Denizen-1.1.2-b4492-DEV # # Version 1.2 # #-----------------------------------------# # Updates and notes are found at: # # https://smellycraft.com/d/tabWorks # #-----------------------------------------# # You may use, modify or share this # # script, provided you don't remove # # or alter lines 1-13 of this file. # ########################################### sc_tw_init: type: task debug: false script: - define namespace:sc_tw - define admin:> - define targets:]].include[].deduplicate||> - define filename: - if ]||null>: - if : - ~yaml unload id:sc_tw - ~yaml load:../Smellycraft/<[filename]> id:sc_tw - else: - ~yaml create id:sc_tw - define payload: - if <[payload].matches[null]>: - ~webget https://raw.githubusercontent.com/smellyonionman/smellycraft/master/configs/TabWorks.yml save:sc_raw headers:host/smellycraft.com:443|user-agent/smellycraft - define payload: - ~yaml loadtext:<[payload]> id:sc_tw - yaml set type:! id:sc_tw - if ].not>: - define msg:'>' - narrate <[msg].unescaped.parse_color> targets:<[targets]> - stop - foreach >> as:task: - if ]||]>>]>].not>: - define placeholder:> - narrate '<[placeholder].replace[[script]].with[<[task]>].separated_by[&sp].unescaped.parse_color>' targets:<[targets]> - stop - ~yaml savefile:../Smellycraft/<[filename]> id:sc_tw - yaml set commands.open:! id:sc_tw - foreach > as:yaml: - if <[yaml].list_keys[tabs].size.is[==].to[0]||false>: - foreach next - ~yaml create id:sc_tw_tabtemp - ~yaml loadtext:<[yaml].to_json> id:sc_tw_tabtemp - foreach : - ~yaml id:sc_tw_tabtemp copykey:tabs.<[value]> tabs.<[value]> to_id:sc_tw - ~yaml set tabs.<[value]>.scriptname:<[yaml]> id:sc_tw - ~yaml set commands.open.<[value]>:use id:sc_tw - ~yaml unload id:sc_tw_tabtemp - define feedback:> - if <[feedback].exists>: - inject >]> sc_tw_cmd: type: command debug: false name: tabworks description: usage: /tabworks script: - define namespace:sc_tw - define use:> - define admin:> - if ]||false> || || : - define selector:>> - if : - yaml set .sc_tw.selector:<[selector]> id:sc_pcache - yaml set .sc_tw.index:1 id:sc_pcache - if : - inventory open d: - else: - define tabs:!|:> - if : - if : - if ]||false> || || : - define arg: - inject - else if : - define feedback:> - else if : - define feedback: - else: - define placeholder:> - define feedback:<[placeholder].replace[[args]].with[]> - else if : - if : - if <[tabs].contains[<[selector]>]||false>: - inventory open d: - else: - define feedback:> - else: - define placeholder:> - define feedback:<[placeholder].replace[[args]].with[]> - else: - if : - define icon: - if <[tabs].contains[<[selector]>]||false>: - define perms:!|:.items.<[icon]>.permissions]||> - foreach <[perms]>: - if ]||false> || ]> || : - define ok:true - foreach stop - if <[ok]||false>: - if : - define placeholder:> - define feedback:<[placeholder].replace[[args]].with[]> - define path:!|:tabs|<[selector]>|items|<[icon]> - define keys:]> - inject path:<[path].separated_by[.]>.script - else: - define feedback:> - else: - define feedback:> - if <[feedback].exists>: - inject >]> #TO DO: Add support for sub-menu items #TO DO: Add support for line-break items sc_tw_menu: type: inventory debug: false title: .sc_tw.selector]>.title].unescaped.parse_color||<&c>Error> size: >].add[2].mul[9].min[54].max[27]> procedural items: - define selector:.sc_tw.selector]||>> - define index:.sc_tw.index]||1> - define slots:>].round_down.mul[9].min[36].max[9]> - define items:.items].alphanumeric> - define range:<[items].get[<[index]>].to[<[index].add[<[slots]>].sub[1]>]> - foreach <[range]||> as:node: - define perms:!|:.items.<[node]>.permissions]||> - foreach <[perms]>: - if ]||false>: - define material:.items.<[node]>.icon]||air> - define display:.items.<[node]>.display].parsed||&cError> - define lore:.items.<[node]>.lore].parsed||> - define icon:].with[display_name=<[display]>;lore=<[lore]>;nbt=type/icon|data/<[node]>;flags=HIDE_ENCHANTS|HIDE_ATTRIBUTES]||> - if .items.<[node]>.glow].parsed||false>: - adjust def:icon enchantments:protection,1 - define icons:|:<[icon]> - foreach stop - repeat <[slots].sub[<[range].size>]>: - define icons:|: - define divider:> - repeat 9: - define icons:|:].with[display_name=&sp]> - if <[index].is[MORE].than[1]||false>: - define prev:]>]> - else: - define prev:]> - define icons:|:<[prev]> - define buttons:>> - define active:.sc_tw.selector]||>> - define tabindex:<[buttons].find[<[active]>]||1> - define offset:<[tabindex].min[<[buttons].size.sub[3]>].sub[<[buttons].size.min[4]>].max[0]> - define buttons:!|:<[buttons].get[<[offset].add[1]||1>].to[<[offset].add[7]||7>]> - foreach <[buttons]>: - define icon:.icon]||barrier> - define display:.display]||&cError> - define lore:.lore]||> - define button:].with[display_name=<[display]>;lore=<[lore]>;nbt=type/tab|data/<[value]>;flags=HIDE_ENCHANTS|HIDE_ATTRIBUTES|HIDE_POTION_EFFECTS]> - if <[value].matches[<[active]>]||false>: - adjust def:button enchantments:protection,1 - define tabs:|:<[button]> - define icons:|:<[tabs].pad_right[7].with[]> - if <[items].size.is[MORE].than[<[index].add[<[slots]>]>]||false>: - define next:]>]> - else: - define next:]> - define icons:|:<[next]> - determine <[icons].unescaped.parse_color> #TO DO: Read list position of subkeys and parse code execution in order specified sc_tw_listener: type: world debug: false events: on reload scripts: - if : - inject on server start priority:1: - inject on shutdown: - define namespace:sc_tw - yaml set tabs:! id:sc_tw - inject on delta time hourly: - define namespace:sc_tw - define silent:true - inject - if : - inject ]> on player receives commands: - if : - determine on player clicks in sc_tw_menu: - determine passively cancelled - define namespace:sc_tw - define type: - if <[type].matches[null]||false>: - stop - else if <[type].matches[prev|next]||null>: - define index: - yaml set .sc_tw.index:<[index]> id:sc_pcache - else if <[type].matches[tab]||null>: - yaml set .sc_tw.index:1 id:sc_pcache - yaml set .sc_tw.selector: id:sc_pcache - else: - define selector:.sc_tw.selector]||null> - define path:!|:tabs|<[selector]>|items| - define stay:.stay]||true> - define keys:]> - inject - inventory open d: on player drags in sc_tw_menu: - determine cancelled sc_tw_execute: type: task debug: false definitions: keys|path script: - if <[keys].contains[script]>: - inject .scriptname]>]> path:<[path].separated_by[.]>.script - if <[keys].contains[scommand]>: - foreach .scommand].replace[%p].with[]>: - execute as_server '<[value].parsed>' - if <[keys].contains[pcommand]>: - foreach .pcommand]>: - execute as_player '<[value].parsed>' - if .stay]||true>: - inventory open d: - if <[keys].contains[message]>: - define title:.message].parsed||&cError> - inject >]> - else: - inventory close - if <[keys].contains[message]>: - define feedback:.message].parsed||&cError> - inject >]> - stop sc_tw_data: type: yaml data version: 1.2 filename: tabworks.yml scripts: reload: sc_tw_init save: sc_common_save update: sc_common_update sc_tw_defaults: type: yaml data settings: rows: 1 divider: vine default: options update: true scripts: narrator: sc_common_feedback GUI: sc_common_marquee permissions: admin: tabworks.admin use: tabworks.use messages: prefix: '&9[&aTab&2Works&9]' reload: '&9Plugin has been reloaded.' description: 'Multidimensional GUI fit for almost any purpose.' missing_common: '&This plugin uses code contained in sc_common.yml. Visit https://smellycraft.com/d/common for the most recent version.' missing_script: '&9 Script &a[script] &9was not detected. &c Installation not complete. &9An alternative is available in the Common Files.' args_i: '&9Unused arguments: &c[args]' badmenu: - '&cPlease select a choice from the provided list'