mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
remove unneeded and deprecated resource location handling
This commit is contained in:
parent
ad7354964d
commit
a9069c7403
@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.entities.block
|
package de.bixilon.minosoft.data.entities.block
|
||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
|
||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.util.KUtil
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
|
||||||
class JigsawBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
|
class JigsawBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
|
||||||
var joint: String = "rollable"
|
var joint: String = "rollable"
|
||||||
@ -33,11 +32,11 @@ class JigsawBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
|
|||||||
|
|
||||||
|
|
||||||
override fun updateNBT(nbt: Map<String, Any>) {
|
override fun updateNBT(nbt: Map<String, Any>) {
|
||||||
nbt["joint"]?.nullCast<String>()?.let { joint = it }
|
nbt["joint"]?.let { joint = it.toString() }
|
||||||
nbt["name"]?.nullCast<String>()?.let { name = ResourceLocation.ofPath(it) }
|
nbt["name"]?.let { name = it.toResourceLocation() }
|
||||||
nbt["pool"]?.nullCast<String>()?.let { pool = ResourceLocation.ofPath(it) }
|
nbt["pool"]?.let { pool = it.toResourceLocation() }
|
||||||
nbt["finalState"]?.nullCast<String>()?.let { finalState = ResourceLocation.ofPath(it) }
|
nbt["finalState"]?.let { finalState = it.toResourceLocation() }
|
||||||
nbt["target"]?.nullCast<String>()?.let { target = ResourceLocation.ofPath(it) }
|
nbt["target"]?.let { target = it.toResourceLocation() }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : BlockEntityFactory<JigsawBlockEntity> {
|
companion object : BlockEntityFactory<JigsawBlockEntity> {
|
||||||
|
@ -29,6 +29,7 @@ import de.bixilon.minosoft.data.registries.item.items.Item
|
|||||||
class PlayerItemManager(private val player: LocalPlayerEntity) {
|
class PlayerItemManager(private val player: LocalPlayerEntity) {
|
||||||
val inventory = PlayerInventory(this, player.connection)
|
val inventory = PlayerInventory(this, player.connection)
|
||||||
|
|
||||||
|
@Deprecated("this is probably not needed anymore, container network packets are not async anymore")
|
||||||
val incomplete: SynchronizedMap<Int, IncompleteContainer> = synchronizedMapOf()
|
val incomplete: SynchronizedMap<Int, IncompleteContainer> = synchronizedMapOf()
|
||||||
|
|
||||||
val containers: SynchronizedBiMap<Int, Container> = synchronizedBiMapOf(
|
val containers: SynchronizedBiMap<Int, Container> = synchronizedBiMapOf(
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package de.bixilon.minosoft.data.registries.identified
|
package de.bixilon.minosoft.data.registries.identified
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.language.translate.Translatable
|
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation.Companion.ALLOWED_PATH_PATTERN
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +81,6 @@ open class ResourceLocation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ALLOWED_PATH_PATTERN = Regex("(?!.*//)[a-z0-9_./\\-]+")
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a resource location from a string.
|
* Creates a resource location from a string.
|
||||||
@ -98,21 +96,5 @@ open class ResourceLocation(
|
|||||||
}
|
}
|
||||||
return ResourceLocation(split[0], split[1])
|
return ResourceLocation(split[0], split[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a resource location from a string by splitting it at the first colon (:) or at the first slash (/) if there is no colon.
|
|
||||||
* If possible, use minecraft() or minosoft() instead.
|
|
||||||
*
|
|
||||||
* @param path The path to parse
|
|
||||||
* @return The parsed resource location
|
|
||||||
*/
|
|
||||||
@Deprecated("Don't know why this was a thing")
|
|
||||||
fun ofPath(path: String): ResourceLocation {
|
|
||||||
if (path.contains(':') || !path.contains('/')) {
|
|
||||||
return of(path)
|
|
||||||
}
|
|
||||||
val split = path.split('/', limit = 2)
|
|
||||||
return ResourceLocation(split[0], split[1])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,26 +95,4 @@ class ResourceLocationTest {
|
|||||||
assertThrows<IllegalArgumentException> { ResourceLocationUtil.validateNamespace("^minecraft") }
|
assertThrows<IllegalArgumentException> { ResourceLocationUtil.validateNamespace("^minecraft") }
|
||||||
assertThrows<IllegalArgumentException> { ResourceLocationUtil.validateNamespace("mine/craft") }
|
assertThrows<IllegalArgumentException> { ResourceLocationUtil.validateNamespace("mine/craft") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see [de.bixilon.minosoft.data.registries.identified.ResourceLocation]
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
fun testAllowedResourceLocationPaths() {
|
|
||||||
// Should Pass
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("minecraft"), true)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("min1234567890craft"), true)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine-craft"), true)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine_craft"), true)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine.craft"), true)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine/craft"), true)
|
|
||||||
// Should Fail
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("MineCraft"), false)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine craft"), false)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("minecraft!"), false)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("^minecraft"), false)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine//craft"), false)
|
|
||||||
kotlin.test.assertEquals(ResourceLocation.ALLOWED_PATH_PATTERN.matches("mine///craft"), false)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user