mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
add some deprecated parsers to properly parse the packet
This commit is contained in:
parent
f0942b0467
commit
2f390e8393
@ -18,7 +18,6 @@ import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -50,8 +49,6 @@ class DoubleParser(
|
||||
companion object : ArgumentParserFactory<DoubleParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "brigadier:double".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = DoubleParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): DoubleParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val min = if (flags.isBitMask(0x01)) buffer.readDouble() else -Double.MAX_VALUE
|
||||
|
@ -18,7 +18,6 @@ import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -50,8 +49,6 @@ class FloatParser(
|
||||
companion object : ArgumentParserFactory<FloatParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "brigadier:float".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = FloatParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): FloatParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val min = if (flags.isBitMask(0x01)) buffer.readFloat() else -Float.MAX_VALUE
|
||||
|
@ -18,7 +18,6 @@ import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -50,8 +49,6 @@ class IntParser(
|
||||
companion object : ArgumentParserFactory<IntParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "brigadier:integer".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = IntParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): IntParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val min = if (flags.isBitMask(0x01)) buffer.readInt() else Int.MIN_VALUE
|
||||
|
@ -18,7 +18,6 @@ import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -50,8 +49,6 @@ class LongParser(
|
||||
companion object : ArgumentParserFactory<LongParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "brigadier:long".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = LongParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): LongParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val min = if (flags.isBitMask(0x01)) buffer.readLong() else Long.MIN_VALUE
|
||||
|
@ -20,7 +20,6 @@ import de.bixilon.minosoft.commands.suggestion.ArraySuggestion
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -50,6 +49,5 @@ object BooleanParser : BrigadierParser<Boolean>, ArgumentParserFactory<BooleanPa
|
||||
return suggestion.suggest(text.result) ?: throw NoSuggestionError(reader, text)
|
||||
}
|
||||
|
||||
override fun build(connection: PlayConnection?) = this
|
||||
override fun read(buffer: PlayInByteBuffer) = this
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -54,8 +53,6 @@ class StringParser(
|
||||
companion object : ArgumentParserFactory<StringParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "brigadier:string".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = StringParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): StringParser {
|
||||
return StringParser(StringModes[buffer.readVarInt()])
|
||||
}
|
||||
|
@ -19,10 +19,13 @@ import de.bixilon.minosoft.commands.parser.brigadier._int.IntParser
|
||||
import de.bixilon.minosoft.commands.parser.brigadier._long.LongParser
|
||||
import de.bixilon.minosoft.commands.parser.brigadier.bool.BooleanParser
|
||||
import de.bixilon.minosoft.commands.parser.brigadier.string.StringParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range.RangeParserFactory
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._int.IntRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.resource.ResourceParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.resource.tag.ResourceOrTagParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.score.holder.ScoreHolderParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.target.TargetParser
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range.RangeParserFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._int.IntRangeParser
|
||||
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
|
||||
object ArgumentParserFactories : DefaultFactory<ArgumentParserFactory<*>>(
|
||||
@ -38,4 +41,49 @@ object ArgumentParserFactories : DefaultFactory<ArgumentParserFactory<*>>(
|
||||
RangeParserFactory,
|
||||
FloatRangeParser,
|
||||
IntRangeParser,
|
||||
|
||||
ScoreHolderParser,
|
||||
ResourceParser,
|
||||
ResourceOrTagParser,
|
||||
|
||||
/* TODO:
|
||||
minecraft:game_profile
|
||||
minecraft:block_pos
|
||||
minecraft:column_pos
|
||||
minecraft:vec3
|
||||
minecraft:vec2
|
||||
minecraft:block_state
|
||||
minecraft:block_predicate
|
||||
minecraft:item_stack
|
||||
minecraft:item_predicate
|
||||
minecraft:color
|
||||
minecraft:component
|
||||
minecraft:message
|
||||
minecraft:nbt
|
||||
minecraft:nbt_path
|
||||
minecraft:objective
|
||||
minecraft:objective_criteria
|
||||
minecraft:operation
|
||||
minecraft:particle
|
||||
minecraft:rotation
|
||||
minecraft:angle
|
||||
minecraft:scoreboard_slot
|
||||
minecraft:score_holder
|
||||
minecraft:swizzle
|
||||
minecraft:team
|
||||
minecraft:item_slot
|
||||
minecraft:resource_location
|
||||
minecraft:mob_effect
|
||||
minecraft:function
|
||||
minecraft:entity_anchor
|
||||
minecraft:item_enchantment
|
||||
minecraft:entity_summon
|
||||
minecraft:dimension
|
||||
minecraft:uuid
|
||||
minecraft:nbt_tag
|
||||
minecraft:nbt_compound_tag
|
||||
minecraft:time
|
||||
minecraft:resource_or_tag
|
||||
minecraft:resource
|
||||
*/
|
||||
)
|
||||
|
@ -15,12 +15,9 @@ package de.bixilon.minosoft.commands.parser.factory
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.data.registries.CompanionResourceLocation
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
|
||||
interface ArgumentParserFactory<T : ArgumentParser<*>> : CompanionResourceLocation {
|
||||
|
||||
fun build(connection: PlayConnection?): T
|
||||
|
||||
fun read(buffer: PlayInByteBuffer): T
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range
|
||||
|
||||
interface Range<T : Number> {
|
||||
val min: T
|
@ -11,15 +11,14 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._int.IntRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._int.IntRangeParser
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -27,8 +26,6 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
object RangeParserFactory : ArgumentParserFactory<ArgumentParser<*>> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minosoft:range".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = TODO("Can not construct range parser!")
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): ArgumentParser<*> {
|
||||
val decimals = buffer.readBoolean()
|
||||
return if (decimals) {
|
@ -11,9 +11,9 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range._float
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range._float
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range.Range
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range.Range
|
||||
|
||||
class FloatRange(
|
||||
override val min: Float = -Float.MAX_VALUE,
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range._float
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range._float
|
||||
|
||||
import de.bixilon.minosoft.commands.errors.parser.ParserError
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
@ -11,16 +11,15 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range._float
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range._float
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.brigadier._float.FloatParser.Companion.readFloat
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range.RangeParserFactory.readRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range.RangeParserFactory.readRange
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -44,8 +43,6 @@ class FloatRangeParser(
|
||||
companion object : ArgumentParserFactory<FloatRangeParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:float_range".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = FloatRangeParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) = FloatRangeParser()
|
||||
|
||||
fun CommandReader.readFloatRange(defaultMin: Boolean = true): FloatRange? {
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range._int
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range._int
|
||||
|
||||
import de.bixilon.minosoft.commands.errors.parser.ParserError
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
@ -11,16 +11,15 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minosoft.range._int
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.range._int
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.brigadier._int.IntParser.Companion.readInt
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range.RangeParserFactory.readRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range.RangeParserFactory.readRange
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -44,8 +43,6 @@ class IntRangeParser(
|
||||
companion object : ArgumentParserFactory<IntRangeParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:float_range".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = IntRangeParser()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) = IntRangeParser()
|
||||
|
||||
fun CommandReader.readIntRange(defaultMin: Boolean = true): IntRange? {
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 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.commands.parser.minecraft.resource
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.AbstractRegistry
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@Deprecated("TODO")
|
||||
class ResourceParser(
|
||||
val registry: AbstractRegistry<*>?,
|
||||
) : ArgumentParser<IntRange> {
|
||||
override val examples: List<Any> = listOf("TODO")
|
||||
override val placeholder = ChatComponent.of("<TODO>")
|
||||
|
||||
override fun parse(reader: CommandReader): IntRange {
|
||||
TODO()
|
||||
}
|
||||
|
||||
override fun getSuggestions(reader: CommandReader): List<Any> {
|
||||
if (reader.readString()?.isBlank() != false) {
|
||||
return examples
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
companion object : ArgumentParserFactory<ResourceParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:resource".toResourceLocation()
|
||||
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): ResourceParser {
|
||||
val registryName = buffer.readResourceLocation()
|
||||
val registry = buffer.connection.registries[registryName]
|
||||
return ResourceParser(registry)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 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.commands.parser.minecraft.resource.tag
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.AbstractRegistry
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@Deprecated("TODO")
|
||||
class ResourceOrTagParser(
|
||||
val registry: AbstractRegistry<*>?,
|
||||
) : ArgumentParser<IntRange> {
|
||||
override val examples: List<Any> = listOf("TODO")
|
||||
override val placeholder = ChatComponent.of("<TODO>")
|
||||
|
||||
override fun parse(reader: CommandReader): IntRange {
|
||||
TODO()
|
||||
}
|
||||
|
||||
override fun getSuggestions(reader: CommandReader): List<Any> {
|
||||
if (reader.readString()?.isBlank() != false) {
|
||||
return examples
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
companion object : ArgumentParserFactory<ResourceOrTagParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:resource_or_tag".toResourceLocation()
|
||||
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): ResourceOrTagParser {
|
||||
val registryName = buffer.readResourceLocation()
|
||||
val registry = buffer.connection.registries[registryName]
|
||||
return ResourceOrTagParser(registry)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 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.commands.parser.minecraft.score.holder
|
||||
|
||||
import de.bixilon.minosoft.commands.errors.parser.ParserError
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.commands.util.ReadResult
|
||||
|
||||
class ScoreHolderParseError(
|
||||
reader: CommandReader,
|
||||
result: ReadResult<IntRange?>,
|
||||
) : ParserError(reader, result)
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 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.commands.parser.minecraft.score.holder
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@Deprecated("TODO")
|
||||
class ScoreHolderParser(
|
||||
val allowMultiple: Boolean = false,
|
||||
) : ArgumentParser<IntRange> {
|
||||
override val examples: List<Any> = listOf("TODO")
|
||||
override val placeholder = ChatComponent.of("<TODO>")
|
||||
|
||||
override fun parse(reader: CommandReader): IntRange {
|
||||
TODO()
|
||||
}
|
||||
|
||||
override fun getSuggestions(reader: CommandReader): List<Any> {
|
||||
if (reader.readString()?.isBlank() != false) {
|
||||
return examples
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
companion object : ArgumentParserFactory<ScoreHolderParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:score_holder".toResourceLocation()
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): ScoreHolderParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val allowMultiple = flags.isBitMask(0x01)
|
||||
return ScoreHolderParser(allowMultiple)
|
||||
}
|
||||
}
|
||||
}
|
@ -31,7 +31,6 @@ import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.commands.util.ReadResult
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.BitByte.isBitMask
|
||||
@ -106,8 +105,6 @@ class TargetParser(
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:entity".toResourceLocation()
|
||||
const val DEFAULT_PLAYER_NAME = "Bixilon"
|
||||
|
||||
override fun build(connection: PlayConnection?) = TargetParser(playerName = connection?.player?.name ?: DEFAULT_PLAYER_NAME)
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer): TargetParser {
|
||||
val flags = buffer.readUnsignedByte()
|
||||
val single = flags.isBitMask(0x01)
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.rotation
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.TargetPropertyFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.rotation
|
||||
|
||||
import de.bixilon.minosoft.commands.errors.parser.ParserError
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.commands.util.ReadResult
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.rotation
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.TargetProperty
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
package de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.rotation
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.target.targets.selector.properties.TargetPropertyFactory
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRange
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.range._float.FloatRangeParser
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
|
||||
|
@ -21,7 +21,6 @@ import de.bixilon.minosoft.commands.suggestion.ArraySuggestion
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -51,8 +50,6 @@ class EnumParser<E : Enum<*>>(
|
||||
companion object : ArgumentParserFactory<EnumParser<*>> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minosoft:enum".toResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection?) = TODO("Can not construct enum parser yet!")
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) = TODO("Can not construct enum parser yet!")
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +232,11 @@ class Registries {
|
||||
return currentField?.get(this) as Registry<T>?
|
||||
}
|
||||
|
||||
@Deprecated("TODO")
|
||||
operator fun get(name: ResourceLocation): AbstractRegistry<*>? {
|
||||
return null // ToDo
|
||||
}
|
||||
|
||||
|
||||
private fun <T, R : AbstractRegistry<T>> register(name: String, registry: R): R {
|
||||
registries[name.toResourceLocation()] = registry
|
||||
|
Loading…
x
Reference in New Issue
Block a user