3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 15:00:11 +01:00

remove debug, ensure we fully check failed packs, merge master

Dieser Commit ist enthalten in:
onebeastchris 2023-12-21 22:08:15 +01:00
Ursprung 0ac91ebc25
Commit 626189fa25
5 geänderte Dateien mit 20 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -88,10 +88,6 @@ public final class GameProtocol {
return session.getUpstream().getProtocolVersion() < Bedrock_v630.CODEC.getProtocolVersion();
}
public static boolean isPre1_20_30(GeyserSession session) {
return session.getUpstream().getProtocolVersion() < Bedrock_v618.CODEC.getProtocolVersion();
}
/**
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
*

Datei anzeigen

@ -44,13 +44,13 @@ import org.geysermc.geyser.event.type.SessionLoadResourcePacksEventImpl;
import org.geysermc.geyser.pack.GeyserResourcePack;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.loader.ResourcePackLoader;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.LoginEncryptionUtils;
import org.geysermc.geyser.util.MathUtils;
import org.geysermc.geyser.util.VersionCheckUtils;
import org.geysermc.geyser.util.WebUtils;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -61,7 +61,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
private boolean networkSettingsRequested = false;
private final Deque<String> packsToSent = new ArrayDeque<>();
private final List<UUID> brokenResourcePacks = new ArrayList<>();
private final Set<UUID> brokenResourcePacks = new HashSet<>();
private SessionLoadResourcePacksEventImpl resourcePackLoadEvent;
@ -186,7 +186,6 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
}
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks());
GeyserImpl.getInstance().getLogger().info(resourcePacksInfo.toString());
session.sendUpstreamPacket(resourcePacksInfo);
GeyserLocale.loadGeyserLocale(session.locale());
@ -280,16 +279,15 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
ResourcePack pack = this.resourcePackLoadEvent.getPacks().get(packet.getPackId().toString());
PackCodec codec = pack.codec();
// Check for packs that the client should normally download on its own. If the client cannot find the pack, we provide it instead.
// If a remote pack ends up here, that usually implies that a platform was not able to download the pack
if (codec instanceof UrlPackCodec urlPackCodec) {
if (!GameProtocol.isPre1_20_30(this.session)) {
// Ensure we don't a. spam console, and b. spam download/check requests
if (!brokenResourcePacks.contains(packet.getPackId())) {
brokenResourcePacks.add(packet.getPackId());
GeyserImpl.getInstance().getLogger().warning("Received a request for a remote pack that the client should have already downloaded!" +
"Is the pack at the URL " + urlPackCodec.url() + " still available?");
WebUtils.checkUrlAndDownloadRemotePack(urlPackCodec.url());
}
// Ensure we don't a. spam console, and b. spam download/check requests
if (!brokenResourcePacks.contains(packet.getPackId())) {
brokenResourcePacks.add(packet.getPackId());
GeyserImpl.getInstance().getLogger().warning("Received a request for a remote pack that the client should have already downloaded!" +
"Is the pack at the URL " + urlPackCodec.url() + " still available?");
// not actually interested in using the download, but this does all the checks we need
ResourcePackLoader.downloadPack(urlPackCodec.url());
}
}

Datei anzeigen

@ -100,6 +100,8 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<String, Reso
resourcePacks.add(skullResourcePack);
}
@SuppressWarnings("deprecation")
GeyserLoadResourcePacksEvent event = new GeyserLoadResourcePacksEvent(resourcePacks);
GeyserImpl.getInstance().eventBus().fire(event);
@ -230,8 +232,12 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<String, Reso
}
public static CompletableFuture<@Nullable Path> downloadPack(String url) throws IllegalArgumentException {
//TODO check if our cache pack is fine (size, url hash; head req)
return WebUtils.checkUrlAndDownloadRemotePack(url).whenCompleteAsync((cachedPath, throwable) -> {
if (cachedPath == null) {
// already warned about in WebUtils
return;
}

Datei anzeigen

@ -115,12 +115,12 @@ public class WebUtils {
if (size <= 0) {
GeyserImpl.getInstance().getLogger().error(String.format("Invalid size from remote pack URL: %s (size: %d)", url, size));
//return null;
return null;
}
if (type == null || !type.equals("application/zip")) {
GeyserImpl.getInstance().getLogger().error(String.format("Invalid application type from remote pack URL: %s (type: %s)", url, type));
//return null;
return null;
}
InputStream in = con.getInputStream();
@ -137,7 +137,7 @@ public class WebUtils {
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Malformed URL: " + url);
} catch (IOException e) {
throw new RuntimeException("Unable to download and save file: " + url + ")");
throw new RuntimeException("Unable to download and save remote resource pack from: " + url + ")");
}
});
}

Datei anzeigen

@ -174,6 +174,7 @@ force-resource-packs: true
# A list of links to send to the client to download resource packs from.
# These must be direct links to the resource pack, not a link to a page containing the resource pack.
# If you enter a link here, Geyser will download the resource pack once to check if it's in a valid format.
resource-pack-urls:
# Example: GeyserOptionalPack
- "https://ci.opencollab.dev/job/GeyserMC/job/GeyserOptionalPack/job/master/lastSuccessfulBuild/artifact/GeyserOptionalPack.mcpack"