3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Add way to specify key for encrypted packs (#3263)

Dieser Commit ist enthalten in:
Kevin Ludwig 2022-09-03 20:12:48 +02:00 committet von GitHub
Ursprung 7d7a38a502
Commit a16fc9c07c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 14 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -106,7 +106,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
ResourcePackManifest.Header header = resourcePack.getManifest().getHeader(); ResourcePackManifest.Header header = resourcePack.getManifest().getHeader();
resourcePacksInfo.getResourcePackInfos().add(new ResourcePacksInfoPacket.Entry( resourcePacksInfo.getResourcePackInfos().add(new ResourcePacksInfoPacket.Entry(
header.getUuid().toString(), header.getVersionString(), resourcePack.getFile().length(), header.getUuid().toString(), header.getVersionString(), resourcePack.getFile().length(),
"", "", "", false, false)); resourcePack.getContentKey(), "", header.getUuid().toString(), false, false));
} }
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks()); resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks());
session.sendUpstreamPacket(resourcePacksInfo); session.sendUpstreamPacket(resourcePacksInfo);

Datei anzeigen

@ -26,16 +26,20 @@
package org.geysermc.geyser.pack; package org.geysermc.geyser.pack;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import lombok.Getter;
/** /**
* This represents a resource pack and all the data relevant to it * This represents a resource pack and all the data relevant to it
*/ */
@ -55,6 +59,9 @@ public class ResourcePack {
private ResourcePackManifest manifest; private ResourcePackManifest manifest;
private ResourcePackManifest.Version version; private ResourcePackManifest.Version version;
@Getter
private String contentKey;
/** /**
* Loop through the packs directory and locate valid resource pack files * Loop through the packs directory and locate valid resource pack files
*/ */
@ -97,6 +104,11 @@ public class ResourcePack {
} }
} }
}); });
// Check if a file exists with the same name as the resource pack suffixed by .key,
// and set this as content key. (e.g. test.zip, key file would be test.zip.key)
File keyFile = new File(file.getParentFile(), file.getName() + ".key");
pack.contentKey = keyFile.exists() ? Files.readString(keyFile.toPath(), StandardCharsets.UTF_8) : "";
} catch (Exception e) { } catch (Exception e) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.resource_pack.broken", file.getName())); GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.resource_pack.broken", file.getName()));
e.printStackTrace(); e.printStackTrace();