Add overloads to UnsafeValues#loadAdvancement
This PR adds two new methods to UnsafeValues to improve the workflow of working with Advancements:
-
loadAdvancement(NamespacedKey key, String advancement, boolean persist) -
loadAdvancements(Map<Key, String> advancements, boolean persist)
The first method just adds a new overload to the existing loadAdvancement method, which allows for disabling the printing into the Bukkit datapack. From my testing, this doesn't actually persist the Advancement anyways, so I am not even entirely certain what the point of storing it in the Bukkit datapack is, but that's probably a bug and it was intended to work that way.
The second method allows for bulk-registering advancements.
Example of registering two enchantments using the new `loadAdvancements` method
final boolean persist = false;
Bukkit.getUnsafe().loadAdvancements(Map.of(
new NamespacedKey("cool_plugin", "cool/root"), """
{
"display": {
"announce_to_chat": false,
"show_toast": false,
"background": "minecraft:gui/advancements/backgrounds/adventure",
"icon": { "id": "diamond_sword" },
"title": { "color": "blue", "text": "Cool Advancements" },
"description": { "color": "aqua", "text": "Only for the coolest of all!" },
"frame": "challenge"
},
"criteria": { "impossible": {"trigger": "minecraft:impossible"} },
"requirements": [ ["impossible"] ]
}
""",
new NamespacedKey("cool_plugin", "cool/unlocked"), """
{
"parent": "cool_plugin:cool/root",
"display": {
"announce_to_chat": true,
"show_toast": true,
"icon": { "id": "netherite_sword" },
"title": { "color": "dark_red", "text": "You are cool!" },
"description": { "color": "red", "text": "If you have this advancement, it means you are cool!!" },
"frame": "challenge",
"hidden": true
},
"criteria": { "impossible": {"trigger": "minecraft:impossible"} },
"requirements": [ ["impossible"] ]
}
"""),
persist
);
Testing the Advancements, they work as intended even if registered in bulk.
Rebased to 1.21.6
Rebased to 1.21.7
I've addressed all requested changes now.
Rebased to 1.21.8