Skip to content

Add overloads to UnsafeValues#loadAdvancement and fix data persistence#12553

Open
Strokkur424 wants to merge 11 commits intoPaperMC:mainfrom
Strokkur424:feat/load-advancement-improvement
Open

Add overloads to UnsafeValues#loadAdvancement and fix data persistence#12553
Strokkur424 wants to merge 11 commits intoPaperMC:mainfrom
Strokkur424:feat/load-advancement-improvement

Conversation

@Strokkur424
Copy link
Member

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.

image

image

@Strokkur424 Strokkur424 requested a review from a team as a code owner May 16, 2025 20:30
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue May 16, 2025
@Strokkur424 Strokkur424 force-pushed the feat/load-advancement-improvement branch 4 times, most recently from 542d449 to a0fbc24 Compare May 16, 2025 21:42
@Strokkur424 Strokkur424 force-pushed the feat/load-advancement-improvement branch from a0fbc24 to 203faa3 Compare June 17, 2025 17:37
@Strokkur424
Copy link
Member Author

Rebased to 1.21.6

@Strokkur424 Strokkur424 force-pushed the feat/load-advancement-improvement branch from 203faa3 to 71354d5 Compare June 21, 2025 19:09
@github-project-automation github-project-automation bot moved this from Awaiting review to Changes required in Paper PR Queue Jul 1, 2025
@Strokkur424 Strokkur424 force-pushed the feat/load-advancement-improvement branch from 71354d5 to 1d7630a Compare July 12, 2025 12:32
@Strokkur424
Copy link
Member Author

Rebased to 1.21.7

@Strokkur424
Copy link
Member Author

I've addressed all requested changes now.

@Strokkur424 Strokkur424 force-pushed the feat/load-advancement-improvement branch from 8a62c6a to 2d9f995 Compare July 17, 2025 17:46
@Strokkur424
Copy link
Member Author

Rebased to 1.21.8

@Strokkur424
Copy link
Member Author

Rebased to 1.21.11

@Lulu13022002
Copy link
Contributor

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.

That's definitely a bug spigot didn't updated to the new layout of the advancements made recently which changed a bunch of plural names: <namespace>/advancement/<key>.json instead of <namespace>/advancements/<key>.json

@Lulu13022002 Lulu13022002 changed the title Add overloads to UnsafeValues#loadAdvancement Add overloads to UnsafeValues#loadAdvancement and fix data persistence Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes required

Development

Successfully merging this pull request may close these issues.

5 participants