diff --git a/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java b/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java index cdcf624..5842ad3 100644 --- a/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java +++ b/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023 GeyserMC. http://geysermc.org + * Copyright (c) 2019-2024 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 @@ -75,6 +75,7 @@ public class BedrockResourcePack { private Map blockModels; private Map entityModels; + private Map extraFiles; public BedrockResourcePack(@NotNull Path directory) { this(directory, null, null, null); @@ -276,6 +277,25 @@ public class BedrockResourcePack { this.languages = languages; } + /** + * Get the extra files of the resource pack. + * + * @return the extra files of the resource pack + */ + @Nullable + public Map extraFiles() { + return this.extraFiles; + } + + /** + * Set the files of the resource pack. + * + * @param extraFiles the extra files of the resource pack + */ + public void extraFiles(@Nullable Map extraFiles) { + this.extraFiles = extraFiles; + } + /** * Add an item to the resource pack. * @@ -430,6 +450,20 @@ public class BedrockResourcePack { this.languages.language(languageCode, translationStrings); } + /** + * Add an extra file to the resource pack. + * + * @param bytes the bytes of the file + * @param location the location of the file + */ + public void addExtraFile(byte[] bytes, @NotNull String location) { + if (this.extraFiles == null) { + this.extraFiles = new HashMap<>(); + } + + this.extraFiles.put(location, bytes); + } + /** * Exports the resource pack to the specified directory. * @@ -488,5 +522,13 @@ public class BedrockResourcePack { exportProperties(this.directory.resolve("texts/" + language.getKey() + ".lang"), language.getValue()); } } + + if (this.extraFiles != null) { + for (Map.Entry extraFile : this.extraFiles.entrySet()) { + Path extraFilePath = this.directory.resolve(extraFile.getKey()); + Files.createDirectories(extraFilePath.getParent()); + Files.write(extraFilePath, extraFile.getValue()); + } + } } }