command parsers: improve some codes (and replace single ton interfaces with objects)

This commit is contained in:
Bixilon 2021-03-10 00:07:09 +01:00
parent 959470f509
commit 3b6b298c16
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
21 changed files with 84 additions and 197 deletions

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class AngleParser : CoordinateParser() {
object AngleParser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
return readCoordinates(stringReader, true, 1)
}
companion object {
val ANGLE_PARSER = AngleParser()
}
}

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class BlockPositionParser : CoordinateParser() {
object BlockPositionParser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
return readCoordinates(stringReader, false, 3)
}
companion object {
val BLOCK_POSITION_PARSER = BlockPositionParser()
}
}

View File

@ -14,14 +14,12 @@ package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.ColorNotFoundCommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.text.ChatColors
import de.bixilon.minosoft.protocol.network.Connection
class ColorParser : CommandParser() {
object ColorParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
val color = stringReader.readUnquotedString()
try {
@ -30,8 +28,4 @@ class ColorParser : CommandParser() {
throw ColorNotFoundCommandParseException(stringReader, color, exception)
}
}
companion object {
val COLOR_PARSER = ColorParser()
}
}

View File

@ -13,18 +13,13 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class ColumnPositionParser : CoordinateParser() {
object ColumnPositionParser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
return readCoordinates(stringReader, false, 3)
}
companion object {
val COLUMN_POSITION_PARSER = ColumnPositionParser()
}
}

View File

@ -25,33 +25,33 @@ object CommandParsers {
ResourceLocation("brigadier:float") to FloatParser.FLOAT_PARSER,
ResourceLocation("brigadier:integer") to IntegerParser.INTEGER_PARSER,
ResourceLocation("brigadier:string") to StringParser.STRING_PARSER,
ResourceLocation("angle") to AngleParser.ANGLE_PARSER,
ResourceLocation("angle") to AngleParser,
ResourceLocation("entity") to EntityParser.ENTITY_PARSER,
ResourceLocation("game_profile") to GameProfileParser.GAME_PROFILE_PARSER,
ResourceLocation("block_pos") to BlockPositionParser.BLOCK_POSITION_PARSER,
ResourceLocation("column_pos") to ColumnPositionParser.COLUMN_POSITION_PARSER,
ResourceLocation("vec3") to Vec3Parser.VEC3_PARSER,
ResourceLocation("vec2") to Vec2Parser.VEC2_PARSER,
ResourceLocation("block_pos") to BlockPositionParser,
ResourceLocation("column_pos") to ColumnPositionParser,
ResourceLocation("vec3") to Vec3Parser,
ResourceLocation("vec2") to Vec2Parser,
ResourceLocation("block_state") to BlockStateParser.BLOCK_STACK_PARSER,
ResourceLocation("block_predicate") to BlockStateParser.BLOCK_PREDICATE_PARSER,
ResourceLocation("item_stack") to ItemStackParser.ITEM_STACK_PARSER,
ResourceLocation("item_predicate") to ItemStackParser.ITEM_PREDICATE_PARSER,
ResourceLocation("color") to ColorParser.COLOR_PARSER,
ResourceLocation("component") to ComponentParser.COMPONENT_PARSER,
ResourceLocation("color") to ColorParser,
ResourceLocation("component") to ComponentParser,
ResourceLocation("message") to MessageParser.MESSAGE_PARSER,
ResourceLocation("nbt") to NBTParser.NBT_PARSER,
// ToDo: nbt_path
ResourceLocation("objective") to ObjectiveParser.OBJECTIVE_PARSER,
ResourceLocation("objective") to ObjectiveParser,
// ToDo: objective_criteria
ResourceLocation("operation") to OperationParser.OPERATION_PARSER,
ResourceLocation("particle") to ParticleParser.PARTICLE_PARSER,
ResourceLocation("rotation") to RotationParser.ROTATION_PARSER,
ResourceLocation("scoreboard_slot") to ScoreboardSlotParser.SCOREBOARD_SLOT_PARSER,
ResourceLocation("score_holder") to ScoreHolderParser.SCORE_HOLDER_PARSER,
ResourceLocation("swizzle") to SwizzleParser.SWIZZLE_PARSER,
ResourceLocation("team") to TeamParser.TEAM_PARSER,
ResourceLocation("item_slot") to ItemSlotParser.ITEM_SLOT_PARSER,
ResourceLocation("resource_location") to ResourceLocationParser.RESOURCE_LOCATION_PARSER,
ResourceLocation("operation") to OperationParser,
ResourceLocation("particle") to ParticleParser,
ResourceLocation("rotation") to RotationParser,
ResourceLocation("scoreboard_slot") to ScoreboardSlotParser,
ResourceLocation("score_holder") to ScoreHolderParser,
ResourceLocation("swizzle") to SwizzleParser,
ResourceLocation("team") to TeamParser,
ResourceLocation("item_slot") to ItemSlotParser,
ResourceLocation("resource_location") to ResourceLocationParser,
ResourceLocation("mob_effect") to ResourceLocationListParser.MOB_EFFECT_PARSER,
// ToDo: function
// ToDo: entity_anchor
@ -61,7 +61,7 @@ object CommandParsers {
ResourceLocation("item_enchantment") to ResourceLocationListParser.ENCHANTMENT_PARSER,
ResourceLocation("entity_summon") to ResourceLocationListParser.SUMMONABLE_ENTITY_PARSER,
ResourceLocation("dimension") to ResourceLocationListParser.DIMENSION_EFFECT_PARSER,
ResourceLocation("uuid") to UUIDParser.UUID_PARSER,
ResourceLocation("uuid") to UUIDParser,
ResourceLocation("nbt_tag") to NBTParser.NBT_TAG_PARSER,
ResourceLocation("nbt_compound_tag") to NBTParser.NBT_COMPOUND_PARSER,
ResourceLocation("time") to TimeParser.TIME_PARSER

View File

@ -13,15 +13,13 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.InvalidComponentCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.text.BaseComponent
import de.bixilon.minosoft.protocol.network.Connection
class ComponentParser : CommandParser() {
object ComponentParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
try {
return BaseComponent(connection.version.localeManager, stringReader.readJson().asJsonObject)
@ -30,8 +28,4 @@ class ComponentParser : CommandParser() {
throw InvalidComponentCommandParseException(stringReader, stringReader.read().toString(), exception)
}
}
companion object {
val COMPONENT_PARSER = ComponentParser()
}
}

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.EntityParserProperties
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
@ -25,7 +24,6 @@ class GameProfileParser(val properties: EntityParserProperties) : EntityParser()
return null
}
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
return super.parse(connection, properties, stringReader)
}

View File

@ -13,14 +13,36 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.UnknownInventorySlotCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class ItemSlotParser : CommandParser() {
object ItemSlotParser : CommandParser() {
private val SLOTS = HashSet<String>()
init {
for (i in 0 until 54) {
SLOTS.add("container.$i")
}
for (i in 0 until 9) {
SLOTS.add("hotbar.$i")
}
for (i in 0 until 27) {
SLOTS.add("inventory." + (9 + i))
}
for (i in 0 until 27) {
SLOTS.add("enderchest." + (200 + i))
}
for (i in 0 until 8) {
SLOTS.add("villager." + (300 + i))
}
for (i in 0 until 15) {
SLOTS.add("horse." + (500 + i))
}
SLOTS.addAll(setOf("weapon", "weapon.mainhand", "weapon.offhand", "armor.head", "armor.chest", "armor.legs", "armor.feet", "horse.saddle", "horse.armor", "horse.chest"))
}
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
val slot = stringReader.readUnquotedString()
@ -28,35 +50,5 @@ class ItemSlotParser : CommandParser() {
throw UnknownInventorySlotCommandParseException(stringReader, slot)
}
return slot
}
companion object {
private val SLOTS = HashSet<String>()
init {
for (i in 0 until 54) {
SLOTS.add("container.$i")
}
for (i in 0 until 9) {
SLOTS.add("hotbar.$i")
}
for (i in 0 until 27) {
SLOTS.add("inventory." + (9 + i))
}
for (i in 0 until 27) {
SLOTS.add("enderchest." + (200 + i))
}
for (i in 0 until 8) {
SLOTS.add("villager." + (300 + i))
}
for (i in 0 until 15) {
SLOTS.add("horse." + (500 + i))
}
SLOTS.addAll(setOf("weapon", "weapon.mainhand", "weapon.offhand", "armor.head", "armor.chest", "armor.legs", "armor.feet", "horse.saddle", "horse.armor", "horse.chest"))
}
val ITEM_SLOT_PARSER = ItemSlotParser()
}
}

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.nbt.ExpectedPrimitiveTagCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
@ -21,7 +20,6 @@ import de.bixilon.minosoft.util.nbt.tag.CompoundTag
class NBTParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
return when (this) {
NBT_PARSER -> {

View File

@ -13,15 +13,13 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.resourcelocation.InvalidResourceLocationCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
class ObjectiveParser : CommandParser() {
object ObjectiveParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
val argument = stringReader.readUnquotedString()
if (!ProtocolDefinition.SCOREBOARD_OBJECTIVE_PATTERN.matcher(argument).matches()) {
@ -29,8 +27,4 @@ class ObjectiveParser : CommandParser() {
}
return argument
}
companion object {
val OBJECTIVE_PARSER = ObjectiveParser()
}
}

View File

@ -13,15 +13,14 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.UnknownOperationCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class OperationParser : CommandParser() {
object OperationParser : CommandParser() {
private val OPERATIONS = setOf("=", "+=", "-=", "*=", "/=", "%=", "<", ">", "><")
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
val operation = stringReader.readUnquotedString()
if (!OPERATIONS.contains(operation)) {
@ -30,9 +29,4 @@ class OperationParser : CommandParser() {
return operation
}
companion object {
private val OPERATIONS = setOf("=", "+=", "-=", "*=", "/=", "%=", "<", ">", "><")
val OPERATION_PARSER = OperationParser()
}
}

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.resourcelocation.ParticleNotFoundCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.mappings.particle.data.BlockParticleData
@ -22,9 +21,8 @@ import de.bixilon.minosoft.data.mappings.particle.data.ItemParticleData
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.protocol.network.Connection
class ParticleParser : CommandParser() {
object ParticleParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): ParticleData {
val resourceLocation = stringReader.readResourceLocation()
@ -51,8 +49,4 @@ class ParticleParser : CommandParser() {
else -> ParticleData(particle)
}
}
companion object {
val PARTICLE_PARSER = ParticleParser()
}
}

View File

@ -13,18 +13,13 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.protocol.network.Connection
class ResourceLocationParser : CommandParser() {
object ResourceLocationParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): ResourceLocation {
return stringReader.readResourceLocation().value
}
companion object {
val RESOURCE_LOCATION_PARSER = ResourceLocationParser()
}
}

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class RotationParser : CoordinateParser() {
object RotationParser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
return readCoordinates(stringReader, true, 2)
}
companion object {
val ROTATION_PARSER = RotationParser()
}
}

View File

@ -10,29 +10,21 @@
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.commands.parser
package de.bixilon.minosoft.data.commands.parser;
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.commands.parser.properties.ScoreHolderParserProperties
import de.bixilon.minosoft.protocol.network.Connection
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
import de.bixilon.minosoft.data.commands.CommandStringReader;
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ScoreHolderParserProperties;
import de.bixilon.minosoft.protocol.network.Connection;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
object ScoreHolderParser : CommandParser() {
import javax.annotation.Nullable;
public class ScoreHolderParser extends CommandParser {
public static final ScoreHolderParser SCORE_HOLDER_PARSER = new ScoreHolderParser();
@Override
public ParserProperties readParserProperties(InByteBuffer buffer) {
return new ScoreHolderParserProperties(buffer);
override fun readParserProperties(buffer: InByteBuffer): ParserProperties? {
return ScoreHolderParserProperties(buffer)
}
@Override
public Object parse(Connection connection, @Nullable ParserProperties properties, CommandStringReader stringReader) throws CommandParseException {
// ToDo
return null;
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
TODO()
}
}

View File

@ -14,15 +14,14 @@ package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.ColorNotFoundCommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.UnknownOperationCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.data.text.ChatColors
import de.bixilon.minosoft.protocol.network.Connection
class ScoreboardSlotParser : CommandParser() {
object ScoreboardSlotParser : CommandParser() {
private val SCOREBOARD_SLOTS = setOf("list", "sidebar", "belowName")
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
val slot = stringReader.readUnquotedString()
@ -41,9 +40,4 @@ class ScoreboardSlotParser : CommandParser() {
return slot
}
companion object {
private val SCOREBOARD_SLOTS = setOf("list", "sidebar", "belowName")
val SCOREBOARD_SLOT_PARSER = ScoreboardSlotParser()
}
}

View File

@ -14,14 +14,12 @@ package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.BadSwizzleCombinationCommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class SwizzleParser : CommandParser() {
object SwizzleParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
val swizzle = stringReader.readUnquotedString()
val containing: HashSet<Char> = HashSet()
@ -40,8 +38,4 @@ class SwizzleParser : CommandParser() {
return swizzle
}
companion object {
val SWIZZLE_PARSER = SwizzleParser()
}
}

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class TeamParser : CommandParser() {
object TeamParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): String {
return stringReader.readUnquotedString()
}
companion object {
val TEAM_PARSER = TeamParser()
}
}

View File

@ -13,16 +13,15 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.exceptions.UUIDCommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
import de.bixilon.minosoft.util.Util
import java.util.*
class UUIDParser : CommandParser() {
object UUIDParser : CommandParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): UUID {
val argument = stringReader.readString()
try {
return Util.getUUIDFromString(argument)
@ -30,8 +29,4 @@ class UUIDParser : CommandParser() {
throw UUIDCommandParseException(stringReader, argument, exception)
}
}
companion object {
val UUID_PARSER = UUIDParser()
}
}

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class Vec2Parser : CoordinateParser() {
object Vec2Parser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
return readCoordinates(stringReader, true, 2)
}
companion object {
val VEC2_PARSER = Vec2Parser()
}
}

View File

@ -13,18 +13,12 @@
package de.bixilon.minosoft.data.commands.parser
import de.bixilon.minosoft.data.commands.CommandStringReader
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties
import de.bixilon.minosoft.protocol.network.Connection
class Vec3Parser : CoordinateParser() {
object Vec3Parser : CoordinateParser() {
@Throws(CommandParseException::class)
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any? {
override fun parse(connection: Connection, properties: ParserProperties?, stringReader: CommandStringReader): Any {
return readCoordinates(stringReader, true, 3)
}
companion object {
val VEC3_PARSER = Vec3Parser()
}
}