Developers
API reference
The calls available to script plugins through BA, and their external-pack equivalents.
Progress
BA.award(player, "gems:root", "emerald"); // complete one goal
BA.grant(player, "gems:root"); // complete an advancement
BA.revoke(player, "gems:root");
BA.reopen(player, "gems:root"); // take the completion back, keep the progress (2.0.19)
BA.isDone(player, "gems:root"); // true or false
BA.progress(player, "gems:hoarder"); // { done, total }
BA.reopen is for when you've added to an advancement players have completed: they keep what they'd done and only the new part is left. For a finished list, say which entries are new: BA.reopen(player, "gems:hunter", { kills: ["stray"] }) (the goal's name, then its new entries). It returns false when there's nothing new to do. Completing it again calls onComplete with again: true and doesn't give the rewards a second time. The admin menu does the same.
Events
BA.emit(player, "gems:polished", "ruby"); // progresses { trigger: "event", event: "gems:polished" }
BA.onComplete(({ player, advancement }) => {
// every completion, from any pack
});
An event goal can require a value with data (a string or number, compared exactly) or, in script plugins, test it with match(data, player).
The screen
BA.open(player, { tabId: "gems:main" });
Content
BA.remove("minecraft:story/root"); // remove a built-in advancement
BA.english({ "my.tab.title": "My Tab" }); // English text for Discord when you use lang keys
External packs
| Script plugin | External pack (baClient.js) |
|---|---|
BA.award(player, id, criterion) | ba.award(player, id, criterion) |
BA.grant / BA.revoke | ba.grant / ba.revoke |
BA.emit(player, event, data) | ba.emit(player, event, data) |
BA.onComplete(fn) | ba.onCompleted(fn) |
BA.open(player, { tabId }) | ba.open(player, tabId) |