Skip to content

Support adding/removing multiple resource packs #2712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

mergu
Copy link
Contributor

@mergu mergu commented Mar 23, 2025

I'm a bit rusty here so apologies if anything is flat out wrong.

This was all tested on 1.21.4, multiple rps can be added and removals work:
image

I wasn't sure how to format the command with removals.. my guess is url/hash would become optional args and the meta would need to explain the differences. I just opted for some mecs

UUID packUUID;
try {
packUUID = UUID.fromString(id);
} catch (IllegalArgumentException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

mcmonkey4eva
mcmonkey4eva previously approved these changes Mar 24, 2025
@mergu
Copy link
Contributor Author

mergu commented Mar 24, 2025

fixed format

Debug.echoDebug(scriptEntry, "Player is offline, can't send resource pack to them. Skipping.");
continue;
}
player.getPlayerEntity().addResourcePack(packUUID, url, hashData, prompt, forced);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Spigot API here vs Paper API for setting means that set allows advanced text stuff in the prompt and add doesn't - might be better to use Paper API here as well for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a paper api version of this that I saw, other than the Audience stuff. Can you link me what you're referencing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think Paper has a direct alternative to the Spigot method? but you can just use adventure, untested but should be something like this:

ResourcePackRequest.Builder builder = ResourcePackRequest.resourcePackRequest();
builder.packs(ResourcePackInfo.resourcePackInfo(UUID.fromString("123"), URI.create("https://www.pack.com/pack.zip"), "hash-13th0aing"));
builder.prompt(Component.text("Use pack pls").color(NamedTextColor.AQUA));
builder.replace(false);
builder.required(true);
player.sendResourcePacks(builder);

Comment on lines +122 to +127
try {
packUUID = UUID.fromString(id);
}
catch (IllegalArgumentException e) {
packUUID = UUID.nameUUIDFromBytes(id.getBytes(StandardCharsets.UTF_8));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably put this in a util method on ResourcePackCommand, just because it's repeated a couple times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants