diff --git a/src/main/java/de/bixilon/minosoft/data/registries/LegacyResourceLocation.kt b/src/main/java/de/bixilon/minosoft/data/registries/LegacyResourceLocation.kt
deleted file mode 100644
index e65a7762d..000000000
--- a/src/main/java/de/bixilon/minosoft/data/registries/LegacyResourceLocation.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Minosoft
- * Copyright (C) 2020 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.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- *
- * This software is not affiliated with Mojang AB, the original developer of Minecraft.
- */
-package de.bixilon.minosoft.data.registries
-
-class LegacyResourceLocation(resourceLocation: String) : ResourceLocation("", resourceLocation) {
- override val full: String = path
-
- override fun hashCode(): Int {
- return this.path.hashCode()
- }
-
- override fun equals(other: Any?): Boolean {
- if (other === this) {
- return true
- }
- if (hashCode() != other.hashCode()) {
- return false
- }
- if (other !is ResourceLocation) {
- return false
- }
- return path == other.path
- }
-}
diff --git a/src/main/java/de/bixilon/minosoft/data/registries/PluginChannel.kt b/src/main/java/de/bixilon/minosoft/data/registries/PluginChannel.kt
index 1441377b4..2d5436700 100644
--- a/src/main/java/de/bixilon/minosoft/data/registries/PluginChannel.kt
+++ b/src/main/java/de/bixilon/minosoft/data/registries/PluginChannel.kt
@@ -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.
*
@@ -31,7 +31,7 @@ data class PluginChannel(
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map): PluginChannel {
return PluginChannel(
resourceLocation = resourceLocation,
- name = LegacyResourceLocation(data["name"].unsafeCast())
+ name = ResourceLocation(data["name"].unsafeCast())
)
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/registries/ResourceLocation.kt b/src/main/java/de/bixilon/minosoft/data/registries/ResourceLocation.kt
index 3ede94788..17da03899 100644
--- a/src/main/java/de/bixilon/minosoft/data/registries/ResourceLocation.kt
+++ b/src/main/java/de/bixilon/minosoft/data/registries/ResourceLocation.kt
@@ -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.
*
@@ -12,7 +12,6 @@
*/
package de.bixilon.minosoft.data.registries
-import de.bixilon.kutil.string.StringUtil.isLowercase
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import java.util.*
@@ -41,9 +40,6 @@ open class ResourceLocation(
if (hashCode() != other.hashCode()) {
return false
}
- if (other is LegacyResourceLocation) {
- return path == other.path
- }
if (other !is ResourceLocation) {
return false
}
@@ -81,13 +77,7 @@ open class ResourceLocation(
}
fun getResourceLocation(resourceLocation: String): ResourceLocation {
- // if (!ProtocolDefinition.RESOURCE_LOCATION_PATTERN.matcher(resourceLocation).matches()) {
- // throw new IllegalArgumentException(String.format("%s in not a valid resource location!", resourceLocation));
- // }
- return if (!resourceLocation.isLowercase()) {
- // just a string but wrapped into a resourceLocation (like old plugin channels MC|BRAND or ...)
- LegacyResourceLocation(resourceLocation)
- } else ResourceLocation(resourceLocation)
+ return ResourceLocation(resourceLocation)
}
fun getPathResourceLocation(resourceLocation: String): ResourceLocation {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ChannelC2SP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ChannelC2SP.kt
index c95f23a47..63579dc1b 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ChannelC2SP.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ChannelC2SP.kt
@@ -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.
*
@@ -31,7 +31,7 @@ class ChannelC2SP(
constructor(channel: ResourceLocation, buffer: OutByteBuffer) : this(channel, buffer.toArray())
override fun write(buffer: PlayOutByteBuffer) {
- buffer.writeResourceLocation(channel)
+ buffer.writeLegacyResourceLocation(channel)
if (buffer.versionId < ProtocolVersions.V_14W29A) {
buffer.writeShort(data.size)
} else if (buffer.versionId < ProtocolVersions.V_14W31A) {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/OutByteBuffer.kt b/src/main/java/de/bixilon/minosoft/protocol/protocol/OutByteBuffer.kt
index e15b2dcd4..e2a1a03e3 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/OutByteBuffer.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/OutByteBuffer.kt
@@ -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.
*
@@ -285,6 +285,14 @@ open class OutByteBuffer() {
buffer.put(toArray())
}
+ fun writeLegacyResourceLocation(resourceLocation: ResourceLocation) {
+ if (resourceLocation.namespace == ProtocolDefinition.DEFAULT_NAMESPACE) {
+ writeString(resourceLocation.path)
+ return
+ }
+ writeResourceLocation(resourceLocation)
+ }
+
fun writeResourceLocation(resourceLocation: ResourceLocation) {
writeString(resourceLocation.full)
}