AdvancementManagerHelper
com.jsmacrosce.jsmacros.client.api.helper.AdvancementManagerHelper
Provides the client's advancement tree and, when a player is available, that player's progress.
Progress queries use the local player's advancement progress; the unfiltered tree queries do not.
js
const player = Player.getPlayer();
if (player !== null) {
const manager = player.getAdvancementManager();
// the progress views
Chat.log(`${manager.getCompletedAdvancements().length} done`);
Chat.log(`${manager.getStartedAdvancements().length} partly done`);
Chat.log(`${manager.getMissingAdvancements().length} not done`);
// one advancement, looked up by identifier
const root = manager.getAdvancement("minecraft:story/root");
if (root.getRaw() !== null) {
const progress = root.getProgress();
if (progress.getRaw() !== null) {
Chat.log(`root is ${progress.isDone() ? "done" : "not done"}`);
} else {
Chat.log("root has no progress entry");
}
}
}Constructors
new AdvancementManagerHelper
new AdvancementManagerHelper(AdvancementTree advancementManager)#Wraps the supplied advancement tree.
Parameters:
advancementManager: raw advancement tree to wrap
Methods
getAdvancement
Looks up an advancement by identifier; an omitted namespace defaults to
minecraft. The wrapper has no underlying node if the identifier is absent from the tree; check its raw value before using the wrapper. const player = Player.getPlayer();
if (player === null) { throw new Error("not in a world"); }
const manager = player.getAdvancementManager();
// both spellings work, the namespace is optional
const a = manager.getAdvancement("minecraft:story/root");
const b = manager.getAdvancement("story/root");
if (a.getRaw() !== null) {
if (b.getRaw() !== null) {
Chat.log(`${a.getId()} is ${b.getId()}`);
}
}Parameters:
identifier: the advancement identifier; theminecraftnamespace may be omitted
Returns: a wrapper for the matching advancement, with no underlying node if it is absent
getAdvancementProgress
Returns local-player progress for an advancement identifier; an omitted namespace defaults to
minecraft. The advancement must exist in the tree. If it has no progress entry, the returned wrapper has no underlying progress; check its raw value before using it.Parameters:
identifier: the advancement identifier
Returns: a wrapper for the advancement's progress entry, which may have no underlying progress
getAdvancements
Returns every advancement node in the tree; the list order is unspecified.
Returns: the advancement nodes
getAdvancementsForIdentifiers
Returns the advancement tree keyed by each identifier's
namespace:path string.Returns: a map containing every advancement; identifiers use the
namespace:path formgetAdvancementsProgress
Returns the local player's progress entries, keyed by their advancement nodes.
Returns: progress entries present in the local player's progress store
getCompletedAdvancements
Returns local-player progress entries that are complete.
Returns: the matching advancement nodes
getMissingAdvancements
Returns local-player progress entries that are not complete, including entries with no criteria obtained.
Returns: the matching advancement nodes
getRootAdvancements
Returns root advancements, which have no parent.
Returns: the root advancement nodes
getStartedAdvancements
Returns local-player progress entries that are incomplete and have at least one criterion obtained.
Returns: the matching advancement nodes
getSubAdvancements
Returns a flat list of non-root advancements.
Returns: the non-root advancement nodes
toString
Returns a diagnostic representation with started, missing, and completed advancement counts. Counts are obtained from the local player's progress lists; started entries are also included in the missing count. A local player is required.
Returns: diagnostic representation containing started, missing, and completed counts