+# dHunger system
+# Arena admins require op or dhunger.command permission
+# Arenas are stored in dHungers_saves.yml and it is editable and reloadable.
+# Created by Talamar1
+
+dHunger:
+ type: world
+ debug: false
+ events:
+ on server start:
+ - run dhunger_task_init delay:1t
+
+ on shutdown:
+ - run dhunger_task_init delay:1t
+
+ on player clicks wall_sign:
+ - define sign <context.location.block>
+ - wait 1t
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas].exclude[default]> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.board].as_list.contains[%sign%]||false> && <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.enable]||false> && <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.max_players]||20> >= <server.flag[dhg.%value%.players].size||0> {
+ - if <player.has_flag[dhg.play]> determine cancelled
+ - flag <player> dhg.play:%value%
+ - inject dhunger_command_join
+ - foreach stop
+ }
+ }
+
+ on player joins:
+ - if <player.has_flag[dhg]> {
+ - flag <player> dhg:!
+ }
+ - if <yaml[dhunger_saves].contains[dhg.player.<player.uuid>]> {
+ - inject dhunger_task_cleanup_player
+ }
+ - teleport <player> <yaml[dhunger_saves].read[dhg.lobby]||<player.location.world.spawn_location>>
+
+ on player quits:
+ - if <player.has_flag[dhg.play]> {
+ - define arena <player.flag[dhg.play]>
+ - inject dhunger_remove_player
+ - run dhunger_check_end_of_game def:%arena% instantly
+ - flag <player> dhg:!
+ }
+
+ on player killed:
+ - if <player.has_flag[dhg.play]> {
+ - define arena <player.flag[dhg.play]>
+ - narrate "<context.entity.name> was killed by <tern[<context.damager.is_player>]:<context.damager.name>||<context.cause>> in arena %arena%" targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ - inject dhunger_remove_player
+ - run dhunger_check_end_of_game def:%arena% instantly
+ - determine cancelled
+ }
+
+ on player breaks block in notable cuboid:
+ - foreach <context.location.cuboids.parse[notable_name].filter[starts_with[dhg_]].parse[after[dhg_]]> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.locked]||false> && <yaml[dhunger_saves].contains[dhg.arenas.%value%.settings.breakable]> {
+ - if !<yaml[dhunger_saves].read[dhg.arenas.%value%.settings.breakable].contains[<context.material>]> {
+ - determine cancelled
+ - foreach stop
+ }
+ else {
+ - run dhunger_task_block_track def:break|%value%|<context.location>|<context.material>
+ - foreach stop
+ }
+ }
+ }
+
+ on player places block in notable cuboid:
+ - foreach <context.location.cuboids.parse[notable_name].filter[starts_with[dhg_]].parse[after[dhg_]]> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.locked]||false> && <yaml[dhunger_saves].contains[dhg.arenas.%value%.settings.placeable]> {
+ - if !<yaml[dhunger_saves].read[dhg.arenas.%value%.settings.placeable].contains[<context.material>]> {
+ - determine cancelled
+ - foreach stop
+ }
+ else {
+ - run dhunger_task_block_track def:place|%value%|<context.location>|<context.material>
+ - foreach stop
+ }
+ }
+ }
+
+ on block ignites:
+ - inject dhunger_task_block_change_check
+
+ on block burns:
+ - inject dhunger_task_block_change_check
+
+ on block forms:
+ - inject dhunger_task_block_change_check
+
+ on block fades:
+ - inject dhunger_task_block_change_check
+
+ on block builds:
+ - inject dhunger_task_block_change_check
+
+ on entity spawns:
+ - if !<server.has_flag[dhg.loaded]> queue clear
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas].exclude[default]> {
+ - if <context.entity.location.is_within[cu@dhg_%value%]> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.locked]||false> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.spawnable].as_list||li@> !contains <context.entity> {
+ - determine cancelled
+ }
+ }
+ }
+ }
+
+dhunger_task_init:
+ type: task
+ debug: false
+ script:
+ - ^flag server dhg:!
+ - inject dhunger_command_reload
+ - ^foreach <yaml[dhunger_saves].list_keys[dhg.arenas].filter[is[!=].to[default]]> {
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%value%.cuboid]> {
+ - define area <yaml[dhunger_saves].read[dhg.arenas.%value%.cuboid]>
+ - if <def[area].as_cuboid.notable_name> == null {
+ - note %area% as:dhg_%value%
+ }
+ }
+ - run dhunger_check_end_of_game def:%value%
+ }
+
+dhunger_dhg:
+ type: command
+ debug: false
+ name: dhg
+ description: dHunger Command
+ usage: /dhg <<>arg1<&pipe>arg2...<>>
+ aliases:
+ - dhunger
+ script:
+ - if <context.args.size||0> == 0 {
+ - inject dhunger_command_help
+ - queue clear
+ }
+ - define arg1 <context.args.get[1].escaped>
+ - define cmdList li@create|save|delete|spawn|rename|set|breakable|placeable|lock|unlock|resize|board|disable|enable|start|stop|quit|select|list|clear|reload|lobby|vote|tier1|tier2|scan_chests|reset_default|join|spawnable
+ - if <def[cmdList].contains[%arg1%]> {
+ - if <context.server> || <player.has_permission[dhunger.%arg1%]||false> {
+ - if li@placeable|breakable contains %arg1% inject dhunger_command_blockmgmt
+ else if li@tier1|tier2 contains %arg1% inject dhunger_command_tier
+ else inject dhunger_command_%arg1%
+ - queue clear
+ }
+ else {
+ - narrate "<&6>You do not have permission to use the dhunger command."
+ - queue clear
+ }
+ }
+ - inject dhunger_command_help
+
+dhunger_command_help:
+ type: task
+ debug: false
+ script:
+ - if <player.has_permission[dhunger.create]> narrate "<&6>/dhg create <<>arena name<>>"
+ - if <player.has_permission[dhunger.save]> narrate "<&6>/dhg save"
+ - if <player.has_permission[dhunger.delete]> narrate "<&6>/dhg delete <<>arena name<>>"
+ - if <player.has_permission[dhunger.spawn]> narrate "<&6>/dhg spawn <&lb>add<&rb>/<&lb>del <<>id<>><&rb>/<&lb>list<&rb>/<&lb>show<&rb>"
+ - if <player.has_permission[dhunger.breakable]> narrate "<&6>/dhg breakable <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>"
+ - if <player.has_permission[dhunger.placeable]> narrate "<&6>/dhg placeable <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>"
+ - if <player.has_permission[dhunger.tier1]> narrate "<&6>/dhg tier1 <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>"
+ - if <player.has_permission[dhunger.tier2]> narrate "<&6>/dhg tier2 <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>"
+ - if <player.has_permission[dhunger.set]> narrate "<&6>/dhg set <<>setting<>> <<>value<>>"
+ - if <player.has_permission[dhunger.board]> narrate "<&6>/dhg board <&lb>add<&rb>/<&lb>del<&rb>"
+ - if <player.has_permission[dhunger.lock]> narrate "<&6>/dhg lock <<>arena name<>>"
+ - if <player.has_permission[dhunger.unlock]> narrate "<&6>/dhg unlock <<>arena name<>>"
+ - if <player.has_permission[dhunger.disable]> narrate "<&6>/dhg disable <<>arena name<>>"
+ - if <player.has_permission[dhunger.enable]> narrate "<&6>/dhg enable <<>arena name<>>"
+ - if <player.has_permission[dhunger.start]> narrate "<&6>/dhg start <<>arena name<>>"
+ - if <player.has_permission[dhunger.stop]> narrate "<&6>/dhg stop <<>arena name<>>"
+ - if <player.has_permission[dhunger.select]> narrate "<&6>/dhg select <<>arena name<>>"
+ - if <player.has_permission[dhunger.resize]> narrate "<&6>/dhg resize"
+ - if <player.has_permission[dhunger.reload]> narrate "<&6>/dhg reload"
+ - if <player.has_permission[dhunger.clear]> narrate "<&6>/dhg clear"
+ - if <player.has_permission[dhunger.reset_default]> narrate "<&6>/dhg reset_default"
+ - if <player.has_permission[dhunger.join]> narrate "<&6>/dhg join <&lb>Arena Name<&rb>"
+ - if <player.has_permission[dhunger.list]> narrate "<&6>/dhg list"
+ - if <player.has_permission[dhunger.quit]> narrate "<&6>/dhg quit"
+
+dhunger_command_create:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> {
+ - narrate "<&6>/dhg create <<>arena name<>>"
+ - narrate "<&6>arena name - name for your arena"
+ - 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[dhunger_saves].contains[dhg.arenas.%arg2%]> {
+ - narrate "<&6>Arena with that name already exists."
+ - queue clear
+ }
+ - if li@help|false|true|null contains %arg2% {
+ - narrate "<&6>That is not a valid arena 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 arena"
+ - run dhunger_task_yaml_copy def:dhg.arenas.default|dhg.arenas.%arg2% instantly
+ - inject dhunger_command_save
+ - note <player.selected_region> as:dhg_%arg2%
+ - flag player dhg.edit:%arg2%
+ - narrate "Arena created."
+
+dhunger_command_save:
+ type: task
+ debug: false
+ script:
+# - ^if <player.is_online> narrate "Saving Hunger Games"
+ - ^yaml savefile:dhunger_saves.yml id:dhunger_saves
+
+dhunger_command_delete:
+ type: task
+ debug: false
+ script:
+ - define arena <context.args.get[2]||<player.flag[dhg.edit]||<def[1]||help>>>
+ - if %arena% == help {
+ - narrate "<&6>/dhg delete <<>Arena Name<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - narrate "Deleting selected arena."
+ - yaml id:dhunger_saves set dhg.arenas.%arena%:!
+ - flag player dhg.edit:!
+ - note remove as:dhg_%arena%
+ - inject dhunger_command_save
+
+dhunger_command_reset_default:
+ type: task
+ debug: false
+ script:
+ - narrate "Setting up default arena values."
+ - ^yaml id:dhunger_saves set dhg.arenas.default:!
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.max_players:20
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.min_players:2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.lightning:2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.lightning_delay:60
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.locked:false
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.enable:false
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.timer:30
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.countdown:10
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.restock:0
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.placeable:|:m@melon_block|m@tnt|m@cake
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.spawnable:|:e@bat|e@pig|e@squid|e@villager|e@rabbit|e@sheep|e@cow|e@horse|e@chicken|e@donkey|e@wolf|e@ocelot|e@mule
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_chestplate:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@carrot:|:25|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@rabbit:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@stone_sword:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@fishing_rod:|:25|3
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@iron_ingot:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@feather:|:20|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@gold_sword:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@wood_sword:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@pork:|:25|3
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@stick:|:25|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_helmet:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_beef:|:20|4
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_boots:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@string:|:25|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@arrow:|:25|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@flint:|:15|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_leggings:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@cookie:|:5|2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_fish:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@gold_ingot:|:10|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_chicken:|:20|4
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@potato:|:15|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@bow:|:25|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@apple:|:25|3
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@pumpkin_pie:|:5|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@baked_potato:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_chicken:|:20|2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cake:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@ender_pearl:|:20|2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_rabbit:|:10|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_chestplate:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@grilled_pork:|:20|3
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_boots:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@melon_block:|:15|4
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_leggings:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_leggings:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@mushroom_soup:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_helmet:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_chestplate:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@nether_warts:|:5|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_boots:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@diamond:|:5|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_boots:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@flint_and_steel:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@golden_apple:|:10|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@golden_carrot:|:5|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@glass_bottle:|:10|5
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_helmet:|:15|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_helmet:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_chestplate:|:20|1
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_beef:|:20|2
+ - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_leggings:|:15|1
+ - narrate "Finished setting up Default File."
+ - inject dhunger_command_save
+
+dhunger_command_reload:
+ type: task
+ debug: false
+ script:
+ - ^if <yaml.list.contains[dhunger_saves]> yaml unload id:dhunger_saves
+ - ^if <server.has_file[dhunger_saves.yml]> {
+ - announce "<red><&lb>dHunger<&rb> <green>Loading Hunger Config File"
+ - yaml load:dhunger_saves.yml id:dhunger_saves
+ }
+ else {
+ - announce "<red><&lb>dHunger<&rb> <green>Creating Hunger Config File"
+ - yaml create id:dhunger_saves
+ - yaml savefile:dhunger_saves.yml id:dhunger_saves
+ - inject dhunger_command_reset_default
+ }
+ - flag server dhg.loaded
+
+dhunger_command_clear:
+ type: task
+ debug: false
+ script:
+ - yaml unload id:dhunger_saves
+ - yaml create id:dhunger_saves
+ - inject dhunger_command_save
+
+dhunger_command_select:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> {
+ - narrate "<&6>/dhg select <<>arena name<>>"
+ - narrate "<&6>arena name - name for your arena"
+ - 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[dhunger_saves].list_keys[dhg.arenas].contains[%arg2%]> {
+ - narrate "<&6>Selecting arena with name<&co> %arg2%"
+ - flag player dhg.edit:%arg2%
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+
+dhunger_command_resize:
+ type: task
+ debug: false
+ script:
+ - define arena <context.args.get[2]||<player.flag[dhg.edit]||<def[1]||help>>>
+ - if %arena% == help {
+ - narrate "<&6>/dhg resize <<>Arena Name<>>"
+ - narrate "<&6>Either select an arena or provide an arena 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 "Resizing arena %arena%"
+ - yaml id:dhunger_saves set dhg.arenas.<player.flag[dhg.edit]>.cuboid:<player.selected_region>
+ - inject dhunger_command_save
+ - note <player.selected_region> as:dhg_<player.flag[dhg.edit]>
+ - narrate "Arena resized."
+
+dhunger_command_quit:
+ type: task
+ debug: false
+ script:
+ - if !<player.has_flag[dhg.play]> {
+ - narrate "You don't appear to be in a game."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.play]>
+ - narrate "Quitting arena game."
+ - narrate "<player.name> quit the arena." targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ - inject dhunger_remove_player
+ - run dhunger_check_end_of_game def:%arena%
+
+dhunger_command_spawn:
+ type: task
+ debug: false
+ script:
+ - define arg2 <context.args.get[2]||help>
+ - define arg3 <context.args.get[3]||0>
+ - if %arg2% == help {
+ - narrate "<&6>/dhg spawn add - add a new spawn"
+ - narrate "<&6>/dhg spawn del <<>ID<>> - delete spawn at ID number (use list)"
+ - narrate "<&6>/dhg spawn list - list all spawns"
+ - narrate "<&6>/dhg spawn clear - clear all spawns"
+ - narrate "<&6>/dhg spawn show - visually show spawns"
+ - queue clear
+ }
+ - if !<player.has_flag[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - if li@add|del|list|show|clear contains %arg2% {
+ - inject dhunger_spawn_%arg2%
+ }
+ else {
+ - narrate "Invalid setting"
+ }
+
+dhunger_spawn_add:
+ type: task
+ debug: false
+ script:
+ - if %arg3% == help {
+ - narrate "<&6>/dhg spawn add"
+ - narrate "<&6>Adds a spawnpoint to the selected arena."
+ - queue clear
+ }
+ - narrate "Adding new spawnpoint."
+ - define scount <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].size||0>
+ - define spawnpoint l@<player.location.block.x.add[.5]>,<player.location.block.y>,<player.location.block.z.add[.5]>,<player.location.pitch>,<player.location.yaw>,<player.location.world.name>
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.<def[scount].add[1]>:%spawnpoint%
+ - inject dhunger_command_save
+
+dhunger_spawn_del:
+ type: task
+ debug: false
+ script:
+ - if %arg3% == help || %arg3% == 0 {
+ - narrate "<&6>/dhg spawn del <<>spawnpoint<>>"
+ - narrate "<&6>spawnpoint - ID Number for spawnpoint"
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%arena%.spawnpoint.%arg3%]> {
+ - narrate "Removing spawnpoint."
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%arg3%:!
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].numerical> {
+ - define spawnpoint <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.%value%]>
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%value%:!
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%loop_index%:%spawnpoint%
+ }
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "Could not find that spawnpoint."
+ }
+
+dhunger_spawn_list:
+ type: task
+ debug: false
+ script:
+ - narrate "Listing spawnpoints:"
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].numerical> {
+ - narrate "<<>%value%<>> <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.%value%]>"
+ }
+
+dhunger_spawn_show:
+ type: task
+ debug: false
+ script:
+ - narrate "Showing spawnpoints:"
+ - repeat 10 {
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].numerical> {
+ - playeffect <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.%value%]> effect:red_dust qty:15
+ }
+ - wait 1s
+ }
+
+dhunger_spawn_clear:
+ type: task
+ debug: false
+ script:
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint:!
+ - inject dhunger_command_save
+
+dhunger_command_tier:
+ type: task
+ debug: false
+ script:
+ - define arg2 <context.args.get[2]||help>
+ - define arg3 <context.args.get[3]||li@>
+ - if !<player.has_flag[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - if %arg2% == help || ( li@add|del contains %arg2% && <def[arg3].as_list.size> <= 0 ) || ( li@add|del|list|clear|help !contains %arg2% ) {
+ - narrate "<gold>/dhg tier<&lb>1<&pipe>2<&rb> (add<&pipe>del) (item)(<&pc>percent)(<&ns>qty)"
+ - narrate "<gold><&sp><&sp><&sp>1 or 2 <green>the tier you want to modify"
+ - narrate "<gold><&sp><&sp><&sp>add or del <green>(optional<&cm> leaving it out overwites the whole list)"
+ - narrate "<gold><&sp><&sp><&sp>item <green>the item to modify"
+ - narrate "<gold><&sp><&sp><&sp><&pc>value <green>the chance item will be in chest (optional<&cm> default 25)"
+ - narrate "<gold><&sp><&sp><&sp><&ns>value <green>the max quantity to be in a chest (optional<&cm> default 1)"
+ - narrate "<gold>/dhg tier<&lb>1<&pipe>2<&rb> list"
+ - narrate "<gold>/dhg tier<&lb>1<&pipe>2<&rb> clear"
+ - queue clear
+ }
+ else if %arg2% == clear {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:!
+ - inject dhunger_command_save
+ - queue clear
+ }
+ else if %arg2% == list {
+ - narrate "%arg1% item list"
+ - if !<yaml[dhunger_saves].contains[dhg.arenas.%arena%.settings.%arg1%]> queue clear
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.settings.%arg1%]> {
+ - define itemvals <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.%arg1%.%value%]>
+ - narrate "<gold><&sp><&sp><&sp><def[value]><&sp><green><def[itemvals].get[1].pad_left[3]><&pc><&sp><white>qty<&co><def[itemvals].get[2]>"
+ }
+ - queue clear
+ }
+ - foreach %arg3% {
+ - define newitem <el@val[%value%].before[%].before[#].as_item||null>
+ - define percent <el@val[%value%].after[%].before[#].as_int||25>
+ - define qty <el@val[%value%].after[#].before[%].as_int||1>
+ - if <def[newitem].is[!=].to[null]> {
+ - narrate "%value% is %newitem% at %percent% qty %qty%"
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%.%newitem%:!
+ - if %arg2% == add {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%.%newitem%:|:%percent%|%qty%
+ }
+ }
+ else {
+ - narrate "%newitem% is not a valid item"
+ }
+ }
+ - inject dhunger_command_save
+
+dhunger_task_scan_chests:
+ type: task
+ debug: false
+ script:
+ - wait 1t
+ - if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dhg.edit]> && <def[arena].exists> {
+ - narrate "<&6>/dhg locked <<>Arena ID<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if !<def[arena].exists> {
+ - if <context.args.get[2].is[==].to[null]||true> {
+ - define arena <player.flag[dhg.edit]>
+ }
+ else {
+ - define arena <context.args.get[2]>
+ }
+ }
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%arena%]> && <server.list_notables[cuboids].contains[cu@dhg_%arena%]> {
+ - narrate "Processing chests in arena %arena"
+ - define length <cu@dhg_%arena%.min.x.sub[<cu@dhg_%arena%.max.x>].abs>
+ - define width <cu@dhg_%arena%.min.z.sub[<cu@dhg_%arena%.max.z>].abs>
+ - define height <cu@dhg_%arena%.min.y.sub[<cu@dhg_%arena%.max.y>].abs>
+ - define chunkie 100
+ - define chests li@
+ - repeat <def[length].div[%chunkie%].round_up> {
+ - define x_tick <def[value].sub[1]>
+ - repeat <def[width].div[%chunkie%].round_up> {
+ - define z_tick <def[value].sub[1]>
+ - repeat <def[height].div[%chunkie%].round_up> {
+ - define y_tick <def[value].sub[1]>
+ - foreach li@x|y|z {
+ - define %value%_min <cu@dhg_%arena%.min.%value%.add[<def[%value%_tick].mul[%chunkie%]>]>
+ - define %value%_max <cu@dhg_%arena%.min.%value%.add[<def[%value%_tick].add[1].mul[%chunkie%].sub[1]>]>
+ - if <def[%value%_max]> > <cu@dhg_%arena%.max.%value%> define %value%_max <cu@dhg_%arena%.max.%value%>
+ }
+ - define subcuboid cu@%x_min%,%y_min%,%z_min%,<cu@dhg_%arena%.min.world.name>|%x_max%,%y_max%,%z_max%,<cu@dhg_%arena%.min.world.name>
+ - define chests <def[chests].include[<def[subcuboid].get_blocks[chest,1|chest,2|chest,3|chest,4|chest,5|chest,6|trapped_chest,1|trapped_chest,2|trapped_chest,3|trapped_chest,4|trapped_chest,5|trapped_chest,6]>]>
+ - wait 1t
+ }
+ }
+ }
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier1_chests:!
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier2_chests:!
+ - foreach %chests% {
+ - narrate "Chest %value% material <def[value].material.name>"
+ - if <def[value].material.name> == chest {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier1_chests:->:%value%
+ }
+ else {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier2_chests:->:%value%
+ }
+ }
+ - inject dhunger_command_save
+ - narrate "found <def[chests].size> chests "
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+ - narrate "Chest processing for arena %arena% complete"
+
+
+dhunger_command_spawnable:
+ type: task
+ debug: false
+ script:
+ - define arg2 <context.args.get[2]||help>
+ - define arg3 <context.args.get[3]||li@>
+ - if !<player.has_flag[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - if %arg2% == help || ( li@add|del contains %arg2% && <def[arg3].as_list.size> <= 0 ) || ( li@add|del|list|clear|help !contains %arg2% ) {
+ - narrate "<gold>/dhg spawnable (add<&pipe>del) (entity|entity)"
+ - narrate "<gold><&sp><&sp><&sp>entity <green>the creature to allow spawning"
+ - narrate "<gold>/dhg spawnable list"
+ - narrate "<gold>/dhg spawnable clear"
+ - queue clear
+ }
+ else if %arg2% == clear {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:!
+ - narrate "Spawnable list cleared for arena %arena%"
+ - inject dhunger_command_save
+ - queue clear
+ }
+ else if %arg2% == list {
+ - narrate "Spawnable item list"
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%arena%.settings.spawnable].not> queue clear
+ - foreach <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.spawnable]> {
+ - narrate "<gold><&sp><&sp><&sp><def[value]>"
+ }
+ - queue clear
+ }
+ - foreach %arg3% {
+ - define entity <el@val[%value%].as_entity||false>
+ - if <def[entity].is[!=].to[false]> {
+ - narrate "%value% is %entity%"
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:<-:%entity%
+ - if %arg2% == add {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:->:%entity%
+ }
+ }
+ else {
+ - narrate "%entity% is not a valid item"
+ }
+ }
+ - inject dhunger_command_save
+
+dhunger_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>/dhg %arg1% add - add block(s) to list"
+ - narrate "<&6>/dhg %arg1% del - delete block(s) from list"
+ - narrate "<&6>/dhg %arg1% list - list all blocks"
+ - narrate "<&6>/dhg %arg1% clear - clear all blocks in list"
+ - queue clear
+ }
+ - if !<player.has_flag[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - define settings li@add|del|list|clear
+ - if <def[settings].contains[%arg2%]> inject dhunger_blockmgmt_%arg2%
+ else narrate "Invalid %arg1% command"
+
+dhunger_blockmgmt_add:
+ type: task
+ debug: false
+ script:
+ - define arena <def[arena]||<def[1]||0>>
+ - define arg1 <def[arg1]||<def[1]||0>>
+ - define arg3 <def[arg3]||<def[3].unescaped||li@>>
+ - if %arg3% == help {
+ - narrate "<&6>/dhg %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[dhunger_saves].read[dhg.arenas.%arena%.settings.%arg1%].contains[%newmat%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:->:%newmat%
+ - narrate "Added blocks to %arg1% list for %arena%"
+ }
+ else {
+ - narrate "Item already in list"
+ }
+ }
+ else {
+ - narrate "%value% is not a valid block or item"
+ }
+ }
+ - inject dhunger_command_save
+
+dhunger_blockmgmt_del:
+ type: task
+ debug: false
+ script:
+ - if %arg3% == help {
+ - narrate "<&6>/dhg %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[dhunger_saves].read[dhg.arenas.%arena%.settings.%arg1%].contains[%newmat%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:<-:%newmat%
+ - narrate "Deleted blocks from %arg1% list for %arena%"
+ }
+ }
+ else {
+ - narrate "%value% is not a valid block or item"
+ }
+ }
+ - inject dhunger_command_save
+
+dhunger_blockmgmt_list:
+ type: task
+ debug: false
+ script:
+ - if <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.%arg1%].size||0> > 0 {
+ - define blocklist <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.%arg1%].replace[li@]>
+ - narrate "%blocklist%"
+ }
+
+dhunger_blockmgmt_clear:
+ type: task
+ debug: false
+ script:
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:!
+ - narrate "Cleared blocks from %arg1% list for %arena%"
+ - inject dhunger_command_save
+
+dhunger_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>/dhg rename <<>arena name<>>"
+ - narrate "<&6>arena name - name for your arena"
+ - 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 arena name."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].list_keys[dhg.arenas].contains[%arg2%]> {
+ - narrate "<&6>Renaming arena with name<&co> %arg2% to<&co> %arg3%"
+ - run dhunger_task_yaml_copy def:dhg.arenas.%arg2%|dhg.arenas.%arg3% instantly
+ - run dhunger_command_delete def:%arg2% instantly
+ - note <yaml[dhunger_saves].read[dhg.arenas.%arg3%.cuboid]||cu@0,0,0,world|0,0,0,world> as:dhg_%arg3%
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+
+dhunger_command_lock:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dhg.edit]> {
+ - narrate "<&6>/dhg locked <<>Arena ID<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if <context.args.get[2].is[==].to[null]||true> define arena <player.flag[dhg.edit]>
+ else define arena <context.args.get[2]>
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].list_keys[dhg.arenas].contains[%arena%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.locked:true
+ - narrate "<&6>Locking arena with name: %arena%"
+ - inject dhunger_task_scan_chests
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+dhunger_command_unlock:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dhg.edit]> {
+ - narrate "<&6>/dhg locked <<>Arena ID<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if <context.args.get[2].is[==].to[null]||true> define arena <player.flag[dhg.edit]>
+ else define arena <context.args.get[2]>
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].list_keys[dhg.arenas].contains[%arena%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.locked:false
+ - narrate "<&6>Unlocking arena with name: %arena%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+dhunger_command_enable:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dhg.edit]> {
+ - narrate "<&6>/dhg enable <<>Arena ID<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if <context.args.get[2].is[==].to[null]||true> define arena <player.flag[dhg.edit]>
+ else define arena <context.args.get[2]>
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].list_keys[dhg.arenas].contains[%arena%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.enable:true
+ - narrate "<&6>Enabling arena with name: %arena%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+dhunger_command_disable:
+ type: task
+ debug: false
+ script:
+ - if <context.args.get[2].is[==].to[null]||true> && !<player.has_flag[dhg.edit]> {
+ - narrate "<&6>/dhg enable <<>Arena ID<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if <context.args.get[2].is[==].to[null]||true> define arena <player.flag[dhg.edit]>
+ else define arena <context.args.get[2]>
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <yaml[dhunger_saves].list_keys[dhg.arenas].contains[%arena%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.enable:false
+ - narrate "<&6>Disabling arena with name: %arena%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>Arena with that name not found."
+ }
+
+dhunger_command_list:
+ type: task
+ debug: false
+ script:
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas]> {
+ - narrate "<&6>Arena: %value%"
+ }
+
+dhunger_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>/dhg 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[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - define settings li@restock|min_players|max_players|lightning|lightning_delay|countdown|timer
+ - if <def[settings].contains[%arg2%]> {
+ - inject dhunger_setting_%arg2%
+ }
+ else {
+ - narrate "Invalid setting"
+ - queue clear
+ }
+
+dhunger_setting_restock:
+ type: task
+ debug: false
+ script:
+ - if %arg3% != help && ( %arg3% matches integer && %arg3% > 0 ) {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.restock:%arg3%
+ - narrate "<&6>Changing RESTOCK on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg set restock <<>value<>>"
+ - narrate "Where <&dq>value<&dq> is the number of seconds between restocks."
+ - narrate "Use 0 for no restocking."
+ }
+
+dhunger_setting_min_players:
+ type: task
+ debug: false
+ script:
+ - if %arg3% matches integer && %arg3% >= 2 {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.min_players:%arg3%
+ - narrate "<&6>Changing MIN_PLAYERS on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg set min_players <<>value<>>"
+ - narrate "Where <&dq>value<&dq> is the minimum number of players for a game."
+ - narrate "Default is 2."
+ }
+
+dhunger_setting_max_players:
+ type: task
+ debug: false
+ script:
+ - if %arg3% matches integer && %arg3% >= <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.min_players]||2> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.max_players:%arg3%
+ - narrate "<&6>Changing MAX_PLAYERS on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg set max_players <<>value<>>"
+ - narrate "Where <&dq>value<&dq> is the maximum number of players for a game."
+ - narrate "Default is 20."
+ }
+
+dhunger_setting_lightning:
+ type: task
+ debug: false
+ script:
+ - define allowed li@always|2|off
+ - if <def[allowed].contains[%arg3%]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.lightning:%arg3%
+ - narrate "<&6>Changing LIGHTNING on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg set lightning <<>value<>>"
+ - narrate "<&6>Available values are: always, 2 or off"
+ - narrate "<&6>Always = Use lightning through the whole game"
+ - narrate "<&6>2 = Use lightning when game is down to 2 players"
+ - narrate "<&6>off = Don't use lightning at all"
+ }
+
+dhunger_setting_lightning_delay:
+ type: task
+ debug: false
+ script:
+ - if <def[arg3].is[matches].to[integer]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.lightning_delay:%arg3%
+ - narrate "<&6>Changing LIGHTNING_DELAY on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg set lightning_delay <<>value<>>"
+ - narrate "<&6>value = Seconds between lightning strikes."
+ - narrate "<&6>Available values are numbers > 0 "
+ }
+
+dhunger_setting_countdown:
+ type: task
+ debug: false
+ script:
+ - if <def[arg3].is[matches].to[integer]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.countdown:%arg3%
+ - narrate "<&6>Changing COUNTDOWN on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg 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"
+ }
+
+dhunger_setting_timer:
+ type: task
+ debug: false
+ script:
+ - if <def[arg3].is[matches].to[integer]> {
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.timer:%arg3%
+ - narrate "<&6>Changing TIMER on arena <<>%arena%<>> with value: %arg3%"
+ - inject dhunger_command_save
+ }
+ else {
+ - narrate "<&6>/dhg 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"
+ }
+
+dhunger_command_board:
+ type: task
+ debug: false
+ script:
+ - if !<player.has_flag[dhg.edit]> {
+ - narrate "You don't have an arena selected."
+ - queue clear
+ }
+ - define arena <player.flag[dhg.edit]>
+ - define arg2 <context.args.get[2]>
+ - define settings li@add|del|reset
+ - if <def[settings].contains[%arg2%]> {
+ - if <def[arg2].is[==].to[help]> inject dhunger_help_board_%arg2%
+ else inject dhunger_board_%arg2%
+ }
+ else {
+ - narrate "<&6>/dhg board <&lb>add<&rb><&pipe><&lb>del<&rb><&pipe><&lb>reset<&rb>"
+ - narrate "add - Add a sign board"
+ - narrate "del - Delete the arena sign configuration"
+ - narrate "reset - Reset a board"
+ }
+
+dhunger_board_add:
+ type: task
+ debug: false
+ script:
+ - define signs <player.selected_region.get_blocks.filter[material.bukkit_enum.is[==].to[wall_sign]]||0>
+ - if <def[signs].size.is[OR_MORE].to[3]> {
+ - narrate "Found your sign"
+ - define sdir <def[signs].get[1].material.data>
+ - define slist li@<def[signs].get[1]>
+ - define signs <def[signs].remove[1]>
+ - narrate "Direction %sdir%"
+ # West
+ - foreach %signs% {
+ - define nsign %value%
+ - define found false
+ - foreach <def[slist]> {
+ - if <def[nsign].as_location.y.is[MORE].than[<def[value].as_location.y>]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[loop_index]>]>
+ - define found true
+ - foreach stop
+ }
+ # West Facing
+ else if <def[sdir].is[==].to[4]> {
+ - if <def[nsign].as_location.z.is[LESS].than[<def[value].as_location.z>]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[loop_index]>]>
+ - define found true
+ - foreach stop
+ }
+ }
+ # East Facing
+ else if <def[sdir].is[==].to[5]> {
+ - if <def[nsign].as_location.z.is[MORE].than[<def[value].as_location.z>]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[loop_index]>]>
+ - define found true
+ - foreach stop
+ }
+ }
+ # North Facing
+ else if <def[sdir].is[==].to[2]> && <def[nsign].as_location.y.is[==].than[<def[value].as_location.y>]> {
+ - if <def[nsign].as_location.x.is[MORE].than[<def[value].as_location.x>]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[loop_index]>]>
+ - define found true
+ - foreach stop
+ }
+ }
+ # South Facing
+ else if <def[sdir].is[==].to[3]> {
+ - if <def[nsign].as_location.x.is[LESS].than[<def[value].as_location.x>]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[loop_index]>]>
+ - define found true
+ - foreach stop
+ }
+ }
+ }
+ - if !<def[found]> {
+ - if <def[sdir].is[==].to[4]> || <def[sdir].is[==].to[3]> {
+ - define slist <def[slist].insert[%nsign%].at[<def[slist].size.add[1]>]>
+ }
+ else {
+ - define slist <def[slist].insert[%nsign%].at[<def[slist].size>]>
+ }
+ }
+ }
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.board:%slist%
+ - inject dhunger_command_save
+ - inject dhunger_board_reset
+ }
+ else {
+ - narrate "sign wall missing or not big enough"
+ }
+
+dhunger_board_del:
+ type: task
+ debug: false
+ script:
+ - define sign <yaml[dhunger_saves].read[dhg.arenas.%arena%.board]||li@>
+ - foreach %sign% {
+ - sign type:automatic "" %value%
+ }
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.board:!
+ - inject dhunger_command_save
+ - narrate "The board in arena %arena% was removed."
+
+dhunger_board_reset:
+ type: task
+ debug: false
+ script:
+ - ^define sign <yaml[dhunger_saves].read[dhg.arenas.%arena%.board]||li@>
+ - ^if <def[sign].size> > 2 {
+ - define p_list <tern[<server.has_flag[dhg.%arena%.players]>]:<server.flag[dhg.%arena%.players].parse[name].alphanumeric>||li@>
+ - define p_count <def[p_list].size>
+ - define alive <server.get_online_players_flagged[dhg.play].filter[flag[dhg.play].is[==].to[%arena%]].size>
+ # Set panel 1
+ - sign type:automatic "Hunger Game|%arena%|<<>Click to Join<>>" <def[sign].get[1]>
+ # Set panel 2
+ - sign type:automatic "%arena%|<white>%p_count%<&0>/<&2>%alive%<&0>/<&4><server.flag[dhg.%arena%.dead].size||0><&0>/<&0><yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].size||20>" <def[sign].get[2]>
+ # Clear remaining boards
+ - define dead_list <server.flag[dhg.%arena%.dead]||li@>
+ - define p_sign li@
+ - foreach <def[sign].get[3].to[<def[sign].size>]> {
+ - if <def[p_list].size> = 0 {
+ - sign type:automatic "" %value%
+ - foreach next
+ }
+ - define l_sign %value%
+ - define p_sign <def[p_list].get[1].to[3]||li@>
+ - foreach p_sign {
+ - if <def[dead_list].contains[%value%]> define p_sign <def[p_sign].remove[%loop_index%].insert[<red>%value%].at[%loop_index%]>
+ }
+ - define p_list <def[p_list].remove[1|2|3]||li@>
+ - sign type:automatic "%p_sign%" %l_sign%
+ }
+ }
+
+dhunger_command_lobby:
+ type: task
+ debug: false
+ script:
+ - yaml id:dhunger_saves set dhg.lobby:l@<player.location.block.x.add[.5]>,<player.location.block.y>,<player.location.block.z.add[.5]>,<player.location.pitch>,<player.location.yaw>,<player.location.world.name>
+ - inject dhunger_command_save
+
+dhunger_command_join:
+ type: task
+ debug: false
+ script:
+ - define arena <player.flag[dhg.play]||<context.args.get[2]||help>>
+ - narrate "Joining game %arena%"
+ - if %arena% == help {
+ - narrate "<&6>/dhg join <<>Arena Name<>>"
+ - narrate "<&6>Either select an arena or provide an arena name"
+ - queue clear
+ }
+ - if %arena% != <def[arena].escaped> {
+ - narrate "<&6>That value doesn't look right."
+ - queue clear
+ }
+ - if <server.has_flag[dhg.%arena%.started]> {
+ - narrate "That game has already started"
+ - queue clear
+ }
+ - define spawnpoints <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].numerical>
+ - define order <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.order]||ordered>
+ - define ingame false
+ - if <def[order].matches[random]> {
+ - while <def[spawnpoints].size> > 0 {
+ - define randomnum <util.random.int[1].to[<def[spawnpoints].size>]>
+ - define spawnpt <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.<def[spawnpoints].get[%randomnum%]>]>
+ - if <def[spawnpt].find.players.within[3].size> == 0 {
+ - define ingame true
+ - while stop
+ }
+ - define spawnpoints <def[spawnpoints].remove[%randomnum%]>
+ }
+ }
+ else {
+ - foreach %spawnpoints% {
+ - define spawnpt <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.%value%]>
+ - if <def[spawnpt].find.players.within[3].size> == 0 {
+ - define ingame true
+ - foreach stop
+ }
+ }
+ }
+ - if !<def[ingame]> {
+ - narrate "Game spawns are full"
+ }
+ else {
+ - flag server dhg.%arena%.players:->:<player>
+ - inject dhunger_task_prep_player
+ - define state up
+ - inject dhunger_task_barricade
+ - teleport <player> %spawnpt%
+ - adjust <player> gamemode:survival
+ - narrate "<player.name> is joining the game." targets:<server.flag[dhg.%arena%.players].exclude[<player>]||li@>
+ - inject dhunger_board_reset
+ - if <server.has_flag[dhg.%arena%.timer]> {
+ - flag server dhg.%arena%.timer:<yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.timer]||30>
+ }
+ else {
+ - run dhunger_game_check_start def:%arena%
+ }
+ }
+
+dhunger_game_check_start:
+ type: task
+ debug: false
+ script:
+ - wait 1t
+ - ^define arena %1%
+ - ^define timer <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.timer]||30>
+ - ^flag server dhg.%arena%.timer:%timer%
+ - ^define steps li@%timer%|15|10|5|1
+ - ^if <def[timer].is[MORE].than[30]> {
+ - repeat <def[timer].div[30].round_up> {
+ - define steps <def[steps].insert[<def[value].mul[30]>].at[0]>
+ }
+ - define steps <def[steps].numerical.deduplicate>
+ }
+ - ^while <server.has_flag[dhg.%arena%.timer]> {
+ - if <server.flag[dhg.%arena%.players].size||0> == 0 {
+ - run dhunger_check_end_of_game def:%arena%
+ - while stop
+ }
+ - ^if <def[steps].contains[<server.flag[dhg.%arena%.timer].as_int>]> {
+ - if <server.flag[dhg.%arena%.players].size> >= <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.min_player]||2> {
+ - narrate "Game will start in: <server.flag[dhg.%arena%.timer].as_int> seconds" targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ }
+ else {
+ - narrate "Waiting for players...<server.flag[dhg.%arena%.timer].as_int> seconds to go." targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ }
+ }
+ else if <server.flag[dhg.%arena%.timer].is[or_less].than[0]> {
+ - if <server.flag[dhg.%arena%.players].size.is[less].than[<yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.min_player]||2>]> {
+ - define state down
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.spawnpoint].numerical> {
+ - define spawnpt <yaml[dhunger_saves].read[dhg.arenas.%arena%.spawnpoint.%value%].as_location.block>
+ - inject dhunger_task_barricade
+ }
+ - narrate "Not enough players, cancelling game" targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ - run dhunger_check_end_of_game def:%arena%|cancelled
+ - flag server dhg.%arena%:!
+ - while stop
+ }
+ - run dhunger_game_start def:%arena%
+ - while stop
+ }
+ - ^flag server dhg.%arena%.timer:--
+ - wait 1s
+ }
+
+dhunger_game_start:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^define timer <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.countdown]||10>
+ - ^repeat %timer% {
+ - define count <def[timer].sub[%value%].add[1]>
+ - narrate "Beginning in <red>%count%" targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ - wait 1s
+ }
+ - ^run dhunger_stock_chests def:%arena% instantly
+ - ^define state down
+ - ^flag server dhg.%arena%.started:true
+ - ^foreach <server.flag[dhg.%arena%.players].as_list> {
+ - define spawnpt <def[value].location.block>
+ - inject dhunger_task_barricade
+ }
+ - ^narrate "<green>GO!" targets:<server.flag[dhg.%arena%.players].as_list||li@>
+ - ^if <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.lightning]||2> == always {
+ - run dhunger_game_lightning def:%arena% id:dhg_lightning_%arena%
+ }
+ - ^if <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.restock]||0> > 0 {
+ - run dhunger_game_restock def:%arena% id:dhg_restock_%arena%
+ }
+
+dhunger_task_prep_player:
+ type: task
+ debug: false
+ script:
+ #- ^if <player.is_online> narrate "Remove Inventory"
+ - ^define equipment <player.flag[dhg.equipment]||li@>
+ - ^yaml id:dhunger_saves set 'dhg.player.<player.uuid>.equipment:<player.equipment>'
+ - ^yaml id:dhunger_saves set 'dhg.player.<player.uuid>.inventory:<player.inventory.list_contents>'
+ - ^yaml id:dhunger_saves set 'dhg.player.<player.uuid>.gamemode:<player.gamemode>'
+ - ^inventory clear d:<player>
+ - ^equip <player> 'boots:<def[equipment].get[1]||i@air>' 'legs:<def[equipment].get[2]||i@air>' 'chest:<def[equipment].get[3]||i@air>' 'head:<def[equipment].get[4]||i@air>'
+ - inject dhunger_command_save
+
+dhunger_task_cleanup_player:
+ type: task
+ debug: false
+ script:
+ #- ^if <player.is_online> narrate "Replace Inventory"
+ - ^inventory clear d:<player>
+ - ^define equipment <yaml[dhunger_saves].read[dhg.player.<player.uuid>.equipment]||li@>
+ - ^equip <player> 'boots:<def[equipment].get[1]||i@air>' 'legs:<def[equipment].get[2]||i@air>' 'chest:<def[equipment].get[3]||i@air>' 'head:<def[equipment].get[4]||i@air>'
+ - ^inventory set 'd:<player.inventory>' 'o:<yaml[dhunger_saves].read[dhg.player.<player.uuid>.inventory]||li@>'
+ - ^adjust <player> gamemode:<yaml[dhunger_saves].read[dhg.player.<player.uuid>.gamemode]||survival]>
+ - ^yaml id:dhunger_saves set 'dhg.player.<player.uuid>:!'
+ - ^inject dhunger_command_save
+ - ^flag player dhg.play:!
+ - ^adjust <player> health:20
+ - ^adjust <player> food_level:100
+ - ^adjust <player> saturation:100
+
+dhunger_remove_player:
+ type: task
+ debug: true
+ script:
+ - ^define arena <player.flag[dhg.play]>
+ - ^if <player.is_online> {
+ - drop <player.inventory.list_contents>
+ - ^teleport <player> <yaml[dhunger_saves].read[dhg.lobby]||<player.location.world.spawn_location>>
+ }
+ - ^define sound <tern[<yaml[dhunger_saves].contains[dhg.arena.%arena%.settings.sound]>]:<yaml[dhunger_saves].read[dhg.arena.%arena%.settings.sound]>||FIREWORK_LARGE_BLAST>
+ - ^if <def[sound].contains[custom]> playsound <server.flag[dhg.%arena%.players].as_list||li@> sound:%sound% volume:10 custom
+ else playsound <server.flag[dhg.%arena%.players].as_list||li@> sound:%sound% volume:10
+ - ^if <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.lightning]||2> == 2 {
+ - run dhunger_game_lightning def:%arena%
+ }
+ - ^flag server dhg.%arena%.dead:->:<player.name>
+ - inject dhunger_board_reset
+ - ^if <player.is_online> inject dhunger_task_cleanup_player
+
+
+dhunger_check_end_of_game:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^if <server.get_online_players_flagged[dhg.play].filter[flag[dhg.play].is[==].to[%arena%]].size.is[==].to[1]> && <def[2]||0> != cancelled {
+ - define winner <server.get_online_players_flagged[dhg.play].filter[flag[dhg.play].is[==].to[%arena%]].get[1]>
+ - announce "<green><def[winner].name> has won the hunger game in %arena%"
+ }
+ - ^foreach <server.get_online_players_flagged[dhg.play].filter[flag[dhg.play].is[==].to[%arena%]]> {
+ - run dhunger_remove_player player:%value% instantly
+ }
+ - ^run dhunger_task_block_rollback def:%arena%
+ - ^remove <cu@dhg_%arena%.list_entities[dropped_item]>
+ - if <queue.exists[dhg_lightning_%arena%]> queue queue:dhg_lightning_%arena% stop
+ - if <queue.exists[dhg_restock_%arena%]> queue queue:dhg_restock_%arena% stop
+ - ^flag server dhg.%arena%:!
+ - inject dhunger_board_reset
+ #- announce "Finished end_of_game"
+
+dhunger_stock_chests:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^foreach li@tier1|tier2 {
+ - define tier %value%
+ - if !<yaml[dhunger_saves].contains[dhg.arenas.%arena%.settings.%tier%]> foreach next
+ - if !<yaml[dhunger_saves].contains[dhg.arenas.%arena%.settings.%tier%_chests]> foreach next
+ - foreach <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.%tier%_chests].as_list> {
+ - define chest %value%
+ - inventory clear d:%chest%
+ - define additems li@
+ - foreach <yaml[dhunger_saves].list_keys[dhg.arenas.%arena%.settings.%tier%]> {
+ - define itemvals <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.%tier%.%value%].as_list>
+ - if <util.random.int[1].to[100].is[OR_LESS].than[<def[itemvals].get[1]||25>]> {
+ - define additems <def[additems].insert[%value%[quantity=<util.random.int[1].to[<def[itemvals].get[2]||1>]>]].at[1]>
+ }
+ }
+ - define additems <def[additems].get[1].to[27]||null>
+ - if %additems% == null {
+ - narrate "error finding items for chests"
+ - queue clear
+ }
+ - foreach %additems% {
+ - define item %value%
+ - while true {
+ - define slot <util.random.int[1].to[27]>
+ - if <def[chest].inventory.slot[%slot%]> == i@air while stop
+ }
+ - inventory set d:%chest% o:%value% slot:%slot%
+ }
+ }
+ }
+
+dhunger_task_block_track:
+ type: task
+ debug: false
+ script:
+ - ^define action %1%
+ - ^define arena %2%
+ - ^define location %3%
+ - ^define mat %4%
+ - ^yaml id:dhunger_saves set dhg.arenas.%arena%.track.%action%:->:li@%location%|%mat%
+ - inject dhunger_command_save
+
+dhunger_task_block_rollback:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^if <yaml[dhunger_saves].contains[dhg.arenas.%arena%.track]||false> {
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%arena%.track.break]> {
+ - foreach <yaml[dhunger_saves].read[dhg.arenas.%arena%.track.break]> {
+ - modifyblock <def[value].get[1]> <def[value].get[2]>
+ }
+ }
+ - if <yaml[dhunger_saves].contains[dhg.arenas.%arena%.track.place]> {
+ - foreach <yaml[dhunger_saves].read[dhg.arenas.%arena%.track.place]> {
+ - modifyblock <def[value].get[1]> m@air
+ }
+ }
+ - yaml id:dhunger_saves set dhg.arenas.%arena%.track:!
+ - inject dhunger_command_save
+ }
+
+dhunger_task_barricade:
+ type: task
+ debug: false
+ script:
+ - ^define barricade li@
+ - ^define blocktype <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.barrier]||m@barrier>
+ - ^foreach li@0|1|2 {
+ - define y %value%
+ - foreach li@-1|0|1 {
+ - define x %value%
+ - foreach li@-1|0|1 {
+ - define z %value%
+ - if %x% == 0 && %z% == 0 {
+ - foreach next
+ }
+ - define block <def[spawnpt].add[%x%,%y%,%z%]>
+ - if ( <def[state].is[==].to[up]> && <def[block].material.is[==].to[m@air]> ) || ( <def[state].is[==].to[down]> && <def[block].material.is[==].to[%blocktype%]> ) {
+ - define barricade <def[barricade].insert[%block%].at[1]>
+ }
+ }
+ }
+ }
+ - ^if <def[barricade].size.is[more].than[0]> modifyblock %barricade% <tern[<def[state].is[==].to[down]>]:m@air||%blocktype%> no_physics
+dhunger_game_lightning:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^define timer <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.lightning_delay]||60>
+ - ^while <server.has_flag[dhg.%arena%.started]> {
+ - wait %timer%
+ - foreach <server.get_online_players_flagged[dhg.play].filter[flag[dhg.play].is[==].to[%arena%]]> {
+ - strike no_damage <def[value].location>
+ }
+ }
+
+dhunger_game_restock:
+ type: task
+ debug: false
+ script:
+ - ^define arena %1%
+ - ^define timer <yaml[dhunger_saves].read[dhg.arenas.%arena%.settings.restock]||0>
+ - ^if %timer% == 0 queue stop
+ - ^while <server.has_flag[dhg.%arena%.started]> {
+ - wait %timer%
+ - inject dhunger_stock_chests %arena%
+ }
+
+dhunger_task_yaml_copy:
+ type: task
+ debug: false
+ script:
+ - define sourcekey %1%
+ - define destkey %2%
+ - if <yaml[dhunger_saves].contains[%1%].not> {
+ - narrate "Source invalid for yaml copy"
+ - queue stop
+ }
+ - if <yaml[dhunger_saves].list_keys[%1%].size||0> > 0 {
+ - foreach <yaml[dhunger_saves].list_keys[%1%]||li@> {
+ - run dhunger_task_yaml_copy def:%1%.%value%|%2%.%value% instantly
+ }
+ }
+ else {
+ - if <yaml[dhunger_saves].is_list[%1%]> {
+ - foreach <yaml[dhunger_saves].read[%1%]> {
+ - yaml id:dhunger_saves set %2%:->:%value%
+ }
+ }
+ else {
+ - yaml id:dhunger_saves set %2%:<yaml[dhunger_saves].read[%1%]>
+ }
+ }
+
+dhunger_task_block_change_check:
+ type: task
+ debug: false
+ script:
+ - if !<server.has_flag[dhg.loaded]> queue clear
+ - foreach <context.location.cuboids.parse[notable_name].filter[starts_with[dhg_]].parse[after[dhg_]]> {
+ - if <yaml[dhunger_saves].read[dhg.arenas.%value%.settings.locked]||false> determine cancelled
+ }
+