Skip to content

Commit

Permalink
Remove pack protection options
Browse files Browse the repository at this point in the history
These were partially broken and did never provide any meaningful security anyway
Resolves #278, #322
  • Loading branch information
NichtStudioCode committed Mar 9, 2024
1 parent 899115f commit 41889ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ minecraft-asset-downloader = { group = "xyz.xenondevs", name = "minecraft-asset-
minecraft-model-renderer = { group = "xyz.xenondevs", name = "minecraft-model-renderer", version = "1.3" }
nmsutilities = { group = "xyz.xenondevs", name = "nms-utilities", version = "0.16" }
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
resource-pack-obfuscator = { group = "xyz.xenondevs", name = "resource-pack-obfuscator", version = "0.4.1" }
specialsource = { group = "net.md-5", name = "SpecialSource", version = "1.11.0" }
stringremapper = { group = "xyz.xenondevs.string-remapper", name = "string-remapper-core", version.ref = "stringremapper" }
zip4j = { group = "net.lingala.zip4j", name = "zip4j", version = "2.11.2" }
Expand All @@ -63,7 +62,7 @@ kotlin = ["kotlin-stdlib", "kotlin-reflect"]
ktor = ["ktor-server-core-jvm", "ktor-server-cio-jvm", "ktor-client-core-jvm", "ktor-client-cio-jvm", "ktor-client-content-negotiation", "ktor-serialization-gson-jvm"]
kyori-adventure = ["adventure-api", "adventure-text-serializer-gson", "adventure-text-serializer-plain", "adventure-platform-bukkit"]
maven-resolver = ["maven-resolver-provider", "maven-resolver-connector-basic", "maven-resolver-transport-http"]
minecraft-assets = ["minecraft-asset-downloader", "minecraft-model-renderer", "resource-pack-obfuscator"]
minecraft-assets = ["minecraft-asset-downloader", "minecraft-model-renderer"]
test = ["kotlin-test-junit", "junit-jupiter"]
xenondevs-commons = ["commons-collections", "commons-gson", "commons-provider", "commons-reflection"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ import xyz.xenondevs.nova.ui.overlay.bossbar.BossBarOverlayManager
import xyz.xenondevs.nova.ui.waila.WailaManager
import xyz.xenondevs.nova.util.data.Version
import xyz.xenondevs.nova.util.runAsyncTask
import xyz.xenondevs.resourcepackobfuscator.ResourcePackObfuscator
import java.io.File
import java.nio.file.FileSystem
import java.nio.file.FileSystems
import java.nio.file.Path
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import kotlin.io.path.createDirectories
import kotlin.io.path.exists
import kotlin.io.path.inputStream
import kotlin.io.path.invariantSeparatorsPathString
import kotlin.io.path.isRegularFile
import kotlin.io.path.relativeTo
import kotlin.io.path.walk
import kotlin.io.path.writeText
import kotlin.time.Duration
import kotlin.time.measureTime
Expand Down Expand Up @@ -81,8 +85,6 @@ private val CORE_RESOURCE_FILTERS by configReloadable {
}
}

private val OBFUSCATE by MAIN_CONFIG.entry<Boolean>("resource_pack", "generation", "protection", "obfuscate")
private val CORRUPT_ENTRIES by MAIN_CONFIG.entry<Boolean>("resource_pack", "generation", "protection", "corrupt_entries")
private val COMPRESSION_LEVEL by MAIN_CONFIG.entry<Int>("resource_pack", "generation", "compression_level")
private val PACK_DESCRIPTION by MAIN_CONFIG.entry<String>("resource_pack", "generation", "description")
private val IN_MEMORY_PROVIDER = MAIN_CONFIG.entry<Boolean>("resource_pack", "generation", "in_memory")
Expand Down Expand Up @@ -298,13 +300,16 @@ class ResourcePackBuilder internal constructor() {
// pack zip
LOGGER.info("Packing zip...")
val filters = getResourceFilters(ResourceFilter.Stage.RESOURCE_PACK)
ResourcePackObfuscator(
OBFUSCATE, CORRUPT_ENTRIES,
PACK_DIR, RESOURCE_PACK_FILE.toPath(),
MCASSETS_DIR.toFile()
) { file ->
filters.all { filter -> filter.allows(file.relativeTo(ASSETS_DIR).invariantSeparatorsPathString) }
}.packZip(COMPRESSION_LEVEL)
ZipOutputStream(RESOURCE_PACK_FILE.outputStream()).use { zip ->
zip.setLevel(COMPRESSION_LEVEL)
PACK_DIR.walk()
.filter { path -> path.isRegularFile() }
.filter { path -> filters.all { filter -> filter.allows(path.relativeTo(ASSETS_DIR).invariantSeparatorsPathString) } }
.forEach { path ->
zip.putNextEntry(ZipEntry(path.relativeTo(PACK_DIR).invariantSeparatorsPathString))
path.inputStream().use { it.copyTo(zip) }
}
}
}

private fun runPackFunction(func: PackFunction) {
Expand Down
6 changes: 0 additions & 6 deletions nova/src/main/resources/configs/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ resource_pack:
compression_level: -1
# If the generation process should take place entirely in memory. This increases memory usage but improves generation speed.
in_memory: true
# Protection settings for the resource pack.
protection:
# Renames resource pack textures and models.
obfuscate: false
# Protects the zip from being opened in normal zip programs.
corrupt_entries: false
# Settings regarding the generation of font files.
font:
# A list of fonts that should not have moved versions generated.
Expand Down

0 comments on commit 41889ab

Please sign in to comment.