Menu Crawler

1figure
5min read
Sheet 20 of 47 · Explore

The crawler drives one bot through a plugin's menus and writes down where every click goes. It runs the root command, clicks every slot, notes where each click leads, gets back to the menu and goes on breadth first. That is the same walk the website's explorer data used to be made with by hand.

The result is a graph of menus, dialogs and chat prompts, with the clicks that reach each one. Export it for the wiki's GUI explorer, open it in GUI Studio, or save it as a snapshot for a menu diff.

A finished crawl: the mapped menus on the left, the selected one drawn with the items that open another menu.
The Crawl page: bot Alice, menu /is, 8 menus mapped in a list on the left and the Arena Creator menu drawn slot by slot

Run a crawl

The Crawl page does it with a form: pick a bot, type the menu command, press Crawl. It shows the menus as a tree, exports to a file and saves snapshots.

Over HTTP, start a job, poll it, then take the graph or an export:

curl "localhost:8767/crawl/start?bot=CrawlBot&root=/zadmin%20gui%20creator-main&depth=2"
curl "localhost:8767/crawl/status?job=crawl-1"
curl "localhost:8767/crawl/result?job=crawl-1" > menus.json
curl "localhost:8767/crawl/export?job=crawl-1&format=explorer" > src/data/gui-myplugin.json
curl "localhost:8767/crawl/export?job=crawl-1&format=studio&name=My%20plugin" > my-plugin.studio.json

The bot needs the permissions the menus ask for. A crawl can also run after the scenarios in CI mode with --crawl.

What gets clicked

Every slot, except blank filler panes and items whose name or lore contains an unsafe word: create, delete, remove, reset, buy, sell, confirm, save, teleport, join, close, toggle and a few more. Small caps count.

  • skip=<regex> skips more.
  • safe=0 turns the built-in list off.
  • allow=<regex> clicks only items whose name or lore matches it, on top of the rest.

Skipped slots are listed in the graph with the reason.

Waiting for the server

A click is done once the server answers and then stays quiet for settle ms. An answer is a new window with its items, new items for the same window, a close, a dialog, chat or a kick. clickWait is only the upper limit for a click nothing answers.

  • Each click's time to the first answer is kept on the slot as millis.
  • Config keystats.latencyConfig keystats.outcomesstats.latency has avg, p50, p95 and max. stats.outcomes counts what the clicks did.
  • After a click that left the menu the crawler takes the short way back. When the bot already sits on a menu along the path, only the clicks after it are replayed.
  • mode=fixed is the old way, with fixed waits (clickWait=1200, settle=300), kept for comparing.

Pages

Items whose name matches next (default ^\W*(next\b|>>|→)) or previous (default ^\W*(prev(ious)?\b|<<|←)) are page buttons. pageLore=1 checks lore too. They are not clicked as buttons.

When a page is done the crawler clicks next. If the same window refreshes in place, or reopens with the same title apart from numbers, with new items, that is the next page, up to pages pages.

  • Pages stay one menu. Page 1 is the menu's slots, the rest are in pages: [{page, path, slots}], and every page is walked like a menu.
  • The exports turn page n into its own screen <id>-page-<n> with next and previous linked.
  • A next button that opens a menu with another title is an ordinary link.

Chat prompts

When a click closes the menu and chat asks for input, the bot answers. prompt decides what counts as a prompt: by default "type, enter or write ... chat, cancel or abort", or "in chat".

  • answers is regex=>value pairs split by ;;, checked in order.
  • By default number prompts and ranges like (1 - 16) get 1, and name, id or label prompts get TestName.
  • Anything else gets answer, default cancel.
  • If the plugin refuses the value and asks again, cancel goes out.

Every prompt is in the graph's prompts with the text, the answer and what happened. An answer that opens another menu links to it, and the typed value becomes part of its path, so that menu is crawled like any other.

Menus are told apart by title and window type. Session ids in titles (gui-test-a9bb706d) are ignored, so a menu that shows one does not turn into a new menu on every open. A menu already seen is linked, not walked again, so back buttons and loops end.

Dialogs that open on a click are recorded with their full definition and linked from the slot.

The graph

{job, start, bot, roots,
 menus: {id: {id, title, titleRuns, type, rows, path,
   slots: [{slot, material, count, name, lore, nameRuns, loreRuns, profile, glint, target, effect, millis}],
   pages}},
 dialogs: {id: {id, title, path, dialog}},
 prompts, skipped, errors, stats}
  • path is the root command followed by the slots clicked to get there and any typed answers.
  • effect is page, refresh, prompt or close when a click did something other than open a screen.

Exports

/crawl/export takes job or snapshot, a format and a name.

FormatWhat you get
explorerThe GuiMenu[] list the wiki's GuiExplorer reads, start menu first. Heads keep icon: player_head plus their profile, the website build turns those into an icon sheet
studioA GUI Studio project (ignited-gui-studio, version 1): names and lore as MiniMessage, and every link as an open action
graphThe raw graph

To edit a crawl, open GUI Studio, press Import, then Load file and pick the studio export. A whole crawl fits: files up to 32 MB and up to 2048 screens, with every page of a menu as its own screen. A project that big autosaves to the browser's IndexedDB, so it is still there after a reload.

Parameters

ParameterDefaultMeaning
botThe bot that crawls
rootOne command, or several split by |
depth2How deep to walk
skipRegex, more items not to click
allowRegex, click only items whose name or lore matches
safe10 turns the built-in unsafe word list off
maxMenus150Stop after this many menus
modeeventsevents or fixed
commandWait2500ms
clickWait2000ms, upper limit for a click nothing answers
settle60ms of quiet after an answer
pages10Pages followed per menu
next, previoussee PagesRegex for page buttons
pageLore01 checks lore for page buttons too
promptsee Chat promptsRegex for chat prompts
answersregex=>value pairs split by ;;
answercancelAnswer for any other prompt
timeout1800Seconds

Endpoints

EndpointParametersReturns
/crawlthe parameters abovethe graph, once the crawl ends
/crawl/startsame as /crawl{"job":"crawl-1",...} right away
/crawl/statusjobstate, progress, and stats and errors once done
/crawl/resultjobthe graph of a finished crawl
/crawl/canceljobstops the crawl, what it found so far stays
/crawl/jobsevery crawl this session
/crawl/exportjob or snapshot, format=explorer|studio|graph, namewebsite explorer JSON, a GUI Studio project, or the raw graph

/crawl/status also lists the server errors the watcher saw while the job ran.

Speed

IgniteZombies 1.5.0 on a local Paper 1.21.11, both creator roots, depth=3:

CrawlerTimeWalk
Old crawler220 s18 menus, 153 clicks
Event crawler69 s20 menus (the same 18 plus two behind prompt answers), the second page of the entity list, 199 clicks, 39 answered prompts
mode=fixed281 sthe same walk as the event crawler

Median click latency is 13 ms. Most of what is left is the settle window.

Loading the index

Enter openUp Down moveEsc close