8000 Feature: Allow API users to set ResourcePackOption's, add a GeyserDefineResourcePacksEvent by onebeastchris · Pull Request #4978 · GeyserMC/Geyser · GitHub
[go: up one dir, main page]

Skip to content
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

Feature: Allow API users to set ResourcePackOption's, add a GeyserDefineResourcePacksEvent #4978

Open
wants to merge 87 commits into
base: master 8000
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
68516a8
Initial stab at implementing 1.20.30's new CDN feature for resource p…
onebeastchris Oct 10, 2023
02d6473
Small tweaks: record formatting/javadocs
onebeastchris Oct 10, 2023
dbfc153
- Don't require configuring the packId, just the link instead
onebeastchris Oct 10, 2023
f74d36a
Remove forRemoval
onebeastchris Oct 10, 2023
94f2ea9
Rename cdn-resource-packs to resource-pack-urls, fix test, remove dup…
onebeastchris Oct 10, 2023
fd69b0c
Rename CDN entry list
onebeastchris Oct 10, 2023
c0227d3
Move loading cdn entries to separate function
onebeastchris Oct 11, 2023
b9c5bdd
Remove CDNEntry; those do not work as expected.
onebeastchris Oct 17, 2023
27c1562
remove outdated javadocs
onebeastchris Oct 17, 2023
5d06edd
Fallback system - download the pack to serve the client in case cdn f…
onebeastchris Oct 18, 2023
8000
880de2d
Ensure GeyserUrlPackCodec.create returns a ResourcePack with the URL …
onebeastchris Oct 18, 2023
76a62ab
Check downloaded resource packs, yeet cdn naming scheme
onebeastchris Oct 18, 2023
3670914
start on proper url checking (application type/size)
onebeastchris Oct 24, 2023
498a415
Change fallback system
onebeastchris Nov 9, 2023
0004f5b
Testing: Don't require `application/zip` or `size` or weird zip forma…
onebeastchris Nov 9, 2023
cdd2aba
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris Nov 9, 2023
15b8b93
We need to ensure no invalid packs end up being loaded - otherwise, c…
onebeastchris Nov 9, 2023
d4f0d8a
Re-add debug: Apparently, not just `application/zip` works....???
onebeastchris Nov 10, 2023
0ac91eb
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris Dec 21, 2023
626189f
remove debug, ensure we fully check failed packs, merge master
onebeastchris Dec 21, 2023
f121299
More robust downloading/caching
onebeastchris Dec 22, 2023
303327a
oops
onebeastchris Dec 22, 2023
d2622a4
Add a registerAll method to register a collection of resource packs e…
onebeastchris Jan 15, 2024
4d99250
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris Jan 25, 2024
2e776c4
Allow null content key
onebeastchris Jan 26, 2024
a4fa2e6
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris Feb 16, 2024
b8fa18a
start: don't try to delete broken packs while we are still delivering…
onebeastchris Feb 19, 2024
c6511a0
update to "new" pack requirements
onebeastchris Feb 22, 2024
507a79e
Merge remote-tracking branch 'refs/remotes/upstream/master' into rp
onebeastchris Jun 19, 2024
86f6458
Code cleanup, less futures, more exceptions when needed
onebeastchris Jun 19, 2024
6053b7d
Yeet unused, update optionalpack link
onebeastchris Jun 19, 2024
2683b59
Minor cleanup
onebeastchris Jun 20, 2024
ba78dba
Add url codec creation method with no content key, remove boolean ret…
onebeastchris Jun 20, 2024
f56c182
Merge branch 'master' into rp
onebeastchris Jun 20, 2024
de54a5b
Ensure packs actually load
onebeastchris Jun 20, 2024
86f1389
Merge remote-tracking branch 'origin/rp' into rp
onebeastchris Jun 20, 2024
27659d0
Add device type to debug to be able to isolate platform specific requ…
onebeastchris Jun 24, 2024
9241957
Automatically download newer pack versions from urls, properly get ri…
onebeastchris Jun 25, 2024
3638d4d
Merge branch 'master' into rp
onebeastchris Jun 25, 2024
8b87c08
Fix typo's
onebeastchris Jun 25, 2024
b6d404e
Merge remote-tracking branch 'origin/rp' into rp
onebeastchris Jun 25, 2024
e214fbe
javadoc typos, log application type as info for now
onebeastchris Jun 27, 2024
1608746
Warn about content-type being null/not application/zip
onebeastchris Jul 1, 2024
f116382
Proper warning about version/uuid changes
onebeastchris Jul 3, 2024
5b52769
Merge branch 'master' into rp
onebeastchris Jul 3, 2024
5649574
Merge branch 'master' into rp
onebeastchris Jul 6, 2024
61f5294
Merge branch 'master' into rp
onebeastchris Jul 9, 2024
226bf38
Merge branch 'master' into rp
onebeastchris Jul 13, 2024
bddd9ac
Merge branch 'master' into rp
onebeastchris Jul 21, 2024
b43e2db
Merge branch 'master' into rp
onebeastchris Aug 2, 2024
6133487
Feature: Subpack loading
onebeastchris Aug 11, 2024
8000 0f8d729
Also expose the settings of a resource pack, as shown on https://lear…
onebeastchris Aug 11, 2024
87829c9
minor fixes
onebeastchris Aug 11, 2024
20e4919
Merge branch 'GeyserMC:master' into rp
onebeastchris Aug 11, 2024
033d2d6
Attempt at making a proper builder for resource pack options (content…
onebeastchris Aug 12, 2024
c316d09
further optimizations, disconnects clients on odd responses
onebeastchris Aug 12, 2024
a868ced
attempt at implementing resource pack order specifying
onebeastchris Aug 12, 2024
250a9b4
Check for duplicate options, other fixes
onebeastchris Aug 12, 2024
fb4e42d
Ensure we don't modify default options
onebeastchris Aug 19, 2024
6c5a05a
Remove options taking a ResourcePack, use uuids
onebeastchris Aug 20, 2024
9279c70
Merge remote-tracking branch 'refs/remotes/origin/rp' into subpacks-r…
onebeastchris Aug 20, 2024
c13f928
Merge remote resource packs, change the default pack option system
onebeastchris Aug 20, 2024
1867c6d
one more change
onebeastchris Aug 20, 2024
139976a
revert bad changes
onebeastchris Aug 20, 2024
ca55d9f
Merge remote-tracking branch 'refs/remotes/upstream/master' into subp…
onebeastchris Aug 20, 2024
e1f86a8
merge master
onebeastchris Aug 20, 2024
3160537
Add UrlFallbackOption
onebeastchris Aug 21, 2024
1faaea7
Merge remote-tracking branch 'refs/remotes/upstream/master' into subp…
onebeastchris Aug 21, 2024
18776a8
Address reviews
onebeastchris Aug 22, 2024
19954a2
Add option#(uuid, type) method to api, add logger.debug(message, obje…
onebeastchris Aug 22, 2024
3bf5da1
smol cleanup: don't register packs if their options failed to registe…
onebeastchris Sep 18, 2024
936c716
Some more cleanup, address Konica's review comments on old PR
onebeastchris Sep 19, 2024
6d4ae96
Merge remote-tracking branch 'refs/remotes/upstream/master' into subp…
onebeastchris Sep 19, 2024
739de66
update comment
onebeastchris Sep 20, 2024
b90d25b
Merge remote-tracking branch 'refs/remotes/upstream/master' into subp…
onebeastchris Nov 4, 2024
5a298de
Update to latest changes, remove odd resource pack option
onebeastchris Nov 4, 2024
a03769b
fix building
onebeastchris Nov 27, 2024
10f1bcd
Re-add UrlFallbackOption
onebeastchris Nov 27, 2024
15c3723
Merge branch 'master' into subpacks-rewrite-merge-urlpacks
onebeastchris Nov 27, 2024
328e269
Merge remote-tracking branch 'upstream/master' into subpacks-rewrite-…
onebeastchris Jan 18, 2025
c79cbfc
merge upstream
onebeastchris Jan 18, 2025
cc99a48
Merge remote-tracking branch 'origin/subpacks-rewrite-merge-urlpacks'…
onebeastchris Jan 18, 2025
2592e92
Make register methods return void, add ResourcePackException
onebeastchris Jan 20, 2025
1be0e16
Merge remote-tracking branch 'upstream/master' into subpacks-rewrite-…
onebeastchris Jan 30, 2025
dfc7c32
fixup javadocs
onebeastchris Jan 30, 2025
6f888d7
remove duplicate
onebeastchris Jan 30, 2025
3ed44dc
attempt to make javadocs even better
onebeastchris Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address reviews
  • Loading branch information
onebeastchris committed Aug 22, 2024
commit 18776a8000c34249c36bd9bfd5798e231d62e89a
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ public interface GeyserConfiguration {

boolean isForceResourcePacks();

// TODO configurate - till then, api only
//List<String> getResourcePackUrls();

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isXboxAchievementsEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("force-resource-packs")
private boolean forceResourcePacks = true;

// @JsonProperty("resource-pack-urls")
// private List<String> resourcePackUrls = new ArrayList<>();

@JsonProperty("xbox-achievements-enabled")
private boolean xboxAchievementsEnabled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;

@Getter
public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePacksEvent {
Expand All @@ -51,7 +50,7 @@ public GeyserDefineResourcePacksEventImpl(Map<UUID, ResourcePackHolder> packMap)

@Override
public @NonNull List<ResourcePack> resourcePacks() {
return packs.values().stream().map(ResourcePackHolder::pack).collect(Collectors.toUnmodifiableList());
return packs.values().stream().map(ResourcePackHolder::resourcePack).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeSet;
import java.util.UUID;
import java.util.stream.Collectors;

public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksEvent {

Expand All @@ -69,7 +67,7 @@ public SessionLoadResourcePacksEventImpl(GeyserSession session) {

@Override
public @NonNull List<ResourcePack> resourcePacks() {
return packs.values().stream().map(ResourcePackHolder::pack).collect(Collectors.toUnmodifiableList());
return packs.values().stream().map(ResourcePackHolder::resourcePack).toList();
}

@Override
Expand Down Expand Up @@ -138,13 +136,12 @@ private void registerOption(@NonNull ResourcePack resourcePack, @Nullable Resour
// Methods used internally for e.g. ordered packs, or resource pack entries

public List<ResourcePackStackPacket.Entry> orderedPacks() {
TreeSet<Map.Entry<GeyserResourcePack, Double>> sortedPacks = packs.values().stream()
return packs.values().stream()
// Map each ResourcePack to a pair of (GeyserResourcePack, Priority)
.map(holder -> new AbstractMap.SimpleEntry<>(holder.pack(), priority(holder.pack())))
// Sort by priority in ascending order
.collect(Collectors.toCollection(() -> new TreeSet<>(Map.Entry.comparingByValue(Comparator.naturalOrder()))));

return sortedPacks.stream()
.sorted(Map.Entry.comparingByValue(Comparator.naturalOrder()))
// Map the sorted entries to ResourcePackStackPacket.Entry
.map(entry -> {
ResourcePackManifest.Header header = entry.getKey().manifest().header();
return new ResourcePackStackPacket.Entry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.geysermc.geyser.pack;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.pack.ResourcePack;
import org.geysermc.geyser.pack.option.OptionHolder;

public record ResourcePackHolder(
Expand All @@ -36,4 +37,8 @@ public record ResourcePackHolder(
public static ResourcePackHolder of(GeyserResourcePack pack) {
return new ResourcePackHolder(pack, new OptionHolder());
}

public ResourcePack resourcePack() {
return this.pack;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,16 @@ public Map<UUID, ResourcePackHolder> load(Path directory) {
}
}

// Load all remote resource packs before firing the new event
packMap.putAll(loadRemotePacks());
// Load all remote resource packs from the config before firing the new event
// TODO configurate
//packMap.putAll(loadRemotePacks());

GeyserDefineResourcePacksEventImpl defineEvent = new GeyserDefineResourcePacksEventImpl(packMap);
GeyserImpl.getInstance().eventBus().fire(defineEvent);

// After loading the new resource packs: let's clean up the old url packs
cleanupRemotePacks();

return defineEvent.getPacks();
}

Expand Down Expand Up @@ -249,9 +254,6 @@ private Map<UUID, ResourcePackHolder> loadRemotePacks() {
}
}

// After loading the new resource packs: let's clean up the old
cleanupRemotePacks();

return packMap;
}

Expand Down
0