mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
Removing unwanted constructors and methods from ResourceLocation
This commit is contained in:
parent
b29eb71469
commit
a2b04a0350
@ -14,6 +14,7 @@ package de.bixilon.minosoft.data.registries
|
||||
|
||||
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.length
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@ -36,8 +37,6 @@ open class ResourceLocation private constructor(
|
||||
override val translationKey: ResourceLocation
|
||||
get() = this
|
||||
|
||||
constructor(resourceLocation: String) : this(resourceLocation.namespace, resourceLocation.path)
|
||||
|
||||
init {
|
||||
if (!ProtocolDefinition.ALLOWED_NAMESPACE_PATTERN.matches(namespace) && namespace != "")
|
||||
throw IllegalArgumentException("Namespace '$namespace' is not allowed!")
|
||||
@ -88,26 +87,11 @@ open class ResourceLocation private constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
val String.namespace: String
|
||||
get() {
|
||||
val split = this.split(':', limit = 2)
|
||||
if (split.size == 1) {
|
||||
return ProtocolDefinition.DEFAULT_NAMESPACE
|
||||
}
|
||||
return split[0]
|
||||
}
|
||||
|
||||
val String.path: String
|
||||
get() {
|
||||
val split = this.split(':', limit = 2)
|
||||
if (split.size == 1) {
|
||||
return split[0]
|
||||
}
|
||||
return split[1]
|
||||
}
|
||||
|
||||
fun of(resourceLocation: String): ResourceLocation {
|
||||
return ResourceLocation(resourceLocation.namespace, resourceLocation.path)
|
||||
var split = resourceLocation.split(':', limit = 2)
|
||||
if (split.length == 1)
|
||||
split = arrayOf(ProtocolDefinition.DEFAULT_NAMESPACE, split[0]).toList()
|
||||
return ResourceLocation(split[0], split[1])
|
||||
}
|
||||
|
||||
fun of(namespace: String, path: String): ResourceLocation {
|
||||
|
Loading…
x
Reference in New Issue
Block a user