diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/AngleParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/AngleParser.kt index 5f90ab350..9de5fe60e 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/AngleParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/AngleParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/BlockPositionParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/BlockPositionParser.kt index 9cea79bc3..f3858460d 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/BlockPositionParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/BlockPositionParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ColorParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ColorParser.kt index 9cfd677e3..50c04caf6 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ColorParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ColorParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ColumnPositionParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ColumnPositionParser.kt index 19b9c346d..17d93a452 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ColumnPositionParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ColumnPositionParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParsers.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParsers.kt index 9470fb3f0..50ee6adbb 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParsers.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParsers.kt @@ -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 diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ComponentParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ComponentParser.kt index a8cd39b5a..6ac3d8a6c 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ComponentParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ComponentParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/GameProfileParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/GameProfileParser.kt index 8aedd1221..1960eaa6e 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/GameProfileParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/GameProfileParser.kt @@ -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) } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ItemSlotParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ItemSlotParser.kt index eb21a6f83..6a7ce6e4b 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ItemSlotParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ItemSlotParser.kt @@ -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() + + 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() - - 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() } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/NBTParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/NBTParser.kt index 6099c77c4..7fbb374e9 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/NBTParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/NBTParser.kt @@ -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 -> { diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ObjectiveParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ObjectiveParser.kt index 3758150d8..7d940ba0d 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ObjectiveParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ObjectiveParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/OperationParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/OperationParser.kt index 3e3f3ea74..60c6ead6e 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/OperationParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/OperationParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ParticleParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ParticleParser.kt index 31c94e674..0fbe73c8c 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ParticleParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ParticleParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ResourceLocationParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ResourceLocationParser.kt index a31562caf..22f98537a 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ResourceLocationParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ResourceLocationParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/RotationParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/RotationParser.kt index 657587cee..db9675624 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/RotationParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/RotationParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.kt similarity index 51% rename from src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java rename to src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.kt index 7294b63d8..7b46597ec 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.kt @@ -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() } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreboardSlotParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreboardSlotParser.kt index c59cc6833..bfe5211a2 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreboardSlotParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreboardSlotParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/SwizzleParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/SwizzleParser.kt index 160e8709e..8ee42760d 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/SwizzleParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/SwizzleParser.kt @@ -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 = HashSet() @@ -40,8 +38,4 @@ class SwizzleParser : CommandParser() { return swizzle } - - companion object { - val SWIZZLE_PARSER = SwizzleParser() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/TeamParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/TeamParser.kt index 082d25e81..637f3b894 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/TeamParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/TeamParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/UUIDParser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/UUIDParser.kt index 93b0dec2e..eff5113c1 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/UUIDParser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/UUIDParser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec2Parser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec2Parser.kt index 730c331d1..bf8355de6 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec2Parser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec2Parser.kt @@ -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() - } } diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec3Parser.kt b/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec3Parser.kt index 3c14bca89..474036a06 100644 --- a/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec3Parser.kt +++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/Vec3Parser.kt @@ -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() - } }