-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Implement sending CDN entries to Bedrock clients to download resource packs from #4205
Open
onebeastchris
wants to merge
36
commits into
GeyserMC:master
Choose a base branch
from
onebeastchris:rp
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
36 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 02d6473
Small tweaks: record formatting/javadocs
onebeastchris dbfc153
- Don't require configuring the packId, just the link instead
onebeastchris f74d36a
Remove forRemoval
onebeastchris 94f2ea9
Rename cdn-resource-packs to resource-pack-urls, fix test, remove dup…
onebeastchris fd69b0c
Rename CDN entry list
onebeastchris c0227d3
Move loading cdn entries to separate function
onebeastchris b9c5bdd
Remove CDNEntry; those do not work as expected.
onebeastchris 27c1562
remove outdated javadocs
onebeastchris 5d06edd
Fallback system - download the pack to serve the client in case cdn f…
onebeastchris 880de2d
Ensure GeyserUrlPackCodec.create returns a ResourcePack with the URL …
onebeastchris 76a62ab
Check downloaded resource packs, yeet cdn naming scheme
onebeastchris 3670914
start on proper url checking (application type/size)
onebeastchris 498a415
Change fallback system
onebeastchris 0004f5b
Testing: Don't require `application/zip` or `size` or weird zip forma…
onebeastchris cdd2aba
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris 15b8b93
We need to ensure no invalid packs end up being loaded - otherwise, c…
onebeastchris d4f0d8a
Re-add debug: Apparently, not just `application/zip` works....???
onebeastchris 0ac91eb
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris 626189f
remove debug, ensure we fully check failed packs, merge master
onebeastchris f121299
More robust downloading/caching
onebeastchris 303327a
oops
onebeastchris d2622a4
Add a registerAll method to register a collection of resource packs e…
onebeastchris 4d99250
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris 2e776c4
Allow null content key
onebeastchris a4fa2e6
Merge remote-tracking branch 'upstream/master' into rp
onebeastchris b8fa18a
start: don't try to delete broken packs while we are still delivering…
onebeastchris c6511a0
update to "new" pack requirements
onebeastchris 507a79e
Merge remote-tracking branch 'refs/remotes/upstream/master' into rp
onebeastchris 86f6458
Code cleanup, less futures, more exceptions when needed
onebeastchris 6053b7d
Yeet unused, update optionalpack link
onebeastchris 2683b59
Minor cleanup
onebeastchris ba78dba
Add url codec creation method with no content key, remove boolean ret…
onebeastchris f56c182
Merge branch 'master' into rp
onebeastchris de54a5b
Ensure packs actually load
onebeastchris 86f1389
Merge remote-tracking branch 'origin/rp' into rp
onebeastchris File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...src/main/java/org/geysermc/geyser/api/event/lifecycle/GeyserDefineResourcePacksEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.event.lifecycle; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.geysermc.event.Event; | ||
import org.geysermc.geyser.api.pack.ResourcePack; | ||
import org.geysermc.geyser.api.pack.ResourcePackCDNEntry; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Called when {@link ResourcePack}'s and {@link ResourcePackCDNEntry}'s are loaded within Geyser. | ||
* | ||
*/ | ||
public abstract class GeyserDefineResourcePacksEvent implements Event { | ||
onebeastchris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Gets an unmodifiable list of {@link ResourcePack}s that will be sent to clients. | ||
* | ||
* @return an unmodifiable list of resource packs that will be sent to clients. | ||
*/ | ||
public abstract @NonNull List<ResourcePack> resourcePacks(); | ||
|
||
/** | ||
* Gets an unmodifiable list of {@link ResourcePackCDNEntry}s that will be sent to clients. | ||
* | ||
* @return an unmodifiable list of resource pack CDN entries that will be sent to clients. | ||
*/ | ||
public abstract @NonNull List<ResourcePackCDNEntry> cdnEntries(); | ||
|
||
/** | ||
* Registers a {@link ResourcePack} to be sent to clients. | ||
* | ||
* @param resourcePack a resource pack that will be sent to clients. | ||
* @return true if the resource pack was added successfully, | ||
* or false if already present | ||
*/ | ||
public abstract boolean register(@NonNull ResourcePack resourcePack); | ||
|
||
/** | ||
* Registers a {@link ResourcePackCDNEntry} to be sent to clients. | ||
* | ||
* @param entry CDN entry that will be sent to the client to download a resource pack from. | ||
*/ | ||
public abstract boolean register(@NonNull ResourcePackCDNEntry entry); | ||
|
||
/** | ||
* Unregisters a {@link ResourcePack} or {@link ResourcePackCDNEntry} from being sent to clients. | ||
* | ||
* @param uuid the UUID of the resource pack/CDN entry to remove. | ||
* @return true whether the resource pack/CDN entry was removed successfully. | ||
*/ | ||
public abstract boolean unregister(@NonNull UUID uuid); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
api/src/main/java/org/geysermc/geyser/api/pack/ResourcePackCDNEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.pack; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Represents a CDN entry for a resource pack. | ||
* The URL must be a direct download link to a Bedrock edition resource pack. | ||
* The UUID must be the UUID of the resource pack. | ||
* | ||
* @param url URL from which the pack should be downloaded | ||
* @param uuid UUID of the pack | ||
*/ | ||
public record ResourcePackCDNEntry(String url, UUID uuid) { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
core/src/main/java/org/geysermc/geyser/event/type/GeyserDefineResourcePacksEventImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.event.type; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineResourcePacksEvent; | ||
import org.geysermc.geyser.api.pack.ResourcePack; | ||
import org.geysermc.geyser.api.pack.ResourcePackCDNEntry; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePacksEvent { | ||
|
||
private final Map<String, ResourcePack> packs; | ||
private final Map<String, ResourcePackCDNEntry> cdnEntries; | ||
|
||
public GeyserDefineResourcePacksEventImpl(Map<String, ResourcePack> packMap, List<ResourcePackCDNEntry> cdnEntries) { | ||
this.packs = packMap; | ||
this.cdnEntries = new HashMap<>(); | ||
cdnEntries.forEach(entry -> this.cdnEntries.put(entry.uuid().toString(), entry)); | ||
} | ||
|
||
public @NonNull Map<String, ResourcePack> getPacks() { | ||
return packs; | ||
} | ||
|
||
@Override | ||
public @NonNull List<ResourcePack> resourcePacks() { | ||
return List.copyOf(packs.values()); | ||
} | ||
|
||
@Override | ||
public @NonNull List<ResourcePackCDNEntry> cdnEntries() { | ||
return List.copyOf(cdnEntries.values()); | ||
} | ||
|
||
@Override | ||
public boolean register(@NonNull ResourcePack resourcePack) { | ||
String packID = resourcePack.manifest().header().uuid().toString(); | ||
if (packs.containsValue(resourcePack) || packs.containsKey(packID) || cdnEntries.containsKey(packID)) { | ||
return false; | ||
} | ||
packs.put(resourcePack.manifest().header().uuid().toString(), resourcePack); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean register(@NonNull ResourcePackCDNEntry entry) { | ||
String packID = entry.uuid().toString(); | ||
if (packs.containsKey(packID) || cdnEntries.containsValue(entry) || cdnEntries.containsKey(packID)) { | ||
return false; | ||
} | ||
cdnEntries.put(packID, entry); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean unregister(@NonNull UUID uuid) { | ||
if (packs.containsKey(uuid.toString())) { | ||
return packs.remove(uuid.toString()) != null; | ||
} else if (cdnEntries.containsKey(uuid.toString())) { | ||
return cdnEntries.remove(uuid.toString()) != null; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not like we have a formal style guide, but if the javadoc body is the same as the
@return
tag, can we just have the return tag only?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but this has been accepted before & i'd rather keep it consistent (or change all instances of that in api)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFC :P
and it exists elsewhere afaik