mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
remove LegacyResourceLocation
Co-authored-by: MrGeoTech <themrgeotech@gmail.com>
This commit is contained in:
parent
5873611b9c
commit
a3ec99f55a
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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
|
||||
}
|
||||
}
|
@ -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<String, Any>): PluginChannel {
|
||||
return PluginChannel(
|
||||
resourceLocation = resourceLocation,
|
||||
name = LegacyResourceLocation(data["name"].unsafeCast())
|
||||
name = ResourceLocation(data["name"].unsafeCast())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user