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<*, *>) check(data is Map<*, *>)
val name = path.toAssetName(false) ?: continue val name = path.toAssetName(false) ?: continue
val type = IndexAssetsType.determinate(name.path) val type = IndexAssetsType.determinate(name)
if (type == null || type !in this.types) { if (type == null || type !in this.types) {
continue 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.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.assets.util.FileAssetsTypes 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) { enum class IndexAssetsType(val type: String) {
LANGUAGE(FileAssetsTypes.GAME), LANGUAGE(FileAssetsTypes.GAME),
@ -28,12 +30,13 @@ enum class IndexAssetsType(val type: String) {
override val NAME_MAP: Map<String, IndexAssetsType> = EnumUtil.getEnumValues(VALUES) override val NAME_MAP: Map<String, IndexAssetsType> = EnumUtil.getEnumValues(VALUES)
fun determinate(path: String): IndexAssetsType? { fun determinate(identifier: ResourceLocation): IndexAssetsType? {
return when { return when {
path.startsWith("lang/") -> LANGUAGE identifier.path == "sounds.json" -> SOUNDS
path.startsWith("sounds/") -> SOUNDS identifier.namespace != Namespaces.MINECRAFT -> null
path == "sounds.json" -> SOUNDS identifier.path.startsWith("sounds/") -> SOUNDS
path.startsWith("textures/") -> TEXTURES identifier.path.startsWith("lang/") -> LANGUAGE
identifier.path.startsWith("textures/") -> TEXTURES
else -> null else -> null
} }
} }