index assets manager: ignore realms resources

This should reduce size of saved assets and bandwidth usage (not a lot, but some MB)
This commit is contained in:
Bixilon 2023-03-19 15:50:12 +01:00
parent d90ccd3780
commit abbf5d0f84
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 9 additions and 6 deletions

View File

@ -102,7 +102,7 @@ class IndexAssetsManager(
check(data is Map<*, *>)
val name = path.toAssetName(false) ?: continue
val type = IndexAssetsType.determinate(name.path)
val type = IndexAssetsType.determinate(name)
if (type == null || type !in this.types) {
continue
}

View File

@ -16,6 +16,8 @@ package de.bixilon.minosoft.assets.minecraft.index
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.assets.util.FileAssetsTypes
import de.bixilon.minosoft.data.registries.identified.Namespaces
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
enum class IndexAssetsType(val type: String) {
LANGUAGE(FileAssetsTypes.GAME),
@ -28,12 +30,13 @@ enum class IndexAssetsType(val type: String) {
override val NAME_MAP: Map<String, IndexAssetsType> = EnumUtil.getEnumValues(VALUES)
fun determinate(path: String): IndexAssetsType? {
fun determinate(identifier: ResourceLocation): IndexAssetsType? {
return when {
path.startsWith("lang/") -> LANGUAGE
path.startsWith("sounds/") -> SOUNDS
path == "sounds.json" -> SOUNDS
path.startsWith("textures/") -> TEXTURES
identifier.path == "sounds.json" -> SOUNDS
identifier.namespace != Namespaces.MINECRAFT -> null
identifier.path.startsWith("sounds/") -> SOUNDS
identifier.path.startsWith("lang/") -> LANGUAGE
identifier.path.startsWith("textures/") -> TEXTURES
else -> null
}
}