From ed62328d03bce30379659b30b8e335b045142265 Mon Sep 17 00:00:00 2001 From: StillLutto Date: Sat, 21 Dec 2024 13:36:19 +0100 Subject: [PATCH] feat(score-holder): merge ScoreHolderArgument and ScoreHoldersArgument --- .../stellar/argument/ArgumentHandler.kt | 9 ++-- .../types/scoreboard/ScoreHolderArgument.kt | 9 ++-- .../argument/types/world/LocationArgument.kt | 10 ++--- .../exception/UnsupportedArgumentException.kt | 4 +- .../main/kotlin/com/undefined/stellar/Main.kt | 15 ++++--- .../stellar/v1_19_2/ArgumentHelper.kt | 42 +++++++++---------- .../stellar/v1_19_3/ArgumentHelper.kt | 42 +++++++++---------- .../stellar/v1_19_4/ArgumentHelper.kt | 42 +++++++++---------- .../undefined/stellar/v1_20/ArgumentHelper.kt | 34 ++++++++------- .../stellar/v1_20_1/ArgumentHelper.kt | 34 ++++++++------- .../stellar/v1_20_2/ArgumentHelper.kt | 35 +++++++++------- .../stellar/v1_20_4/ArgumentHelper.kt | 35 +++++++++------- .../stellar/v1_20_6/ArgumentHelper.kt | 34 ++++++++------- .../undefined/stellar/v1_21/ArgumentHelper.kt | 35 +++++++++------- .../stellar/v1_21_1/ArgumentHelper.kt | 35 +++++++++------- .../stellar/v1_21_3/ArgumentHelper.kt | 41 +++++++++--------- .../stellar/v1_21_4/ArgumentHelper.kt | 35 +++++++++------- 17 files changed, 263 insertions(+), 228 deletions(-) diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt b/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt index 8d9e21e..05dc75f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt @@ -117,7 +117,7 @@ open class ArgumentHandler { fun addGameProfileArgument(name: String): GameProfileArgument = addArgument { GameProfileArgument(base, name) } - fun addLocationArgument(name: String, type: LocationType = LocationType.LOCATION3D): LocationArgument = + fun addLocationArgument(name: String, type: LocationType = LocationType.LOCATION_3D): LocationArgument = addArgument { LocationArgument(base, name, type) } fun addBlockDataArgument(name: String): BlockDataArgument = @@ -165,11 +165,8 @@ open class ArgumentHandler { fun addDisplaySlotArgument(name: String): DisplaySlotArgument = addArgument { DisplaySlotArgument(base, name) } - fun addScoreHolderArgument(name: String): ScoreHoldersArgument = - addArgument { ScoreHoldersArgument(base, name) } - - fun addScoreHoldersArgument(name: String): ScoreHoldersArgument = - addArgument { ScoreHoldersArgument(base, name) } + fun addScoreHolderArgument(name: String, type: ScoreHolderType = ScoreHolderType.SINGLE): ScoreHolderArgument = + addArgument { ScoreHolderArgument(base, name, type) } fun addAxisArgument(name: String): AxisArgument = addArgument { AxisArgument(base, name) } diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt index a9f890e..dce6b01 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt @@ -1,10 +1,11 @@ -@file:Suppress("UNCHECKED_CAST") - package com.undefined.stellar.argument.types.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ScoreHoldersArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) +class ScoreHolderArgument(parent: AbstractStellarCommand<*>, name: String, val type: ScoreHolderType) : AbstractStellarArgument(parent, name) -class ScoreHolderArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +enum class ScoreHolderType { + SINGLE, + MULTIPLE; +} \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt index 51c03fd..1554177 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt @@ -6,8 +6,8 @@ import com.undefined.stellar.argument.AbstractStellarArgument class LocationArgument(parent: AbstractStellarCommand<*>, name: String, val type: LocationType) : AbstractStellarArgument(parent, name) enum class LocationType { - LOCATION3D, - LOCATION2D, - DOUBLE_LOCATION_3D, - DOUBLE_LOCATION_2D -} + LOCATION_3D, + LOCATION_2D, + PRECISE_LOCATION_3D, + PRECISE_LOCATION_2D +} \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/exception/UnsupportedArgumentException.kt b/common/src/main/kotlin/com/undefined/stellar/exception/UnsupportedArgumentException.kt index be1b688..fcdc85c 100644 --- a/common/src/main/kotlin/com/undefined/stellar/exception/UnsupportedArgumentException.kt +++ b/common/src/main/kotlin/com/undefined/stellar/exception/UnsupportedArgumentException.kt @@ -1,3 +1,5 @@ package com.undefined.stellar.exception -class UnsupportedArgumentException : RuntimeException("This Argument is unsupported by Stellar! This is totally unintentional behaviour.") \ No newline at end of file +import com.undefined.stellar.argument.AbstractStellarArgument + +class UnsupportedArgumentException(val argument: AbstractStellarArgument<*>) : RuntimeException("${argument::class.simpleName} is unsupported by Stellar! This is totally unintentional behaviour.") \ No newline at end of file diff --git a/server/src/main/kotlin/com/undefined/stellar/Main.kt b/server/src/main/kotlin/com/undefined/stellar/Main.kt index 71f033a..0f27ef2 100644 --- a/server/src/main/kotlin/com/undefined/stellar/Main.kt +++ b/server/src/main/kotlin/com/undefined/stellar/Main.kt @@ -1,19 +1,24 @@ package com.undefined.stellar +import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import org.bukkit.plugin.java.JavaPlugin -import java.util.function.Predicate +import org.bukkit.scoreboard.Criteria +import org.bukkit.scoreboard.Objective class Main : JavaPlugin() { override fun onEnable() { - StellarCommand("isItem") - .addItemArgument(name = "item") + if (Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective("test") == null) + Bukkit.getScoreboardManager()!!.mainScoreboard.registerNewObjective("test", Criteria.HEALTH, "test") + StellarCommand("objective") + .addScoreHolderArgument(name = "holder") .addExecution { - val predicate = getArgument>("item") - sender.inventory.setItem() + val holder = getArgument("holder") + val item = ItemStack(Material.DIAMOND) + Bukkit.getPlayer(holder)?.inventory?.addItem(item) } .register(this) } diff --git a/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt b/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt index 18830b6..b0c0e49 100644 --- a/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt +++ b/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt @@ -23,7 +23,7 @@ import com.undefined.stellar.argument.types.player.GameModeArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.world.* @@ -113,19 +113,15 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.text.ColorArgument -> ColorArgument.color() is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) @@ -137,8 +133,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -180,7 +178,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registry.ENTITY_TYPE.key()) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> ResourceKeyArgument.key(Registry.MEMORY_MODULE_TYPE.key()) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -227,8 +225,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -273,7 +273,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registry.ENTITY_TYPE_REGISTRY)) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registry.MEMORY_MODULE_TYPE_REGISTRY)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -466,10 +466,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> context.getArgument(command.name, Coordinates::class.java).getBlockPos(context.source).toLocation(world); - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> context.getArgument(command.name, Coordinates::class.java).getBlockPos(context.source).toLocation(world); + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt b/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt index 13784bf..c4149e1 100644 --- a/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt +++ b/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt @@ -22,7 +22,7 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.world.* @@ -113,19 +113,15 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.text.ColorArgument -> ColorArgument.color() is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) @@ -139,8 +135,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -182,7 +180,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -229,8 +227,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -275,7 +275,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -451,10 +451,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> context.getArgument(command.name, Coordinates::class.java).getBlockPos(context.source).toLocation(world); - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> context.getArgument(command.name, Coordinates::class.java).getBlockPos(context.source).toLocation(world); + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt b/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt index 408f645..e39b9e3 100644 --- a/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt +++ b/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt @@ -25,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,19 +120,15 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate( - COMMAND_BUILD_CONTEXT - ) + is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.text.ColorArgument -> ColorArgument.color() is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) @@ -146,8 +142,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -189,7 +187,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -236,8 +234,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -282,7 +282,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -458,10 +458,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_20/src/main/kotlin/com/undefined/stellar/v1_20/ArgumentHelper.kt b/v1_20/src/main/kotlin/com/undefined/stellar/v1_20/ArgumentHelper.kt index f14107b..c75f945 100644 --- a/v1_20/src/main/kotlin/com/undefined/stellar/v1_20/ArgumentHelper.kt +++ b/v1_20/src/main/kotlin/com/undefined/stellar/v1_20/ArgumentHelper.kt @@ -25,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +120,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +140,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +185,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +232,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +280,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -452,10 +456,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt b/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt index d370a8d..31621e0 100644 --- a/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt +++ b/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt @@ -25,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +120,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +140,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +185,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +232,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +280,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> throwArgumentVersionException(argument) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -452,10 +456,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt b/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt index 0cfb5b2..f4a4d9f 100644 --- a/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt +++ b/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -121,10 +120,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -141,8 +140,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -184,7 +185,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -231,8 +232,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name) - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name) + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name) + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -277,7 +280,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -453,10 +456,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt index a6a3030..b269f35 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -121,10 +120,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -141,8 +140,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -184,7 +185,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -231,8 +232,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -277,7 +280,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -454,10 +457,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt index c6886fc..866d6a9 100644 --- a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt +++ b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt @@ -25,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -119,10 +119,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -139,8 +139,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -182,7 +184,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -228,8 +230,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -274,7 +278,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -459,10 +463,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_21/src/main/kotlin/com/undefined/stellar/v1_21/ArgumentHelper.kt b/v1_21/src/main/kotlin/com/undefined/stellar/v1_21/ArgumentHelper.kt index 55151a3..3cd909e 100644 --- a/v1_21/src/main/kotlin/com/undefined/stellar/v1_21/ArgumentHelper.kt +++ b/v1_21/src/main/kotlin/com/undefined/stellar/v1_21/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +119,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +139,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +184,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +231,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +279,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -463,10 +466,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt b/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt index 9bd4927..85327d1 100644 --- a/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt +++ b/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +119,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +139,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +184,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +231,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +279,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -463,10 +466,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } diff --git a/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt b/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt index 51c49d7..f1b2be3 100644 --- a/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt +++ b/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +119,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +139,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +184,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +231,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +279,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -461,17 +464,17 @@ object ArgumentHelper { } private fun getLocation(context: CommandContext, command: LocationArgument): Location { - val world = context.source.bukkitWorld + val world = context.source.level.world return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } } - private fun BlockPos.toLocation(world: World?) = Location(world, x.toDouble(), y.toDouble(), z.toDouble()) - private fun ColumnPos.toLocation(world: World?) = Location(world, x.toDouble(), 0.0, z.toDouble()) + private fun BlockPos.toLocation(world: World) = Location(world, x.toDouble(), y.toDouble(), z.toDouble()) + private fun ColumnPos.toLocation(world: World) = Location(world, x.toDouble(), 0.0, z.toDouble()) private fun Vec3.toLocation(world: World?) = Location(world, x, y, z) private fun Vec2.toLocation(world: World?) = Location(world, x.toDouble(), 0.0, y.toDouble()) diff --git a/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt b/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt index 6fe48ff..eef7a71 100644 --- a/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt +++ b/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt @@ -16,7 +16,6 @@ import com.undefined.stellar.argument.types.block.BlockDataArgument import com.undefined.stellar.argument.types.registry.BlockTypeArgument import com.undefined.stellar.argument.types.registry.FluidArgument import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.EnumArgument import com.undefined.stellar.argument.types.custom.ListArgument import com.undefined.stellar.argument.types.entity.* import com.undefined.stellar.argument.types.item.* @@ -26,13 +25,13 @@ import com.undefined.stellar.argument.types.misc.UUIDArgument import com.undefined.stellar.argument.types.primitive.* import com.undefined.stellar.argument.types.registry.* import com.undefined.stellar.argument.types.scoreboard.DisplaySlotArgument -import com.undefined.stellar.argument.types.scoreboard.ScoreHoldersArgument import com.undefined.stellar.argument.types.registry.InstrumentArgument import com.undefined.stellar.argument.types.registry.SoundArgument import com.undefined.stellar.argument.types.structure.MirrorArgument import com.undefined.stellar.argument.types.registry.StructureArgument import com.undefined.stellar.argument.types.structure.StructureRotationArgument import com.undefined.stellar.argument.types.registry.StructureTypeArgument +import com.undefined.stellar.argument.types.scoreboard.ScoreHolderType import com.undefined.stellar.argument.types.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation @@ -120,10 +119,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { - LocationType.LOCATION3D -> BlockPosArgument.blockPos() - LocationType.LOCATION2D -> ColumnPosArgument.columnPos() - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.vec3() - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() + LocationType.LOCATION_3D -> BlockPosArgument.blockPos() + LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.vec3() + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) @@ -140,8 +139,10 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.scoreHolder() - is ScoreHoldersArgument -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } is AxisArgument -> SwizzleArgument.swizzle() is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() @@ -183,7 +184,7 @@ object ArgumentHelper { is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } fun > getParsedArgument(context: CommandContext, argument: T): Any? { @@ -230,8 +231,10 @@ object ArgumentHelper { Location(context.source.bukkitWorld, rotation.x, rotation.y, rotation.z) } is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> ScoreHolderArgument.getName(context, argument.name).scoreboardName - is ScoreHoldersArgument -> ScoreHolderArgument.getNames(context, argument.name).map { scoreholder -> scoreholder.scoreboardName } + is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } is AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) @@ -276,7 +279,7 @@ object ArgumentHelper { is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name, Registries.ENTITY_TYPE)) is PotionArgument -> org.bukkit.Registry.POTION.get(getId(context, argument.name, Registries.POTION)) is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) - else -> throw UnsupportedArgumentException() + else -> throw UnsupportedArgumentException(argument) } } @@ -463,10 +466,10 @@ object ArgumentHelper { private fun getLocation(context: CommandContext, command: LocationArgument): Location { val world = context.source.bukkitWorld return when (command.type) { - LocationType.LOCATION3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) - LocationType.LOCATION2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) - LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) + LocationType.LOCATION_3D -> BlockPosArgument.getBlockPos(context, command.name).toLocation(world) + LocationType.LOCATION_2D -> ColumnPosArgument.getColumnPos(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_3D -> Vec3Argument.getVec3(context, command.name).toLocation(world) + LocationType.PRECISE_LOCATION_2D -> Vec2Argument.getVec2(context, command.name).toLocation(world) } }