option to disable resource location validation

This commit is contained in:
Bixilon 2023-01-05 13:24:44 +01:00
parent ce339198e3
commit b81212dd94
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -21,4 +21,6 @@ object StaticConfiguration {
const val IGNORE_SERVER_LIGHT = true
const val VALIDATE_RESOURCE_LOCATION = true
}

View File

@ -12,6 +12,7 @@
*/
package de.bixilon.minosoft.data.registries.identified
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.identified.ResourceLocation.Companion.ALLOWED_NAMESPACE_PATTERN
import de.bixilon.minosoft.data.registries.identified.ResourceLocation.Companion.ALLOWED_PATH_PATTERN
@ -39,7 +40,7 @@ open class ResourceLocation(
get() = this
init {
if (namespace.isBlank() || !ALLOWED_NAMESPACE_PATTERN.matches(namespace)) {
if (StaticConfiguration.VALIDATE_RESOURCE_LOCATION && (namespace.isBlank() || !ALLOWED_NAMESPACE_PATTERN.matches(namespace))) {
throw IllegalArgumentException("Invalid namespace: $namespace")
}
// TODO: Figure out a way to implement this but have backwards compatibility with pre flattening versions