# dminereset system
# mine admins require op or dminereset.command permission
# mines are stored in dmineresets_saves.yml and it is editable and reloadable.
# Created by Talamar1
dminereset:
type: world
debug: false
events:
on server start:
- run dminereset_task_init delay:5t
dminereset_task_init:
type: task
debug: false
script:
- inject dminereset_command_reload
- ^flag server dmr:!
- ^foreach <yaml[dminereset_saves].list_keys[dmr.mines].filter[is[!=].to[default]]> {
- run dminereset_queue_check def:%value%
}
dminereset_dmr:
type: command
debug: false
name: dmr
description: dMineReset Command
usage: /dmr <&lb>command<&rb> (arg1<&pipe>arg2...)
aliases:
dminereset
Line with no clear purpose - missing a -dash- or :colon:?
script:
- if <context.args.size||0> == 0 {
- inject dminereset_command_help
- queue clear
}
- define arg1 <context.args.get[1].escaped>
- define cmdList li@create|delete|rename|set|resize|disable|enable|list|clear|reload|reset|tp|save
- if <def[cmdList].contains[%arg1%]> {
- if <context.server> || <player.has_permission[dminereset.%arg1%]||false> {
- inject dminereset_command_%arg1%
- queue clear
}
else {
- narrate "<&6>You do not have permission to use that dminereset command."
- queue clear
}
}
- inject dminereset_command_help
dminereset_command_help:
type: task
debug: false
script:
- if <player.has_permission[dminereset.create]> narrate "<&6>/dmr create <&lb>minename<&rb>"
- if <player.has_permission[dminereset.delete]> narrate "<&6>/dmr delete <&lb>minename<&rb>"
- if <player.has_permission[dminereset.save]> narrate "<&6>/dmr save"
- if <player.has_permission[dminereset.set]> narrate "<&6>/dmr set <&lb>minename<&rb> <<>setting<>> <<>value<>>"
- if <player.has_permission[dminereset.select]> narrate "<&6>/dmr select <&lb>minename<&rb>"
- if <player.has_permission[dminereset.resize]> narrate "<&6>/dmr resize <&lb>minename<&rb>"
- if <player.has_permission[dminereset.rename]> narrate "<&6>/dmr rename <&lb>old minename<&rb> <&lb>new minename<&rb>"
- if <player.has_permission[dminereset.reload]> narrate "<&6>/dmr reload"
- if <player.has_permission[dminereset.clear]> narrate "<&6>/dmr clear"
- if <player.has_permission[dminereset.reset]> narrate "<&6>/dmr reset <&lb>minename<&rb>"
- if <player.has_permission[dminereset.list]> narrate "<&6>/dmr list"
dminereset_command_create:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> {
- narrate "<&6>/dmr create <<>mine name<>>"
- narrate "<&6>mine name - name for your mine"
- queue clear
}
- define arg2 <context.args.get[2]>
- if %arg2% != <def[arg2].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- if <yaml[dminereset_saves].contains[dmr.mines.%arg2%]> {
- narrate "<&6>mine with that name already exists."
- queue clear
}
- if li@help|false|true|null contains %arg2% {
- narrate "<&6>That is not a valid mine name."
- queue clear
}
- if <player.selected_region.is[==].to[null]||true> {
- narrate "<&6>You don't have an area selected with WorldEdit wand."
- queue clear
}
- narrate "Creating new mine"
- run dminereset_task_yaml_copy def:dmr.mines.default|dmr.mines.%arg2% instantly
- inject dminereset_command_save
- note <player.selected_region> as:dmr_%arg2%
- flag player dmr.edit:%arg2%
- narrate "mine created."
dminereset_command_save:
type: task
debug: false
script:
- ^yaml savefile:dminereset_saves.yml id:dminereset_saves
dminereset_command_delete:
type: task
debug: false
script:
- define mine <context.args.get[2]||<player.flag[dmr.edit]||<def[1]||help>>>
- if %mine% == help {
- narrate "<&6>/dmr delete <<>mine Name<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- narrate "Deleting selected mine."
- yaml id:dminereset_saves set dmr.mines.%mine%:!
- flag player dmr.edit:!
- note remove as:dmr_%mine%
- inject dminereset_command_save
dminereset_command_reset:
type: task
debug: false
script:
- define mine <context.args.get[2]||<player.flag[dmr.edit]||<def[1]||help>>>
- if %mine% == help {
- narrate "<&6>/dmr delete <<>mine Name<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- narrate "Resetting mine<&co> %mine%."
- if <yaml[dminereset_saves].contains[dmr.mines.%mine%.physics]> {
- modifyblock cu@dmr_%mine% <yaml[dminereset_saves].read[dmr.mines.%mine%.materials]> <yaml[dminereset_saves].read[dmr.mines.%mine%.percentages]>
} else {
- modifyblock cu@dmr_%mine% <yaml[dminereset_saves].read[dmr.mines.%mine%.materials]> no_physics <yaml[dminereset_saves].read[dmr.mines.%mine%.percentages]>
}
dminereset_command_reload:
type: task
debug: false
script:
- ^if <yaml.list.contains[dminereset_saves]> yaml unload id:dminereset_saves
- ^if <server.has_file[dminereset_saves.yml]> {
- announce "<red><&lb>dminereset<&rb> <green>Loading MineReset Config File"
- yaml load:dminereset_saves.yml id:dminereset_saves
}
else {
- announce "<red><&lb>dminereset<&rb> <green>Creating MineReset Config File"
- yaml create id:dminereset_saves
- yaml savefile:dminereset_saves.yml id:dminereset_saves
- inject dminereset_command_reset_default
}
dminereset_command_clear:
type: task
debug: false
script:
- yaml unload id:dminereset_saves
- yaml create id:dminereset_saves
- inject dminereset_command_save
dminereset_command_select:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> {
- narrate "<&6>/dmr select <<>mine name<>>"
- narrate "<&6>mine name - name for your mine"
- queue clear
}
- if <context.args.get[2].is[!=].to[<context.args.get[2].escaped>]> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- define arg2 <context.args.get[2]>
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%arg2%]> {
- narrate "<&6>Selecting mine with name<&co> %arg2%"
- flag player dmr.edit:%arg2%
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_resize:
type: task
debug: false
script:
- if !<player.has_flag[dmr.edit]> {
- narrate "You don't have an mine selected."
- queue clear
}
- if <player.selected_region.is[==].to[null]||true> {
- narrate "<&6>You don't have an area selected with WorldEdit wand."
- queue clear
}
- narrate "Resizing mine %mine%"
- yaml id:dminereset_saves set dmr.mines.<player.flag[dmr.edit]>.cuboid:<player.selected_region>
- inject dminereset_command_save
- note <player.selected_region> as:dmr_<player.flag[dmr.edit]>
- narrate "Mine resized."
dminereset_command_blockmgmt:
type: task
debug: false
script:
- define arg2 <context.args.get[2]||help>
- define arg3 <context.args.get[3]||li@>
- if %arg2% == help || ( li@add|del contains %arg2% && <def[arg3].as_list.size> <= 0 ) {
- narrate "<&6>/dmr %arg1% add - add block(s) to list"
- narrate "<&6>/dmr %arg1% del - delete block(s) from list"
- narrate "<&6>/dmr %arg1% list - list all blocks"
- narrate "<&6>/dmr %arg1% clear - clear all blocks in list"
- queue clear
}
- if !<player.has_flag[dmr.edit]> {
- narrate "You don't have an mine selected."
- queue clear
}
- define mine <player.flag[dmr.edit]>
- define settings li@add|del|list|clear
- if <def[settings].contains[%arg2%]> inject dminereset_blockmgmt_%arg2%
else narrate "Invalid %arg1% command"
dminereset_blockmgmt_add:
type: task
debug: false
script:
- define mine <def[mine]||<def[1]||0>>
- define arg1 <def[arg1]||<def[1]||0>>
- define arg3 <def[arg3]||<def[3].unescaped||li@>>
- if %arg3% == help {
- narrate "<&6>/dmr %arg1% add <<>value<&pipe>value<&pipe>...<>>"
- narrate "Where <&dq>value<&dq> is a <&pipe> separated list of block or material IDs."
- queue clear
}
- foreach <el@val[%arg3%].as_list> {
- define newmat <el@val[%value%].as_material||null>
- if <def[newmat].is[!=].to[null]> {
- narrate "%value% is %newmat%"
- if !<yaml[dminereset_saves].read[dmr.mines.%mine%.settings.%arg1%].contains[%newmat%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.%arg1%:->:%newmat%
- narrate "Added blocks to %arg1% list for %mine%"
}
else {
- narrate "Item already in list"
}
}
else {
- narrate "%value% is not a valid block or item"
}
}
- inject dminereset_command_save
dminereset_blockmgmt_del:
type: task
debug: false
script:
- if %arg3% == help {
- narrate "<&6>/dmr %arg1% del <<>value<&pipe>value<&pipe>...<>>"
- narrate "Where <&dq>value<&dq> is a <&pipe> separated list of block or material IDs."
- queue clear
}
- foreach <def[arg3]> {
- define newmat <el@val[%value%].unescaped.as_material||null>
- if <def[newmat].is[!=].to[null]> {
- narrate "%newmat% is valid"
- if <yaml[dminereset_saves].read[dmr.mines.%mine%.settings.%arg1%].contains[%newmat%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.%arg1%:<-:%newmat%
- narrate "Deleted blocks from %arg1% list for %mine%"
}
}
else {
- narrate "%value% is not a valid block or item"
}
}
- inject dminereset_command_save
dminereset_blockmgmt_list:
type: task
debug: false
script:
- if <yaml[dminereset_saves].read[dmr.mines.%mine%.settings.%arg1%].size||0> > 0 {
- define blocklist <yaml[dminereset_saves].read[dmr.mines.%mine%.settings.%arg1%].replace[li@]>
- narrate "%blocklist%"
}
dminereset_blockmgmt_clear:
type: task
debug: false
script:
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.%arg1%:!
- narrate "Cleared blocks from %arg1% list for %mine%"
- inject dminereset_command_save
dminereset_command_rename:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> || <context.args.get[3].is[==].to[null]||true> {
- narrate "<&6>/dmr select <<>mine name<>>"
- narrate "<&6>mine name - name for your mine"
- queue clear
}
- if <context.args.get[2].is[!=].to[<context.args.get[2].escaped>]> || <context.args.get[3].is[!=].to[<context.args.get[3].escaped>]> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- define arg2 <context.args.get[2]>
- define arg3 <context.args.get[3]>
- if li@help|false|true|null|%arg2% contains %arg3% {
- narrate "<&6>That is not a valid mine name."
- queue clear
}
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%arg2%]> {
- narrate "<&6>Renaming mine with name<&co> %arg2% to<&co> %arg3%"
- run dminereset_task_yaml_copy def:dmr.mines.%arg2%|dmr.mines.%arg3% instantly
- run dminereset_command_delete def:%arg2% instantly
- note <yaml[dminereset_saves].read[dmr.mines.%arg3%.cuboid]||cu@0,0,0,world|0,0,0,world> as:dmr_%arg3%
- inject dminereset_command_save
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_lock:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dmr.edit]> {
- narrate "<&6>/dmr locked <<>mine ID<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if <context.args.get[2].is[==].to[null]||true> define mine <player.flag[dmr.edit]>
else define mine <context.args.get[2]>
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%mine%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.locked:true
- narrate "<&6>Locking mine with name: %mine%"
- inject dminereset_task_scan_chests
- inject dminereset_command_save
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_unlock:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dmr.edit]> {
- narrate "<&6>/dmr locked <<>mine ID<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if <context.args.get[2].is[==].to[null]||true> define mine <player.flag[dmr.edit]>
else define mine <context.args.get[2]>
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%mine%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.locked:false
- narrate "<&6>Unlocking mine with name: %mine%"
- inject dminereset_command_save
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_enable:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dmr.edit]> {
- narrate "<&6>/dmr enable <<>mine ID<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if <context.args.get[2].is[==].to[null]||true> define mine <player.flag[dmr.edit]>
else define mine <context.args.get[2]>
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%mine%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.enable:true
- narrate "<&6>Enabling mine with name: %mine%"
- inject dminereset_command_save
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_disable:
type: task
debug: false
script:
- if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dmr.edit]> {
- narrate "<&6>/dmr enable <<>mine ID<>>"
- narrate "<&6>Either select an mine or provide an mine name"
- queue clear
}
- if <context.args.get[2].is[==].to[null]||true> define mine <player.flag[dmr.edit]>
else define mine <context.args.get[2]>
- if %mine% != <def[mine].escaped> {
- narrate "<&6>That value doesn't look right."
- queue clear
}
- if <yaml[dminereset_saves].list_keys[dmr.mines].contains[%mine%]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.enable:false
- narrate "<&6>Disabling mine with name: %mine%"
- inject dminereset_command_save
}
else {
- narrate "<&6>mine with that name not found."
}
dminereset_command_list:
type: task
debug: false
script:
- foreach <yaml[dminereset_saves].list_keys[dmr.mines]> {
- narrate "<&6>mine: %value%"
}
dminereset_command_set:
type: task
debug: false
script:
- define arg2 <context.args.get[2]||help>
- define arg3 <context.args.get[3]||help>
- if %arg2% == help {
- narrate "<&6>/dmr set <<>setting<>> <<>value<>>"
- narrate "<&6>setting - setting to change"
- narrate "<&6><&sp><&sp><&sp>restock"
- narrate "<&6><&sp><&sp><&sp>min_players"
- narrate "<&6><&sp><&sp><&sp>max_players"
- narrate "<&6><&sp><&sp><&sp>lightning"
- narrate "<&6><&sp><&sp><&sp>lightning_delay"
- narrate "<&6><&sp><&sp><&sp>countdown"
- narrate "<&6><&sp><&sp><&sp>timer"
- narrate "<&6>value - value to assign to setting"
- queue clear
}
- if !<player.has_flag[dmr.edit]> {
- narrate "You don't have an mine selected."
- queue clear
}
- define mine <player.flag[dmr.edit]>
- define settings li@restock|min_players|max_players|lightning|lightning_delay|countdown|timer
- if <def[settings].contains[%arg2%]> {
- inject dminereset_setting_%arg2%
}
else {
- narrate "Invalid setting"
- queue clear
}
dminereset_setting_countdown:
type: task
debug: false
script:
- if <def[arg3].is[matches].to[integer]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.countdown:%arg3%
- narrate "<&6>Changing COUNTDOWN on mine <<>%mine%<>> with value: %arg3%"
- inject dminereset_command_save
}
else {
- narrate "<&6>/dmr set countdown <<>value<>>"
- narrate "<&6>Number = Seconds to countdown at start of game."
- narrate "<&6>Available values are numbers > 0 "
- narrate "<&6>Default is 10"
}
dminereset_setting_timer:
type: task
debug: false
script:
- if <def[arg3].is[matches].to[integer]> {
- yaml id:dminereset_saves set dmr.mines.%mine%.settings.timer:%arg3%
- narrate "<&6>Changing TIMER on mine <<>%mine%<>> with value: %arg3%"
- inject dminereset_command_save
}
else {
- narrate "<&6>/dmr set countdown <<>value<>>"
- narrate "<&6>Number = Timer to wait for players to join."
- narrate "<&6>Available values are numbers > 0 "
- narrate "<&6>Default is 30"
}
dminereset_task_block_rollback:
type: task
debug: false
script:
- ^define mine %1%
- ^if <yaml[dminereset_saves].contains[dmr.mines.%mine%.track]||false> {
- if <yaml[dminereset_saves].contains[dmr.mines.%mine%.track.break]> {
- foreach <yaml[dminereset_saves].read[dmr.mines.%mine%.track.break]> {
- modifyblock <def[value].get[1]> <def[value].get[2]>
}
}
- if <yaml[dminereset_saves].contains[dmr.mines.%mine%.track.place]> {
- foreach <yaml[dminereset_saves].read[dmr.mines.%mine%.track.place]> {
- modifyblock <def[value].get[1]> m@air
}
}
- yaml id:dminereset_saves set dmr.mines.%mine%.track:!
- inject dminereset_command_save
}
dminereset_task_yaml_copy:
type: task
debug: false
script:
- define sourcekey %1%
- define destkey %2%
- if <yaml[dminereset_saves].contains[%1%].not> {
- narrate "Source invalid for yaml copy"
- queue stop
}
- if <yaml[dminereset_saves].list_keys[%1%].size||0> > 0 {
- foreach <yaml[dminereset_saves].list_keys[%1%]||li@> {
- run dminereset_task_yaml_copy def:%1%.%value%|%2%.%value% instantly
}
}
else {
- if <yaml[dminereset_saves].is_list[%1%]> {
- foreach <yaml[dminereset_saves].read[%1%]> {
- yaml id:dminereset_saves set %2%:->:%value%
}
}
else {
- yaml id:dminereset_saves set %2%:<yaml[dminereset_saves].read[%1%]>
}
}