From e3f8d12850bddfb62b83b8308fc4fee68a3ccc01 Mon Sep 17 00:00:00 2001 From: StillLutto Date: Mon, 13 Jan 2025 20:04:47 +0100 Subject: [PATCH] feat(paper): add 1.21.4 support --- .../argument/AbstractStellarArgument.kt | 2 + .../stellar/argument/ArgumentHandler.kt | 161 ++++--- .../{types => }/block/BlockDataArgument.kt | 2 +- .../block/BlockPredicateArgument.kt | 2 +- .../{types => }/custom/CustomArgument.kt | 3 +- .../{types => }/custom/EnumArgument.kt | 6 +- .../{types => }/custom/ListArgument.kt | 2 +- .../entity/EntityAnchorArgument.kt | 2 +- .../{types => }/entity/EntityArgument.kt | 4 +- .../argument/{types => }/item/ItemArgument.kt | 4 +- .../{types => }/item/ItemPredicateArgument.kt | 2 +- .../{types => }/item/ItemSlotArgument.kt | 2 +- .../{types => }/item/ItemSlotsArgument.kt | 2 +- .../{types => }/math/AngleArgument.kt | 2 +- .../argument/{types => }/math/AxisArgument.kt | 4 +- .../{types => }/math/OperationArgument.kt | 2 +- .../{types => }/math/RangeArgument.kt | 2 +- .../{types => }/math/RotationArgument.kt | 4 +- .../argument/{types => }/math/TimeArgument.kt | 2 +- .../{types => }/misc/NamespacedKeyArgument.kt | 2 +- .../argument/{types => }/misc/UUIDArgument.kt | 2 +- .../{types => }/player/GameModeArgument.kt | 2 +- .../{types => }/player/GameProfileArgument.kt | 2 +- .../{types => }/primitive/BooleanArgument.kt | 2 +- .../{types => }/primitive/DoubleArgument.kt | 2 +- .../argument/primitive/FloatArgument.kt | 6 + .../{types => }/primitive/IntegerArgument.kt | 2 +- .../{types => }/primitive/LongArgument.kt | 4 +- .../{types => }/primitive/PhraseArgument.kt | 2 +- .../{types => }/primitive/StringArgument.kt | 2 +- .../{types => }/primitive/WordArgument.kt | 2 +- .../{types => }/registry/ArtArgument.kt | 4 +- .../{types => }/registry/AttributeArgument.kt | 4 +- .../{types => }/registry/BiomeArgument.kt | 4 +- .../{types => }/registry/BlockTypeArgument.kt | 2 +- .../{types => }/registry/CatTypeArgument.kt | 2 +- .../registry/DamageTypeArgument.kt | 2 +- .../registry/EntityTypeArgument.kt | 2 +- .../{types => }/registry/FluidArgument.kt | 2 +- .../registry/FrogVariantArgument.kt | 4 +- .../{types => }/registry/GameEventArgument.kt | 2 +- .../registry/InstrumentArgument.kt | 2 +- .../registry/InventoryTypeArgument.kt | 2 +- .../{types => }/registry/ItemTypeArgument.kt | 2 +- .../registry/MapDecorationTypeArgument.kt | 4 +- .../{types => }/registry/MemoryKeyArgument.kt | 4 +- .../registry/PatternTypeArgument.kt | 2 +- .../{types => }/registry/PotionArgument.kt | 2 +- .../registry/PotionEffectTypeArgument.kt | 2 +- .../{types => }/registry/SoundArgument.kt | 2 +- .../{types => }/registry/StructureArgument.kt | 2 +- .../registry/StructureTypeArgument.kt | 4 +- .../registry/TrimMaterialArgument.kt | 2 +- .../registry/TrimPatternArgument.kt | 2 +- .../registry/VillagerProfessionArgument.kt | 2 +- .../registry/VillagerTypeArgument.kt | 4 +- .../registry/WolfVariantArgument.kt | 2 +- .../scoreboard/DisplaySlotArgument.kt | 4 +- .../scoreboard/ObjectiveArgument.kt | 4 +- .../scoreboard/ObjectiveCriteriaArgument.kt | 2 +- .../scoreboard/ScoreHolderArgument.kt | 4 +- .../{types => }/scoreboard/TeamArgument.kt | 4 +- .../structure/LootTableArgument.kt | 2 +- .../{types => }/structure/MirrorArgument.kt | 2 +- .../structure/StructureRotationArgument.kt | 4 +- .../{types => }/text/ColorArgument.kt | 2 +- .../{types => }/text/ComponentArgument.kt | 2 +- .../{types => }/text/MessageArgument.kt | 2 +- .../{types => }/text/StyleArgument.kt | 2 +- .../argument/types/primitive/FloatArgument.kt | 6 - .../{types => }/world/DimensionArgument.kt | 4 +- .../{types => }/world/HeightMapArgument.kt | 2 +- .../{types => }/world/LocationArgument.kt | 2 +- .../{types => }/world/ParticleArgument.kt | 4 +- paper/api/build.gradle.kts | 4 +- .../stellar/manager/CommandManager.kt | 2 +- .../arguments/custom/CustomArgument.kt | 48 ++ paper/{v1_17_1 => v1_21_4}/build.gradle.kts | 6 +- .../stellar/v1_21_4/ArgumentAdapter.kt | 258 ++++++++++ .../stellar/v1_21_4/ArgumentHelper.kt | 239 ++++++++++ .../v1_21_4}/BrigadierCommandHelper.kt | 12 +- .../stellar/v1_21_4}/CommandAdapter.kt | 15 +- .../stellar/v1_21_4}/CommandContextAdapter.kt | 22 +- .../stellar/v1_21_4}/CommandRegistrar.kt | 6 +- server/build.gradle.kts | 11 +- .../main/kotlin/com/undefined/stellar/Main.kt | 8 +- settings.gradle.kts | 2 +- .../stellar/manager/CommandManager.kt | 3 +- .../undefined/stellar/v1_13/ArgumentHelper.kt | 189 ++++---- .../undefined/stellar/v1_13/CommandAdapter.kt | 2 +- .../stellar/v1_13/CommandContextAdapter.kt | 2 +- .../stellar/v1_13_1/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_13_1/CommandAdapter.kt | 2 +- .../stellar/v1_13_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_13_2/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_13_2/CommandAdapter.kt | 2 +- .../stellar/v1_13_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_14_1/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_14_1/CommandAdapter.kt | 2 +- .../stellar/v1_14_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_14_1/CommandRegistrar.kt | 2 +- .../stellar/v1_14_2/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_14_2/CommandAdapter.kt | 2 +- .../stellar/v1_14_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_14_2/CommandRegistrar.kt | 2 +- .../stellar/v1_14_3/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_14_3/CommandAdapter.kt | 2 +- .../stellar/v1_14_3/CommandContextAdapter.kt | 2 +- .../stellar/v1_14_3/CommandRegistrar.kt | 2 +- .../stellar/v1_14_4/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_14_4/CommandAdapter.kt | 2 +- .../stellar/v1_14_4/CommandContextAdapter.kt | 2 +- .../stellar/v1_14_4/CommandRegistrar.kt | 2 +- .../undefined/stellar/v1_15/ArgumentHelper.kt | 195 ++++---- .../undefined/stellar/v1_15/CommandAdapter.kt | 2 +- .../stellar/v1_15/CommandContextAdapter.kt | 2 +- .../stellar/v1_15/CommandRegistrar.kt | 2 +- .../stellar/v1_15_1/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_15_1/CommandAdapter.kt | 2 +- .../stellar/v1_15_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_15_1/CommandRegistrar.kt | 2 +- .../stellar/v1_15_2/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_15_2/CommandAdapter.kt | 2 +- .../stellar/v1_15_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_15_2/CommandRegistrar.kt | 2 +- .../stellar/v1_16_1/ArgumentHelper.kt | 197 ++++---- .../stellar/v1_16_1/CommandAdapter.kt | 2 +- .../stellar/v1_16_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_16_1/CommandRegistrar.kt | 2 +- .../stellar/v1_16_2/ArgumentHelper.kt | 197 ++++---- .../stellar/v1_16_2/CommandAdapter.kt | 2 +- .../stellar/v1_16_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_16_2/CommandRegistrar.kt | 2 +- .../stellar/v1_16_3/ArgumentHelper.kt | 197 ++++---- .../stellar/v1_16_3/CommandAdapter.kt | 2 +- .../stellar/v1_16_3/CommandContextAdapter.kt | 2 +- .../stellar/v1_16_3/CommandRegistrar.kt | 2 +- .../stellar/v1_16_4/ArgumentHelper.kt | 197 ++++---- .../stellar/v1_16_4/CommandAdapter.kt | 2 +- .../stellar/v1_16_4/CommandContextAdapter.kt | 2 +- .../stellar/v1_16_4/CommandRegistrar.kt | 2 +- .../stellar/v1_16_5/ArgumentHelper.kt | 197 ++++---- .../stellar/v1_16_5/CommandAdapter.kt | 2 +- .../stellar/v1_16_5/CommandContextAdapter.kt | 2 +- .../stellar/v1_16_5/CommandRegistrar.kt | 2 +- .../undefined/stellar/v1_17/ArgumentHelper.kt | 195 ++++---- .../undefined/stellar/v1_17/CommandAdapter.kt | 2 +- .../stellar/v1_17/CommandContextAdapter.kt | 2 +- .../stellar/v1_17/CommandRegistrar.kt | 2 +- .../com/undefined/stellar}/ArgumentHelper.kt | 197 ++++---- .../{v1_17_1 => }/BrigadierCommandHelper.kt | 3 +- .../com/undefined/stellar}/CommandAdapter.kt | 7 +- .../{v1_17_1 => }/CommandContextAdapter.kt | 6 +- .../stellar/{v1_17_1 => }/CommandRegistrar.kt | 10 +- .../stellar/v1_17_1/ArgumentHelper.kt | 443 ------------------ .../stellar/v1_18_1/ArgumentHelper.kt | 195 ++++---- .../stellar/v1_18_1/CommandAdapter.kt | 2 +- .../stellar/v1_18_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_18_1/CommandRegistrar.kt | 2 +- .../stellar/v1_18_2/ArgumentHelper.kt | 189 ++++---- .../stellar/v1_18_2/CommandAdapter.kt | 2 +- .../stellar/v1_18_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_18_2/CommandRegistrar.kt | 2 +- .../stellar/v1_19_2/ArgumentHelper.kt | 189 ++++---- .../stellar/v1_19_2/CommandAdapter.kt | 2 +- .../stellar/v1_19_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_19_2/CommandRegistrar.kt | 2 +- .../stellar/v1_19_3/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_19_3/CommandAdapter.kt | 2 +- .../stellar/v1_19_3/CommandContextAdapter.kt | 2 +- .../stellar/v1_19_3/CommandRegistrar.kt | 2 +- .../stellar/v1_19_4/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_19_4/CommandAdapter.kt | 2 +- .../stellar/v1_19_4/CommandContextAdapter.kt | 2 +- .../stellar/v1_19_4/CommandRegistrar.kt | 2 +- .../stellar/v1_20_1/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_20_1/CommandAdapter.kt | 2 +- .../stellar/v1_20_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_20_1/CommandRegistrar.kt | 2 +- .../stellar/v1_20_2/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_20_2/CommandAdapter.kt | 2 +- .../stellar/v1_20_2/CommandContextAdapter.kt | 2 +- .../stellar/v1_20_2/CommandRegistrar.kt | 2 +- .../stellar/v1_20_4/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_20_4/CommandAdapter.kt | 2 +- .../stellar/v1_20_4/CommandContextAdapter.kt | 2 +- .../stellar/v1_20_4/CommandRegistrar.kt | 2 +- .../stellar/v1_20_6/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_20_6/CommandAdapter.kt | 2 +- .../stellar/v1_20_6/CommandContextAdapter.kt | 2 +- .../stellar/v1_20_6/CommandRegistrar.kt | 2 +- .../stellar/v1_21_1/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_21_1/CommandAdapter.kt | 2 +- .../stellar/v1_21_1/CommandContextAdapter.kt | 2 +- .../stellar/v1_21_1/CommandRegistrar.kt | 2 +- .../stellar/v1_21_3/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_21_3/CommandAdapter.kt | 2 +- .../stellar/v1_21_3/CommandContextAdapter.kt | 2 +- .../stellar/v1_21_3/CommandRegistrar.kt | 2 +- .../stellar/v1_21_4/ArgumentHelper.kt | 191 ++++---- .../stellar/v1_21_4/CommandAdapter.kt | 2 +- .../stellar/v1_21_4/CommandContextAdapter.kt | 2 +- .../stellar/v1_21_4/CommandRegistrar.kt | 2 +- 203 files changed, 3588 insertions(+), 3652 deletions(-) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/block/BlockDataArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/block/BlockPredicateArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/custom/CustomArgument.kt (97%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/custom/EnumArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/custom/ListArgument.kt (96%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/entity/EntityAnchorArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/entity/EntityArgument.kt (55%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/item/ItemArgument.kt (56%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/item/ItemPredicateArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/item/ItemSlotArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/item/ItemSlotsArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/AngleArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/AxisArgument.kt (56%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/OperationArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/RangeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/RotationArgument.kt (55%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/math/TimeArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/misc/NamespacedKeyArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/misc/UUIDArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/player/GameModeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/player/GameProfileArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/BooleanArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/DoubleArgument.kt (83%) create mode 100644 common/src/main/kotlin/com/undefined/stellar/argument/primitive/FloatArgument.kt rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/IntegerArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/LongArgument.kt (50%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/PhraseArgument.kt (97%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/StringArgument.kt (90%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/primitive/WordArgument.kt (98%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/ArtArgument.kt (55%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/AttributeArgument.kt (53%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/BiomeArgument.kt (55%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/BlockTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/CatTypeArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/DamageTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/EntityTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/FluidArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/FrogVariantArgument.kt (53%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/GameEventArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/InstrumentArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/InventoryTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/ItemTypeArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/MapDecorationTypeArgument.kt (67%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/MemoryKeyArgument.kt (53%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/PatternTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/PotionArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/PotionEffectTypeArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/SoundArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/StructureArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/StructureTypeArgument.kt (52%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/TrimMaterialArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/TrimPatternArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/VillagerProfessionArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/VillagerTypeArgument.kt (52%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/registry/WolfVariantArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/scoreboard/DisplaySlotArgument.kt (52%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/scoreboard/ObjectiveArgument.kt (53%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/scoreboard/ObjectiveCriteriaArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/scoreboard/ScoreHolderArgument.kt (50%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/scoreboard/TeamArgument.kt (54%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/structure/LootTableArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/structure/MirrorArgument.kt (81%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/structure/StructureRotationArgument.kt (50%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/text/ColorArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/text/ComponentArgument.kt (83%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/text/MessageArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/text/StyleArgument.kt (82%) delete mode 100644 common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/FloatArgument.kt rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/world/DimensionArgument.kt (54%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/world/HeightMapArgument.kt (82%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/world/LocationArgument.kt (88%) rename common/src/main/kotlin/com/undefined/stellar/argument/{types => }/world/ParticleArgument.kt (55%) create mode 100644 paper/common/src/main/kotlin/com/undefined/stellar/arguments/custom/CustomArgument.kt rename paper/{v1_17_1 => v1_21_4}/build.gradle.kts (78%) create mode 100644 paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentAdapter.kt create mode 100644 paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt rename paper/{v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4}/BrigadierCommandHelper.kt (93%) rename {spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4}/CommandAdapter.kt (90%) rename paper/{v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4}/CommandContextAdapter.kt (79%) rename paper/{v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4}/CommandRegistrar.kt (90%) rename {paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => spigot/v1_17_1/src/main/kotlin/com/undefined/stellar}/ArgumentHelper.kt (65%) rename spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/{v1_17_1 => }/BrigadierCommandHelper.kt (98%) rename {paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1 => spigot/v1_17_1/src/main/kotlin/com/undefined/stellar}/CommandAdapter.kt (95%) rename spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/{v1_17_1 => }/CommandContextAdapter.kt (95%) rename spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/{v1_17_1 => }/CommandRegistrar.kt (84%) delete mode 100644 spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarArgument.kt index 87048a4..e8313b2 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarArgument.kt @@ -21,6 +21,8 @@ abstract class AbstractStellarArgument(val parent: AbstractStellarCommand<*>, return this as T } + fun addSuggestion(text: String): T = addSuggestion(text, "") + fun addSuggestion(suggestion: Suggestion): T = addSuggestions(listOf(suggestion)) fun addSuggestions(suggestions: List): T { 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 ae84861..70fe84b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/ArgumentHandler.kt @@ -3,34 +3,33 @@ package com.undefined.stellar.argument import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.block.BlockPredicateArgument -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.EntityAnchorArgument -import com.undefined.stellar.argument.types.entity.EntityArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemArgument -import com.undefined.stellar.argument.types.item.ItemPredicateArgument -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.* -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -import com.undefined.stellar.argument.types.player.GameModeArgument -import com.undefined.stellar.argument.types.player.GameProfileArgument -import com.undefined.stellar.argument.types.primitive.* -import com.undefined.stellar.argument.types.registry.* -import com.undefined.stellar.argument.types.scoreboard.* -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.text.ColorArgument -import com.undefined.stellar.argument.types.text.ComponentArgument -import com.undefined.stellar.argument.types.text.MessageArgument -import com.undefined.stellar.argument.types.text.StyleArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.block.BlockPredicateArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.EntityAnchorArgument +import com.undefined.stellar.argument.item.ItemPredicateArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.math.AngleArgument +import com.undefined.stellar.argument.math.OperationArgument +import com.undefined.stellar.argument.math.RangeArgument +import com.undefined.stellar.argument.math.TimeArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.player.GameProfileArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.text.ColorArgument +import com.undefined.stellar.argument.text.ComponentArgument +import com.undefined.stellar.argument.text.MessageArgument +import com.undefined.stellar.argument.text.StyleArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.CommandContext import com.undefined.stellar.data.suggestion.Suggestion import org.bukkit.Bukkit @@ -64,10 +63,10 @@ open class ArgumentHandler { return parsedArgument as T } - fun addCustomArgument(argument: CustomArgument): CustomArgument { - addArgument(argument) - return argument - } +// fun addCustomArgument(argument: CustomArgument): CustomArgument { +// addArgument(argument) +// return argument +// } fun addStringArgument(name: String, type: StringType = StringType.WORD): StringArgument = addArgument { StringArgument(base, name, type) } @@ -78,11 +77,11 @@ open class ArgumentHandler { fun addIntegerArgument(name: String, min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE): IntegerArgument = addArgument { IntegerArgument(base, name, min, max) } - fun addLongArgument(name: String, min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE): LongArgument = - addArgument { LongArgument(base, name, min, max) } + fun addLongArgument(name: String, min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE): com.undefined.stellar.argument.primitive.LongArgument = + addArgument { com.undefined.stellar.argument.primitive.LongArgument(base, name, min, max) } - fun addFloatArgument(name: String, min: Float = Float.MIN_VALUE, max: Float = Float.MAX_VALUE): FloatArgument = - addArgument { FloatArgument(base, name, min, max) } + fun addFloatArgument(name: String, min: Float = Float.MIN_VALUE, max: Float = Float.MAX_VALUE): com.undefined.stellar.argument.primitive.FloatArgument = + addArgument { com.undefined.stellar.argument.primitive.FloatArgument(base, name, min, max) } fun addDoubleArgument(name: String, min: Double = Double.MIN_VALUE, max: Double = Double.MAX_VALUE): DoubleArgument = addArgument { DoubleArgument(base, name, min, max) } @@ -164,17 +163,25 @@ open class ArgumentHandler { fun addUUIDListArgument(name: String, list: CommandContext.() -> List): ListArgument = addArgument { ListArgument(UUIDArgument(base, name), list, parse = { it }) } - inline fun > addEnumArgument(name: String): EnumArgument = - addArgument { EnumArgument(base, name, T::class) } + inline fun > addEnumArgument(name: String): com.undefined.stellar.argument.custom.EnumArgument = + addArgument { com.undefined.stellar.argument.custom.EnumArgument(base, name, T::class) } inline fun > addEnumArgument( name: String, noinline converter: (Enum<*>?) -> Suggestion = { Suggestion.withText(it?.name ?: "") }, noinline parse: (Any?) -> Enum? - ): EnumArgument = addArgument { EnumArgument(base, name, T::class, converter, parse) } + ): com.undefined.stellar.argument.custom.EnumArgument = addArgument { + com.undefined.stellar.argument.custom.EnumArgument( + base, + name, + T::class, + converter, + parse + ) + } - fun addEntityArgument(name: String, type: EntityDisplayType): EntityArgument = - addArgument { EntityArgument(base, name, type) } + fun addEntityArgument(name: String, type: com.undefined.stellar.argument.entity.EntityDisplayType): com.undefined.stellar.argument.entity.EntityArgument = + addArgument { com.undefined.stellar.argument.entity.EntityArgument(base, name, type) } fun addGameProfileArgument(name: String): GameProfileArgument = addArgument { GameProfileArgument(base, name) } @@ -188,8 +195,8 @@ open class ArgumentHandler { fun addBlockPredicateArgument(name: String): BlockPredicateArgument = addArgument { BlockPredicateArgument(base, name) } - fun addItemArgument(name: String): ItemArgument = - addArgument { ItemArgument(base, name) } + fun addItemArgument(name: String): com.undefined.stellar.argument.item.ItemArgument = + addArgument { com.undefined.stellar.argument.item.ItemArgument(base, name) } fun addItemPredicateArgument(name: String): ItemPredicateArgument = addArgument { ItemPredicateArgument(base, name) } @@ -206,8 +213,8 @@ open class ArgumentHandler { fun addMessageArgument(name: String): MessageArgument = addArgument { MessageArgument(base, name) } - fun addObjectiveArgument(name: String): ObjectiveArgument = - addArgument { ObjectiveArgument(base, name) } + fun addObjectiveArgument(name: String): com.undefined.stellar.argument.scoreboard.ObjectiveArgument = + addArgument { com.undefined.stellar.argument.scoreboard.ObjectiveArgument(base, name) } fun addObjectiveCriteriaArgument(name: String): ObjectiveCriteriaArgument = addArgument { ObjectiveCriteriaArgument(base, name) } @@ -215,26 +222,26 @@ open class ArgumentHandler { fun addOperationArgument(name: String): OperationArgument = addArgument { OperationArgument(base, name) } - fun addParticleArgument(name: String): ParticleArgument = - addArgument { ParticleArgument(base, name) } + fun addParticleArgument(name: String): com.undefined.stellar.argument.world.ParticleArgument = + addArgument { com.undefined.stellar.argument.world.ParticleArgument(base, name) } fun addAngleArgument(name: String): AngleArgument = addArgument { AngleArgument(base, name) } - fun addRotationArgument(name: String): RotationArgument = - addArgument { RotationArgument(base, name) } + fun addRotationArgument(name: String): com.undefined.stellar.argument.math.RotationArgument = + addArgument { com.undefined.stellar.argument.math.RotationArgument(base, name) } - fun addDisplaySlotArgument(name: String): DisplaySlotArgument = - addArgument { DisplaySlotArgument(base, name) } + fun addDisplaySlotArgument(name: String): com.undefined.stellar.argument.scoreboard.DisplaySlotArgument = + addArgument { com.undefined.stellar.argument.scoreboard.DisplaySlotArgument(base, name) } - fun addScoreHolderArgument(name: String, type: ScoreHolderType = ScoreHolderType.SINGLE): ScoreHolderArgument = - addArgument { ScoreHolderArgument(base, name, type) } + fun addScoreHolderArgument(name: String, type: com.undefined.stellar.argument.scoreboard.ScoreHolderType = com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE): com.undefined.stellar.argument.scoreboard.ScoreHolderArgument = + addArgument { com.undefined.stellar.argument.scoreboard.ScoreHolderArgument(base, name, type) } - fun addAxisArgument(name: String): AxisArgument = - addArgument { AxisArgument(base, name) } + fun addAxisArgument(name: String): com.undefined.stellar.argument.math.AxisArgument = + addArgument { com.undefined.stellar.argument.math.AxisArgument(base, name) } - fun addTeamArgument(name: String): TeamArgument = - addArgument { TeamArgument(base, name) } + fun addTeamArgument(name: String): com.undefined.stellar.argument.scoreboard.TeamArgument = + addArgument { com.undefined.stellar.argument.scoreboard.TeamArgument(base, name) } fun addItemSlotArgument(name: String): ItemSlotArgument = addArgument { ItemSlotArgument(base, name) } @@ -254,8 +261,8 @@ open class ArgumentHandler { fun addGameModeArgument(name: String): GameModeArgument = addArgument { GameModeArgument(base, name) } - fun addDimensionArgument(name: String): DimensionArgument = - addArgument { DimensionArgument(base, name) } + fun addDimensionArgument(name: String): com.undefined.stellar.argument.world.DimensionArgument = + addArgument { com.undefined.stellar.argument.world.DimensionArgument(base, name) } fun addTimeArgument(name: String, minimum: Int = 0): TimeArgument = addArgument { TimeArgument(base, name, minimum) } @@ -263,8 +270,8 @@ open class ArgumentHandler { fun addMirrorArgument(name: String): MirrorArgument = addArgument { MirrorArgument(base, name) } - fun addStructureRotationArgument(name: String): StructureRotationArgument = - addArgument { StructureRotationArgument(base, name) } + fun addStructureRotationArgument(name: String): com.undefined.stellar.argument.structure.StructureRotationArgument = + addArgument { com.undefined.stellar.argument.structure.StructureRotationArgument(base, name) } fun addHeightMapArgument(name: String): HeightMapArgument = addArgument { HeightMapArgument(base, name) } @@ -298,8 +305,8 @@ open class ArgumentHandler { fun addGameEventArgument(name: String): GameEventArgument = addArgument { GameEventArgument(base, name) } - fun addStructureTypeArgument(name: String): StructureTypeArgument = - addArgument { StructureTypeArgument(base, name) } + fun addStructureTypeArgument(name: String): com.undefined.stellar.argument.registry.StructureTypeArgument = + addArgument { com.undefined.stellar.argument.registry.StructureTypeArgument(base, name) } fun addPotionEffectTypeArgument(name: String): PotionEffectTypeArgument = addArgument { PotionEffectTypeArgument(base, name) } @@ -313,23 +320,23 @@ open class ArgumentHandler { fun addCatTypeArgument(name: String): CatTypeArgument = addArgument { CatTypeArgument(base, name) } - fun addFrogVariantArgument(name: String): FrogVariantArgument = - addArgument { FrogVariantArgument(base, name) } + fun addFrogVariantArgument(name: String): com.undefined.stellar.argument.registry.FrogVariantArgument = + addArgument { com.undefined.stellar.argument.registry.FrogVariantArgument(base, name) } fun addVillagerProfessionArgument(name: String): VillagerProfessionArgument = addArgument { VillagerProfessionArgument(base, name) } - fun addVillagerTypeArgument(name: String): VillagerTypeArgument = - addArgument { VillagerTypeArgument(base, name) } + fun addVillagerTypeArgument(name: String): com.undefined.stellar.argument.registry.VillagerTypeArgument = + addArgument { com.undefined.stellar.argument.registry.VillagerTypeArgument(base, name) } - fun addMapDecorationType(name: String): MapDecorationTypeArgument = - addArgument { MapDecorationTypeArgument(base, name) } + fun addMapDecorationType(name: String): com.undefined.stellar.argument.registry.MapDecorationTypeArgument = + addArgument { com.undefined.stellar.argument.registry.MapDecorationTypeArgument(base, name) } fun addInventoryTypeArgument(name: String): InventoryTypeArgument = addArgument { InventoryTypeArgument(base, name) } - fun addAttributeArgument(name: String): AttributeArgument = - addArgument { AttributeArgument(base, name) } + fun addAttributeArgument(name: String): com.undefined.stellar.argument.registry.AttributeArgument = + addArgument { com.undefined.stellar.argument.registry.AttributeArgument(base, name) } fun addFluidArgument(name: String): FluidArgument = addArgument { FluidArgument(base, name) } @@ -337,8 +344,8 @@ open class ArgumentHandler { fun addSoundArgument(name: String): SoundArgument = addArgument { SoundArgument(base, name) } - fun addBiomeArgument(name: String): BiomeArgument = - addArgument { BiomeArgument(base, name) } + fun addBiomeArgument(name: String): com.undefined.stellar.argument.registry.BiomeArgument = + addArgument { com.undefined.stellar.argument.registry.BiomeArgument(base, name) } fun addStructureArgument(name: String): StructureArgument = addArgument { StructureArgument(base, name) } @@ -358,8 +365,8 @@ open class ArgumentHandler { fun addPatternTypeArgument(name: String): PatternTypeArgument = addArgument { PatternTypeArgument(base, name) } - fun addArtArgument(name: String): ArtArgument = - addArgument { ArtArgument(base, name) } + fun addArtArgument(name: String): com.undefined.stellar.argument.registry.ArtArgument = + addArgument { com.undefined.stellar.argument.registry.ArtArgument(base, name) } fun addInstrumentArgument(name: String): InstrumentArgument = addArgument { InstrumentArgument(base, name) } @@ -370,7 +377,7 @@ open class ArgumentHandler { fun addPotionArgument(name: String): PotionArgument = addArgument { PotionArgument(base, name) } - fun addMemoryKeyArgument(name: String): MemoryKeyArgument = - addArgument { MemoryKeyArgument(base, name) } + fun addMemoryKeyArgument(name: String): com.undefined.stellar.argument.registry.MemoryKeyArgument = + addArgument { com.undefined.stellar.argument.registry.MemoryKeyArgument(base, name) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockDataArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/block/BlockDataArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockDataArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/block/BlockDataArgument.kt index e505e11..d7872d0 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockDataArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/block/BlockDataArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.block +package com.undefined.stellar.argument.block import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockPredicateArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/block/BlockPredicateArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockPredicateArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/block/BlockPredicateArgument.kt index ac3ca7e..4fc8dc6 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/block/BlockPredicateArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/block/BlockPredicateArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.block +package com.undefined.stellar.argument.block import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/custom/CustomArgument.kt similarity index 97% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/custom/CustomArgument.kt index 0631345..a59c49d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/custom/CustomArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.custom +package com.undefined.stellar.argument.custom import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument @@ -45,4 +45,5 @@ abstract class CustomArgument( open fun failureExecution(info: CommandContext, value: T) {} open fun requirement(): Boolean = true abstract fun listSuggestions(context: CommandContext): CompletableFuture> + } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/EnumArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/custom/EnumArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/custom/EnumArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/custom/EnumArgument.kt index ad46d70..a78ef3f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/EnumArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/custom/EnumArgument.kt @@ -1,8 +1,8 @@ -package com.undefined.stellar.argument.types.custom +package com.undefined.stellar.argument.custom import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.argument.types.primitive.StringArgument -import com.undefined.stellar.argument.types.primitive.StringType +import com.undefined.stellar.argument.primitive.StringArgument +import com.undefined.stellar.argument.primitive.StringType import com.undefined.stellar.data.suggestion.Suggestion import java.lang.Enum.valueOf import kotlin.reflect.KClass diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/ListArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/custom/ListArgument.kt similarity index 96% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/custom/ListArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/custom/ListArgument.kt index 4a0b7bf..5d57746 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/ListArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/custom/ListArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.custom +package com.undefined.stellar.argument.custom import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.data.argument.CommandContext diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityAnchorArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityAnchorArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityAnchorArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityAnchorArgument.kt index 964b768..5a9e2fd 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityAnchorArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityAnchorArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.entity +package com.undefined.stellar.argument.entity import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityArgument.kt similarity index 55% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityArgument.kt index 0208e7d..593836b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/entity/EntityArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/entity/EntityArgument.kt @@ -1,9 +1,9 @@ -package com.undefined.stellar.argument.types.entity +package com.undefined.stellar.argument.entity import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class EntityArgument(parent: AbstractStellarCommand<*>, name: String, val type: EntityDisplayType) : AbstractStellarArgument(parent, name) +class EntityArgument(parent: AbstractStellarCommand<*>, name: String, val type: com.undefined.stellar.argument.entity.EntityDisplayType) : AbstractStellarArgument(parent, name) enum class EntityDisplayType { ENTITY, diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemArgument.kt similarity index 56% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/item/ItemArgument.kt index 5a759ce..ac1d02d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.item +package com.undefined.stellar.argument.item import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ItemArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class ItemArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemPredicateArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemPredicateArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemPredicateArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/item/ItemPredicateArgument.kt index 1885380..3a5d73e 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemPredicateArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemPredicateArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.item +package com.undefined.stellar.argument.item import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotArgument.kt index 52c7643..017f5bc 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.item +package com.undefined.stellar.argument.item import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotsArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotsArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotsArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotsArgument.kt index 8882f81..31bc9e0 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/item/ItemSlotsArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/item/ItemSlotsArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.item +package com.undefined.stellar.argument.item import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/AngleArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/AngleArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/AngleArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/AngleArgument.kt index eab9166..627e83f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/AngleArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/AngleArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/AxisArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/AxisArgument.kt similarity index 56% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/AxisArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/AxisArgument.kt index e999df3..d43a9c9 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/AxisArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/AxisArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class AxisArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class AxisArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/OperationArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/OperationArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/OperationArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/OperationArgument.kt index b5206ce..80eb8f9 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/OperationArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/OperationArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/RangeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/RangeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/RangeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/RangeArgument.kt index 42ec9af..72680bb 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/RangeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/RangeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/RotationArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/RotationArgument.kt similarity index 55% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/RotationArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/RotationArgument.kt index 8b49a76..6c48908 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/RotationArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/RotationArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class RotationArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class RotationArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/TimeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/math/TimeArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/math/TimeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/math/TimeArgument.kt index 9547cd2..3bd2dcd 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/math/TimeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/math/TimeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.math +package com.undefined.stellar.argument.math import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/misc/NamespacedKeyArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/misc/NamespacedKeyArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/misc/NamespacedKeyArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/misc/NamespacedKeyArgument.kt index 8044d4f..551c775 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/misc/NamespacedKeyArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/misc/NamespacedKeyArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.misc +package com.undefined.stellar.argument.misc import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/misc/UUIDArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/misc/UUIDArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/misc/UUIDArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/misc/UUIDArgument.kt index f77bd03..ccfb29f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/misc/UUIDArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/misc/UUIDArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.misc +package com.undefined.stellar.argument.misc import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameModeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/player/GameModeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameModeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/player/GameModeArgument.kt index a4045c3..dc73dec 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameModeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/player/GameModeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.player +package com.undefined.stellar.argument.player import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameProfileArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/player/GameProfileArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameProfileArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/player/GameProfileArgument.kt index 3065055..b290fae 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/player/GameProfileArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/player/GameProfileArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.player +package com.undefined.stellar.argument.player import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/BooleanArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/BooleanArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/BooleanArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/BooleanArgument.kt index 3049614..647d708 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/BooleanArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/BooleanArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/DoubleArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/DoubleArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/DoubleArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/DoubleArgument.kt index 5b9946a..ede69cf 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/DoubleArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/DoubleArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/primitive/FloatArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/FloatArgument.kt new file mode 100644 index 0000000..7d7ae2a --- /dev/null +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/FloatArgument.kt @@ -0,0 +1,6 @@ +package com.undefined.stellar.argument.primitive + +import com.undefined.stellar.AbstractStellarCommand +import com.undefined.stellar.argument.AbstractStellarArgument + +class FloatArgument(parent: AbstractStellarCommand<*>, name: String, val min: Float, val max: Float) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/IntegerArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/IntegerArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/IntegerArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/IntegerArgument.kt index 3d91776..8339c4d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/IntegerArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/IntegerArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/LongArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/LongArgument.kt similarity index 50% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/LongArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/LongArgument.kt index 4045208..22604c4 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/LongArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/LongArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class LongArgument(parent: AbstractStellarCommand<*>, name: String, val min: Long, val max: Long) : AbstractStellarArgument(parent, name) \ No newline at end of file +class LongArgument(parent: AbstractStellarCommand<*>, name: String, val min: Long, val max: Long) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/PhraseArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/PhraseArgument.kt similarity index 97% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/PhraseArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/PhraseArgument.kt index 853332e..5acd978 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/PhraseArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/PhraseArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/StringArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/StringArgument.kt similarity index 90% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/StringArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/StringArgument.kt index 09d8903..2a6ceb1 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/StringArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/StringArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/WordArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/WordArgument.kt similarity index 98% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/WordArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/primitive/WordArgument.kt index b2fae9c..1d24ec7 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/WordArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/primitive/WordArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.primitive +package com.undefined.stellar.argument.primitive import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.data.execution.PhraseStellarExecution diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ArtArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/ArtArgument.kt similarity index 55% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ArtArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/ArtArgument.kt index a177568..da3732f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ArtArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/ArtArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ArtArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class ArtArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/AttributeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/AttributeArgument.kt similarity index 53% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/AttributeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/AttributeArgument.kt index 8f68b40..6d39cfd 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/AttributeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/AttributeArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class AttributeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class AttributeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BiomeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/BiomeArgument.kt similarity index 55% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BiomeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/BiomeArgument.kt index 3239cd1..0e691f2 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BiomeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/BiomeArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class BiomeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class BiomeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BlockTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/BlockTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BlockTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/BlockTypeArgument.kt index 065646e..967cef0 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/BlockTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/BlockTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/CatTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/CatTypeArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/CatTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/CatTypeArgument.kt index 969d35f..1dc7be9 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/CatTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/CatTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/DamageTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/DamageTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/DamageTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/DamageTypeArgument.kt index a1d7fe6..a0313a6 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/DamageTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/DamageTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/EntityTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/EntityTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/EntityTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/EntityTypeArgument.kt index dc2fbf7..b0121f2 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/EntityTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/EntityTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FluidArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/FluidArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FluidArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/FluidArgument.kt index 1bb5708..10b0857 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FluidArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/FluidArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FrogVariantArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/FrogVariantArgument.kt similarity index 53% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FrogVariantArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/FrogVariantArgument.kt index 7f42fe4..da043a2 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/FrogVariantArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/FrogVariantArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class FrogVariantArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class FrogVariantArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/GameEventArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/GameEventArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/GameEventArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/GameEventArgument.kt index 51e6bd1..146b976 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/GameEventArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/GameEventArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InstrumentArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/InstrumentArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InstrumentArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/InstrumentArgument.kt index 2739e98..e380039 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InstrumentArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/InstrumentArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InventoryTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/InventoryTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InventoryTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/InventoryTypeArgument.kt index e1c731f..07537df 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/InventoryTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/InventoryTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ItemTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/ItemTypeArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ItemTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/ItemTypeArgument.kt index f140b3b..0940f6b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/ItemTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/ItemTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MapDecorationTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/MapDecorationTypeArgument.kt similarity index 67% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MapDecorationTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/MapDecorationTypeArgument.kt index 98e25cc..e83832a 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MapDecorationTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/MapDecorationTypeArgument.kt @@ -1,7 +1,7 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -import com.undefined.stellar.argument.types.world.LocationArgument +import com.undefined.stellar.argument.world.LocationArgument class MapDecorationTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MemoryKeyArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/MemoryKeyArgument.kt similarity index 53% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MemoryKeyArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/MemoryKeyArgument.kt index bac6343..800a8c0 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/MemoryKeyArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/MemoryKeyArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class MemoryKeyArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class MemoryKeyArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PatternTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PatternTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PatternTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/PatternTypeArgument.kt index f6ef0b5..407d4aa 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PatternTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PatternTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionArgument.kt index f835916..9d6a9af 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionEffectTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionEffectTypeArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionEffectTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionEffectTypeArgument.kt index a66b3d9..baeff55 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/PotionEffectTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/PotionEffectTypeArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/SoundArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/SoundArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/SoundArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/SoundArgument.kt index 240d12d..f64676e 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/SoundArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/SoundArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureArgument.kt index 865c527..020e738 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureTypeArgument.kt similarity index 52% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureTypeArgument.kt index bbf578c..2941a17 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/StructureTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/StructureTypeArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class StructureTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class StructureTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimMaterialArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimMaterialArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimMaterialArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimMaterialArgument.kt index 194115b..c254bcf 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimMaterialArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimMaterialArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimPatternArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimPatternArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimPatternArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimPatternArgument.kt index 88e3295..bfa173b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/TrimPatternArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/TrimPatternArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerProfessionArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerProfessionArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerProfessionArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerProfessionArgument.kt index fcbb5a8..087bbdd 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerProfessionArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerProfessionArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerTypeArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerTypeArgument.kt similarity index 52% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerTypeArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerTypeArgument.kt index 9b6126d..c0e49c7 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/VillagerTypeArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/VillagerTypeArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class VillagerTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class VillagerTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/WolfVariantArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/registry/WolfVariantArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/registry/WolfVariantArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/registry/WolfVariantArgument.kt index 9bf3eb1..0d50fe8 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/registry/WolfVariantArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/registry/WolfVariantArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.registry +package com.undefined.stellar.argument.registry import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/DisplaySlotArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/DisplaySlotArgument.kt similarity index 52% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/DisplaySlotArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/DisplaySlotArgument.kt index b371150..939788d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/DisplaySlotArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/DisplaySlotArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.scoreboard +package com.undefined.stellar.argument.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class DisplaySlotArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class DisplaySlotArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveArgument.kt similarity index 53% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveArgument.kt index f95121f..ccb9e6f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.scoreboard +package com.undefined.stellar.argument.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ObjectiveArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class ObjectiveArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveCriteriaArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveCriteriaArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveCriteriaArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveCriteriaArgument.kt index 98fd6bd..d7baf1d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ObjectiveCriteriaArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ObjectiveCriteriaArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.scoreboard +package com.undefined.stellar.argument.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ScoreHolderArgument.kt similarity index 50% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ScoreHolderArgument.kt index dce6b01..95a7005 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/ScoreHolderArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/ScoreHolderArgument.kt @@ -1,9 +1,9 @@ -package com.undefined.stellar.argument.types.scoreboard +package com.undefined.stellar.argument.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ScoreHolderArgument(parent: AbstractStellarCommand<*>, name: String, val type: ScoreHolderType) : AbstractStellarArgument(parent, name) +class ScoreHolderArgument(parent: AbstractStellarCommand<*>, name: String, val type: com.undefined.stellar.argument.scoreboard.ScoreHolderType) : AbstractStellarArgument(parent, name) enum class ScoreHolderType { SINGLE, diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/TeamArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/TeamArgument.kt similarity index 54% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/TeamArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/TeamArgument.kt index 778d375..74960a0 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/scoreboard/TeamArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/scoreboard/TeamArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.scoreboard +package com.undefined.stellar.argument.scoreboard import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class TeamArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class TeamArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/LootTableArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/structure/LootTableArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/structure/LootTableArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/structure/LootTableArgument.kt index 709807a..a26442a 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/LootTableArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/structure/LootTableArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.structure +package com.undefined.stellar.argument.structure import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/MirrorArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/structure/MirrorArgument.kt similarity index 81% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/structure/MirrorArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/structure/MirrorArgument.kt index 22e4325..2781713 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/MirrorArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/structure/MirrorArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.structure +package com.undefined.stellar.argument.structure import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/StructureRotationArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/structure/StructureRotationArgument.kt similarity index 50% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/structure/StructureRotationArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/structure/StructureRotationArgument.kt index 33d3fda..c574e30 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/structure/StructureRotationArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/structure/StructureRotationArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.structure +package com.undefined.stellar.argument.structure import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class StructureRotationArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class StructureRotationArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/ColorArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/text/ColorArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/text/ColorArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/text/ColorArgument.kt index a89c193..9a23278 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/ColorArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/text/ColorArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.text +package com.undefined.stellar.argument.text import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/ComponentArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/text/ComponentArgument.kt similarity index 83% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/text/ComponentArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/text/ComponentArgument.kt index 67a89e1..54b5a05 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/ComponentArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/text/ComponentArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.text +package com.undefined.stellar.argument.text import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/MessageArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/text/MessageArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/text/MessageArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/text/MessageArgument.kt index 61f825a..05fee91 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/MessageArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/text/MessageArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.text +package com.undefined.stellar.argument.text import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/StyleArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/text/StyleArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/text/StyleArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/text/StyleArgument.kt index de67ee8..5b6de20 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/text/StyleArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/text/StyleArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.text +package com.undefined.stellar.argument.text import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/FloatArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/FloatArgument.kt deleted file mode 100644 index 9505a9e..0000000 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/FloatArgument.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.undefined.stellar.argument.types.primitive - -import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.argument.AbstractStellarArgument - -class FloatArgument(parent: AbstractStellarCommand<*>, name: String, val min: Float, val max: Float) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/DimensionArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/world/DimensionArgument.kt similarity index 54% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/world/DimensionArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/world/DimensionArgument.kt index 2dda1b1..934544b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/DimensionArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/world/DimensionArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.world +package com.undefined.stellar.argument.world import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class DimensionArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class DimensionArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/HeightMapArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/world/HeightMapArgument.kt similarity index 82% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/world/HeightMapArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/world/HeightMapArgument.kt index 2fdb8ee..a3d3f68 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/HeightMapArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/world/HeightMapArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.world +package com.undefined.stellar.argument.world import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/world/LocationArgument.kt similarity index 88% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/world/LocationArgument.kt index 1554177..55fa10e 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/LocationArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/world/LocationArgument.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.argument.types.world +package com.undefined.stellar.argument.world import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/ParticleArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/world/ParticleArgument.kt similarity index 55% rename from common/src/main/kotlin/com/undefined/stellar/argument/types/world/ParticleArgument.kt rename to common/src/main/kotlin/com/undefined/stellar/argument/world/ParticleArgument.kt index 5a9920a..5db681d 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/world/ParticleArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/world/ParticleArgument.kt @@ -1,6 +1,6 @@ -package com.undefined.stellar.argument.types.world +package com.undefined.stellar.argument.world import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument -class ParticleArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file +class ParticleArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument(parent, name) \ No newline at end of file diff --git a/paper/api/build.gradle.kts b/paper/api/build.gradle.kts index f7250ba..ceba6c2 100644 --- a/paper/api/build.gradle.kts +++ b/paper/api/build.gradle.kts @@ -39,8 +39,8 @@ publishing { dependencies { compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT") - implementation(project(":paper:common")) - implementation(project(":paper:v1_17_1")) + api(project(":paper:common")) + implementation(project(":paper:v1_21_4")) implementation(kotlin("reflect")) } diff --git a/paper/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt b/paper/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt index 1275adc..63f1d92 100644 --- a/paper/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt +++ b/paper/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt @@ -10,7 +10,7 @@ import kotlin.reflect.KClass @ApiStatus.Internal object CommandManager { val registrars: Map> = mapOf( - "1.17.1" to com.undefined.stellar.v1_17_1.CommandRegistrar::class, + "1.21.4" to com.undefined.stellar.v1_21_4.CommandRegistrar::class, ) private val initializedPlugins: MutableList = mutableListOf() diff --git a/paper/common/src/main/kotlin/com/undefined/stellar/arguments/custom/CustomArgument.kt b/paper/common/src/main/kotlin/com/undefined/stellar/arguments/custom/CustomArgument.kt new file mode 100644 index 0000000..aec70e8 --- /dev/null +++ b/paper/common/src/main/kotlin/com/undefined/stellar/arguments/custom/CustomArgument.kt @@ -0,0 +1,48 @@ +package com.undefined.stellar.arguments.custom + +import com.undefined.stellar.AbstractStellarCommand +import com.undefined.stellar.argument.AbstractStellarArgument +import com.undefined.stellar.data.argument.CommandContext +import com.undefined.stellar.data.execution.StellarExecution +import com.undefined.stellar.data.execution.StellarRunnable +import com.undefined.stellar.data.requirement.StellarRequirement +import com.undefined.stellar.data.suggestion.StellarSuggestion +import com.undefined.stellar.data.suggestion.Suggestion +import org.bukkit.command.CommandSender +import java.util.concurrent.CompletableFuture + +abstract class CustomArgument( + parent: AbstractStellarCommand<*>, + name: String +) : AbstractStellarArgument(parent, name) { + + override val arguments: MutableList> + get() = (super.arguments + getArgumentsList()).toMutableList() + override val failureExecutions: MutableList> + get() = (super.failureExecutions + StellarExecution(CommandSender::class) { + failureExecution(this, arguments.values.last()) + }).toMutableList() + override val requirements: MutableList> + get() = (super.requirements + StellarRequirement(CommandSender::class) { requirement() }).toMutableList() + override val executions: MutableList> + get() = (super.executions + StellarExecution(CommandSender::class) { + execution(this, this.arguments.values.last()) + }).toMutableList() + override val runnables: MutableList> + get() = (super.runnables + StellarRunnable(CommandSender::class) { + runnable(this, this[name]) + }).toMutableList() + override val suggestions: MutableList> + get() = (super.suggestions + StellarSuggestion(CommandSender::class) { + listSuggestions(this) + }).toMutableList() + + open fun getArgumentsList(): List> = listOf() + abstract fun parse(context: CommandContext): T + open fun execution(info: CommandContext, value: T) {} + open fun runnable(info: CommandContext, value: T): Boolean = true + open fun failureExecution(info: CommandContext, value: T) {} + open fun requirement(): Boolean = true + abstract fun listSuggestions(context: CommandContext): CompletableFuture> + +} \ No newline at end of file diff --git a/paper/v1_17_1/build.gradle.kts b/paper/v1_21_4/build.gradle.kts similarity index 78% rename from paper/v1_17_1/build.gradle.kts rename to paper/v1_21_4/build.gradle.kts index 4c7de5d..cfc8d21 100644 --- a/paper/v1_17_1/build.gradle.kts +++ b/paper/v1_21_4/build.gradle.kts @@ -6,8 +6,8 @@ plugins { paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION dependencies { - paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT") - compileOnly(project(":common")) + paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") + compileOnly(project(":paper:common")) } tasks { @@ -18,7 +18,7 @@ tasks { options.release = 8 } paperweight { - javaLauncher = project.javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(17)) } + javaLauncher = project.javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(21)) } } } diff --git a/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentAdapter.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentAdapter.kt new file mode 100644 index 0000000..55bc9cd --- /dev/null +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentAdapter.kt @@ -0,0 +1,258 @@ +@file:Suppress("UnstableApiUsage") + +package com.undefined.stellar.v1_21_4 + +import com.mojang.brigadier.arguments.* +import com.mojang.brigadier.builder.ArgumentBuilder +import com.mojang.brigadier.builder.LiteralArgumentBuilder +import com.mojang.brigadier.builder.RequiredArgumentBuilder +import com.mojang.brigadier.context.CommandContext +import com.undefined.stellar.argument.AbstractStellarArgument +import com.undefined.stellar.argument.LiteralStellarArgument +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.math.AxisArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.scoreboard.DisplaySlotArgument +import com.undefined.stellar.argument.scoreboard.ScoreHolderType +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType +import com.undefined.stellar.data.argument.Anchor +import com.undefined.stellar.data.argument.Operation +import com.undefined.stellar.exception.LiteralArgumentMismatchException +import com.undefined.stellar.exception.UnsupportedArgumentException +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer +import net.minecraft.commands.CommandBuildContext +import net.minecraft.commands.CommandSourceStack +import net.minecraft.commands.arguments.* +import net.minecraft.commands.arguments.ResourceOrIdArgument.LootTableArgument +import net.minecraft.commands.arguments.blocks.BlockPredicateArgument +import net.minecraft.commands.arguments.blocks.BlockStateArgument +import net.minecraft.commands.arguments.coordinates.* +import net.minecraft.commands.arguments.item.ItemArgument +import net.minecraft.commands.arguments.item.ItemPredicateArgument +import net.minecraft.core.BlockPos +import net.minecraft.core.registries.Registries +import net.minecraft.network.chat.Component +import net.minecraft.server.MinecraftServer +import net.minecraft.world.level.block.state.pattern.BlockInWorld +import org.bukkit.* +import org.bukkit.block.Block +import org.bukkit.block.structure.Mirror +import org.bukkit.block.structure.StructureRotation +import org.bukkit.craftbukkit.CraftParticle +import org.bukkit.craftbukkit.block.data.CraftBlockData +import org.bukkit.craftbukkit.inventory.CraftItemStack +import org.bukkit.inventory.ItemStack +import java.util.function.Predicate + +@Suppress("DEPRECATION") +object ArgumentAdapter { + + private val COMMAND_BUILD_CONTEXT: CommandBuildContext by lazy { + CommandBuildContext.simple( + MinecraftServer.getServer().registryAccess(), + MinecraftServer.getServer().worldData.dataConfiguration.enabledFeatures() + ) + } + + fun getLiteralArguments(argument: AbstractStellarArgument<*>): List> { + val arguments: MutableList> = mutableListOf() + for (name in argument.aliases + argument.name) + arguments.add(LiteralArgumentBuilder.literal(name)) + return arguments + } + + fun getRequiredArgumentBuilder(argument: AbstractStellarArgument<*>): RequiredArgumentBuilder = + RequiredArgumentBuilder.argument(argument.name, getArgumentType(argument)) + + private fun > getArgumentType(argument: T): ArgumentType<*> = + when (argument) { + is ListArgument<*> -> getArgumentType(argument.type) + is CustomArgument<*> -> getArgumentType(argument.type) + is StringArgument -> ArgumentHelper.brigadier(argument.type) + is PhraseArgument -> ArgumentHelper.brigadier(StringType.PHRASE) + is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) + is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) + is BooleanArgument -> BoolArgumentType.bool() + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentHelper.brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is LocationArgument -> when (argument.type) { + 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.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + } + is AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() + is ItemSlotArgument -> SlotArgument.slot() + is ItemSlotsArgument -> SlotsArgument.slots() + is NamespacedKeyArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) + is MirrorArgument -> TemplateMirrorArgument.templateMirror() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is HeightMapArgument -> HeightmapTypeArgument.heightmap() + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) + is UUIDArgument -> UuidArgument.uuid() + is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) + is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) + is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) + is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) + is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) + is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) + is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) + is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) + is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) + is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) + is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) + is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) + is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) + is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) + is WolfVariantArgument -> ResourceKeyArgument.key(Registries.WOLF_VARIANT) + is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) + is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) + is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) + is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) + is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + else -> throw UnsupportedArgumentException(argument) + } + + fun > getParsedArgument(context: CommandContext, argument: T): Any? { + return when (argument) { + is LiteralStellarArgument -> throw LiteralArgumentMismatchException() + is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) + is StringArgument -> StringArgumentType.getString(context, argument.name) + is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) + is LongArgument -> LongArgumentType.getLong(context, argument.name) + is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) + is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) + is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + .map { it.bukkitEntity }.toMutableList() + .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is LocationArgument -> ArgumentHelper.getLocation(context, argument) + is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> + BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( + context.source.level, + BlockPos(block.x, block.y, block.z), true + )) + } + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) + } + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + ArgumentHelper.getArgumentInput(context, argument.name) ?: return null).style() + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager().mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(ArgumentHelper.getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { + val particleOptions = ParticleArgument.getParticle(context, argument.name) + ArgumentHelper.getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) + } + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { + val coordinates = RotationArgument.getRotation(context, argument.name) + val position = coordinates.getPosition(context.source) + val rotation = coordinates.getRotation(context.source) + Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) + } + is DisplaySlotArgument -> ArgumentHelper.getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + ScoreHolderType.MULTIPLE -> ScoreHolderArgument.getNames(context, argument.name).map { it.scoreboardName } + } + is AxisArgument -> ArgumentHelper.getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager().mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) + is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) + is ItemSlotsArgument -> SlotsArgument.getSlots(context, argument.name).slots().toList() + is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(ArgumentHelper.getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { + val range = RangeArgument.Ints.getRange(context, argument.name) + IntRange(range.min.orElse(1), range.max.orElse(2)) + } + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable + is UUIDArgument -> UuidArgument.getUuid(context, argument.name) + is GameEventArgument -> Registry.GAME_EVENT.get(ArgumentHelper.getId(context, argument.name, Registries.GAME_EVENT)) + is StructureTypeArgument -> Registry.STRUCTURE_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is PotionEffectTypeArgument -> Registry.EFFECT.get(ArgumentHelper.getId(context, argument.name, Registries.MOB_EFFECT)) + is BlockTypeArgument -> Registry.BLOCK.get(ArgumentHelper.getId(context, argument.name, Registries.BLOCK_TYPE)) + is ItemTypeArgument -> Registry.ITEM.get(ArgumentHelper.getId(context, argument.name, Registries.ITEM)) + is CatTypeArgument -> Registry.CAT_VARIANT.get(ArgumentHelper.getId(context, argument.name, Registries.CAT_VARIANT)) + is FrogVariantArgument -> Registry.FROG_VARIANT.get(ArgumentHelper.getId(context, argument.name, Registries.FROG_VARIANT)) + is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(ArgumentHelper.getId(context, argument.name, Registries.VILLAGER_PROFESSION)) + is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.VILLAGER_TYPE)) + is MapDecorationTypeArgument -> Registry.MAP_DECORATION_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) + is InventoryTypeArgument -> ArgumentHelper.getInventoryType(ArgumentHelper.resolveKey(context, argument.name, Registries.MENU).value()) + is AttributeArgument -> Registry.ATTRIBUTE.get(ArgumentHelper.getId(context, argument.name, Registries.ATTRIBUTE)) + is FluidArgument -> Registry.FLUID.get(ArgumentHelper.getId(context, argument.name, Registries.FLUID)) + is SoundArgument -> Registry.SOUNDS.get(ArgumentHelper.getId(context, argument.name, Registries.SOUND_EVENT)) + is BiomeArgument -> Registry.BIOME.get(ArgumentHelper.getId(context, argument.name, Registries.BIOME)) + is StructureArgument -> Registry.STRUCTURE.get(ArgumentHelper.getId(context, argument.name, Registries.STRUCTURE)) + is TrimMaterialArgument -> Registry.TRIM_MATERIAL.get(ArgumentHelper.getId(context, argument.name, Registries.TRIM_MATERIAL)) + is TrimPatternArgument -> Registry.TRIM_PATTERN.get(ArgumentHelper.getId(context, argument.name, Registries.TRIM_PATTERN)) + is DamageTypeArgument -> Registry.DAMAGE_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.DAMAGE_TYPE)) + is WolfVariantArgument -> Registry.WOLF_VARIANT.get(ArgumentHelper.getId(context, argument.name, Registries.WOLF_VARIANT)) + is PatternTypeArgument -> Registry.BANNER_PATTERN.get(ArgumentHelper.getId(context, argument.name, Registries.BANNER_PATTERN)) + is ArtArgument -> Registry.ART.get(ArgumentHelper.getId(context, argument.name, Registries.PAINTING_VARIANT)) + is InstrumentArgument -> Registry.INSTRUMENT.get(ArgumentHelper.getId(context, argument.name, Registries.INSTRUMENT)) + is EntityTypeArgument -> Registry.ENTITY_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.ENTITY_TYPE)) + is PotionArgument -> Registry.POTION.get(ArgumentHelper.getId(context, argument.name, Registries.POTION)) + is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(ArgumentHelper.getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) + else -> throw UnsupportedArgumentException(argument) + } + } + +} \ No newline at end of file diff --git a/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt new file mode 100644 index 0000000..aa6a9cd --- /dev/null +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt @@ -0,0 +1,239 @@ +package com.undefined.stellar.v1_21_4 + +import com.mojang.brigadier.arguments.StringArgumentType +import com.mojang.brigadier.context.CommandContext +import com.mojang.brigadier.context.ParsedArgument +import com.mojang.brigadier.context.StringRange +import com.mojang.brigadier.exceptions.CommandSyntaxException +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType +import com.undefined.stellar.argument.entity.EntityDisplayType +import com.undefined.stellar.argument.primitive.StringType +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType +import com.undefined.stellar.data.argument.ParticleData +import net.minecraft.commands.CommandSourceStack +import net.minecraft.commands.arguments.EntityArgument +import net.minecraft.commands.arguments.coordinates.BlockPosArgument +import net.minecraft.commands.arguments.coordinates.ColumnPosArgument +import net.minecraft.commands.arguments.coordinates.Vec2Argument +import net.minecraft.commands.arguments.coordinates.Vec3Argument +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.core.Holder +import net.minecraft.core.Registry +import net.minecraft.core.particles.* +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceKey +import net.minecraft.server.level.ColumnPos +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.level.Level +import net.minecraft.world.level.gameevent.BlockPositionSource +import net.minecraft.world.phys.Vec2 +import net.minecraft.world.phys.Vec3 +import org.bukkit.* +import org.bukkit.block.data.BlockData +import org.bukkit.craftbukkit.block.data.CraftBlockData +import org.bukkit.craftbukkit.inventory.CraftItemStack +import org.bukkit.event.inventory.InventoryType +import org.bukkit.inventory.ItemStack +import org.bukkit.scoreboard.DisplaySlot +import java.util.* + +object ArgumentHelper { + + @Suppress("UNCHECKED_CAST") + fun getArgumentInput(context: CommandContext, name: String): String? { + val field = CommandContext::class.java.getDeclaredField("arguments") + field.isAccessible = true + val arguments: Map> = field.get(context) as Map> + val argument = arguments[name] ?: return null + val range = StringRange.between(argument.range.start, context.input.length) + return range.get(context.input) + } + + fun getInventoryType(menu: MenuType<*>): InventoryType = when (menu) { + MenuType.GENERIC_9x1 -> InventoryType.CHEST + MenuType.GENERIC_9x2 -> InventoryType.CHEST + MenuType.GENERIC_9x3 -> InventoryType.CHEST + MenuType.GENERIC_9x4 -> InventoryType.CHEST + MenuType.GENERIC_9x5 -> InventoryType.CHEST + MenuType.GENERIC_9x6 -> InventoryType.CHEST + MenuType.GENERIC_3x3 -> InventoryType.WORKBENCH + MenuType.CRAFTER_3x3 -> InventoryType.CRAFTER + MenuType.ANVIL -> InventoryType.ANVIL + MenuType.BEACON -> InventoryType.BEACON + MenuType.BLAST_FURNACE -> InventoryType.BLAST_FURNACE + MenuType.BREWING_STAND -> InventoryType.BREWING + MenuType.CRAFTING -> InventoryType.CRAFTING + MenuType.ENCHANTMENT -> InventoryType.ENCHANTING + MenuType.FURNACE -> InventoryType.FURNACE + MenuType.GRINDSTONE -> InventoryType.GRINDSTONE + MenuType.HOPPER -> InventoryType.HOPPER + MenuType.LECTERN -> InventoryType.LECTERN + MenuType.LOOM -> InventoryType.LOOM + MenuType.MERCHANT -> InventoryType.MERCHANT + MenuType.SHULKER_BOX -> InventoryType.SHULKER_BOX + MenuType.SMITHING -> InventoryType.SMITHING + MenuType.SMOKER -> InventoryType.SMOKER + MenuType.CARTOGRAPHY_TABLE -> InventoryType.CARTOGRAPHY + MenuType.STONECUTTER -> InventoryType.STONECUTTER + else -> throw IllegalStateException("No inventory type found! This is not intentional behaviour, please contact the developers.") + } + + @Throws(CommandSyntaxException::class) + fun getRegistryKey( + context: CommandContext, + name: String, + registryRef: ResourceKey>, + invalidException: DynamicCommandExceptionType + ): ResourceKey { + val resourceKey = context.getArgument(name, ResourceKey::class.java) + val optional = resourceKey.cast(registryRef) + return optional.orElseThrow { + invalidException.create(resourceKey) + } + } + + fun getRegistry( + context: CommandContext, + registryRef: ResourceKey> + ): Registry { + return context.source.server.registryAccess().lookupOrThrow(registryRef) + } + + @Throws(CommandSyntaxException::class) + fun resolveKey( + context: CommandContext, + name: String, + registryRef: ResourceKey> + ): Holder.Reference { + val invalidException = DynamicCommandExceptionType { argument -> + Component.translatableEscape("argument.resource_or_id.invalid", argument) + } + val resourceKey = getRegistryKey(context, name, registryRef, invalidException) + return getRegistry(context, registryRef).get(resourceKey).orElseThrow { invalidException.create(resourceKey.location()) } + } + + @Throws(CommandSyntaxException::class) + fun getId( + context: CommandContext, + name: String, + registryRef: ResourceKey> + ): NamespacedKey { + val key = resolveKey(context, name, registryRef).key().location() + return NamespacedKey(key.namespace, key.path) + } + + fun brigadier(type: StringType): StringArgumentType = when (type) { + StringType.WORD -> StringArgumentType.word() + StringType.QUOTABLE_PHRASE -> StringArgumentType.string() + StringType.PHRASE -> StringArgumentType.greedyString() + } + + fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { + EntityDisplayType.ENTITY -> EntityArgument.entity() + EntityDisplayType.ENTITIES -> EntityArgument.entities() + EntityDisplayType.PLAYER -> EntityArgument.player() + EntityDisplayType.PLAYERS -> EntityArgument.players() + } + + fun getBukkitAxis(argument: EnumSet): EnumSet = + argument.mapTo(EnumSet.noneOf(Axis::class.java)) { + when (it) { + Direction.Axis.X -> Axis.X + Direction.Axis.Y -> Axis.Y + Direction.Axis.Z -> Axis.Z + null -> Axis.X + } + } + + fun getBukkitDisplaySlot(slot: net.minecraft.world.scores.DisplaySlot): DisplaySlot = when (slot) { + net.minecraft.world.scores.DisplaySlot.LIST -> DisplaySlot.PLAYER_LIST + net.minecraft.world.scores.DisplaySlot.SIDEBAR -> DisplaySlot.SIDEBAR + net.minecraft.world.scores.DisplaySlot.BELOW_NAME -> DisplaySlot.BELOW_NAME + net.minecraft.world.scores.DisplaySlot.TEAM_BLACK -> DisplaySlot.SIDEBAR_TEAM_BLACK + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_BLUE -> DisplaySlot.SIDEBAR_TEAM_DARK_BLUE + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_GREEN -> DisplaySlot.SIDEBAR_TEAM_GREEN + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_AQUA -> DisplaySlot.SIDEBAR_TEAM_DARK_AQUA + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_RED -> DisplaySlot.SIDEBAR_TEAM_DARK_RED + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_PURPLE -> DisplaySlot.SIDEBAR_TEAM_DARK_PURPLE + net.minecraft.world.scores.DisplaySlot.TEAM_GOLD -> DisplaySlot.SIDEBAR_TEAM_GOLD + net.minecraft.world.scores.DisplaySlot.TEAM_GRAY -> DisplaySlot.SIDEBAR_TEAM_GRAY + net.minecraft.world.scores.DisplaySlot.TEAM_DARK_GRAY -> DisplaySlot.SIDEBAR_TEAM_DARK_GRAY + net.minecraft.world.scores.DisplaySlot.TEAM_BLUE -> DisplaySlot.SIDEBAR_TEAM_BLUE + net.minecraft.world.scores.DisplaySlot.TEAM_GREEN -> DisplaySlot.SIDEBAR_TEAM_GREEN + net.minecraft.world.scores.DisplaySlot.TEAM_AQUA -> DisplaySlot.SIDEBAR_TEAM_AQUA + net.minecraft.world.scores.DisplaySlot.TEAM_RED -> DisplaySlot.SIDEBAR_TEAM_RED + net.minecraft.world.scores.DisplaySlot.TEAM_LIGHT_PURPLE -> DisplaySlot.SIDEBAR_TEAM_LIGHT_PURPLE + net.minecraft.world.scores.DisplaySlot.TEAM_YELLOW -> DisplaySlot.SIDEBAR_TEAM_YELLOW + net.minecraft.world.scores.DisplaySlot.TEAM_WHITE -> DisplaySlot.SIDEBAR_TEAM_WHITE + else -> DisplaySlot.SIDEBAR + } + + fun getParticleData(context: CommandContext, particle: Particle, options: ParticleOptions): ParticleData<*> = when (options) { + is SimpleParticleType -> ParticleData(particle, null) + is BlockParticleOption -> ParticleData(particle, CraftBlockData.fromData(options.state)) + is DustColorTransitionOptions -> { + val fromColor = Color.fromRGB( + (options.fromColor.x() * 255.0f).toInt(), + (options.fromColor.y() * 255.0f).toInt(), + (options.fromColor.z() * 255.0f).toInt() + ) + val toColor = Color.fromRGB( + (options.toColor.x() * 255.0f).toInt(), + (options.toColor.y() * 255.0f).toInt(), + (options.toColor.z() * 255.0f).toInt() + ) + ParticleData(particle, Particle.DustTransition(fromColor, toColor, options.scale)) + } + is DustParticleOptions -> ParticleData( + particle, + Particle.DustOptions( + Color.fromRGB( + (options.color.x() * 255.0f).toInt(), + (options.color.y() * 255.0f).toInt(), (options.color.z() * 255.0f).toInt() + ), options.scale) + ) + is ItemParticleOption -> ParticleData( + particle, + CraftItemStack.asBukkitCopy(options.item) + ) + is VibrationParticleOption -> { + val level: Level = context.source.level + val destination: Vibration.Destination + + if (options.destination is BlockPositionSource) { + val to: Vec3 = options.destination.getPosition(level).get() + destination = Vibration.Destination.BlockDestination(Location(level.world, to.x(), to.y(), to.z())) + ParticleData(particle, Vibration(destination, options.arrivalInTicks)) + } else { + ParticleData(particle, null) + } + } + is ShriekParticleOption -> ParticleData(particle, options.delay) + is SculkChargeParticleOptions -> ParticleData(particle, options.roll()) + is ColorParticleOption -> { + val color = Color.fromARGB( + (options.alpha * 255.0f).toInt(), + (options.red * 255.0f).toInt(), + (options.green * 255.0f).toInt(), + (options.blue * 255.0f).toInt()) + ParticleData(particle, color) + } + else -> ParticleData(particle, null) + } + + fun getLocation(context: CommandContext, command: LocationArgument): Location = + when (command.type) { + LocationType.LOCATION_3D -> blockPosToLocation(BlockPosArgument.getBlockPos(context, command.name), context.source.level.world) + LocationType.LOCATION_2D -> columnPosToLocation(ColumnPosArgument.getColumnPos(context, command.name), context.source.level.world) + LocationType.PRECISE_LOCATION_3D -> vec3ToLocation(Vec3Argument.getVec3(context, command.name), context.source.level.world) + LocationType.PRECISE_LOCATION_2D -> vec2ToLocation(Vec2Argument.getVec2(context, command.name), context.source.level.world) + } + + fun blockPosToLocation(block: BlockPos, world: World) = Location(world, block.x.toDouble(), block.y.toDouble(), block.z.toDouble()) + fun columnPosToLocation(column: ColumnPos, world: World) = Location(world, column.x.toDouble(), 0.0, column.z.toDouble()) + fun vec3ToLocation(vec: Vec3, world: World) = Location(world, vec.x, vec.y, vec.z) + fun vec2ToLocation(vec: Vec2, world: World) = Location(world, vec.x.toDouble(), 0.0, vec.y.toDouble()) + +} \ No newline at end of file diff --git a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/BrigadierCommandHelper.kt similarity index 93% rename from paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt rename to paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/BrigadierCommandHelper.kt index c6baa95..5be5e64 100644 --- a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/BrigadierCommandHelper.kt @@ -1,5 +1,6 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar.v1_21_4 +import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.context.CommandContext import com.mojang.brigadier.suggestion.Suggestions @@ -12,7 +13,6 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.server.MinecraftServer import org.bukkit.Bukkit -import org.bukkit.scheduler.BukkitRunnable import java.util.concurrent.CompletableFuture object BrigadierCommandHelper { @@ -20,7 +20,7 @@ object BrigadierCommandHelper { val COMMAND_SOURCE: CommandSourceStack by lazy { MinecraftServer.getServer().createCommandSourceStack() } - val dispatcher by lazy { MinecraftServer.getServer().functions.dispatcher } + val dispatcher: CommandDispatcher by lazy { MinecraftServer.getServer().functions.dispatcher } fun register(command: LiteralArgumentBuilder): LiteralCommandNode? = dispatcher.register(command) @@ -87,10 +87,4 @@ object BrigadierCommandHelper { return emptyList() } -} - -fun sync(execution: () -> Unit) { - object : BukkitRunnable() { - override fun run() = execution() - }.runTask(CommandRegistrar.plugin) } \ No newline at end of file diff --git a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt similarity index 90% rename from spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt rename to paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt index 98509ce..a46a455 100644 --- a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar.v1_21_4 import com.mojang.brigadier.Command import com.mojang.brigadier.builder.ArgumentBuilder @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit @@ -42,6 +42,9 @@ object CommandAdapter { brigadierCommand.suggests { context, builder -> BrigadierCommandHelper.handleSuggestions(command, context, builder) } + brigadierCommand.suggests { context, builder -> + BrigadierCommandHelper.handleSuggestions(command, context, builder) + } } fun handleArguments(command: AbstractStellarCommand<*>, brigadierCommand: ArgumentBuilder) { @@ -65,7 +68,7 @@ object CommandAdapter { } private fun handleLiteralArgument(argument: LiteralStellarArgument, brigadierCommand: ArgumentBuilder) { - for (argumentBuilder in ArgumentHelper.getLiteralArguments(argument)) { + for (argumentBuilder in ArgumentAdapter.getLiteralArguments(argument)) { handleCommandFunctions(argument, argumentBuilder) handleArguments(argument, argumentBuilder) brigadierCommand.then(argumentBuilder) @@ -73,14 +76,14 @@ object CommandAdapter { } private fun handlePhraseArgument(argument: PhraseArgument, brigadierCommand: ArgumentBuilder) { - val argumentBuilder = ArgumentHelper.getRequiredArgumentBuilder(argument) + val argumentBuilder = ArgumentAdapter.getRequiredArgumentBuilder(argument) handleCommandFunctions(argument, argumentBuilder) handleGreedyStringWordFunctions(argument, argumentBuilder) brigadierCommand.then(argumentBuilder) } private fun handleGreedyStringWordFunctions(argument: PhraseArgument, argumentBuilder: RequiredArgumentBuilder) { - argumentBuilder.executes { context -> + if (argument.executions.isNotEmpty() || argument.executions.isNotEmpty()) argumentBuilder.executes { context -> Bukkit.getScheduler().runTask(CommandRegistrar.plugin, Runnable { val greedyContext = CommandContextAdapter.getGreedyCommandContext(context) @@ -113,7 +116,7 @@ object CommandAdapter { } private fun handleRequiredArgument(argument: AbstractStellarArgument<*>, brigadierCommand: ArgumentBuilder) { - val argumentBuilder = ArgumentHelper.getRequiredArgumentBuilder(argument) + val argumentBuilder = ArgumentAdapter.getRequiredArgumentBuilder(argument) handleCommandFunctions(argument, argumentBuilder) handleArguments(argument, argumentBuilder) brigadierCommand.then(argumentBuilder) diff --git a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt similarity index 79% rename from paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt rename to paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt index b63b2f2..ad556f6 100644 --- a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt @@ -1,26 +1,23 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar.v1_21_4 import com.mojang.brigadier.context.CommandContext import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException import com.undefined.stellar.exception.LiteralArgumentMismatchException -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer +import io.papermc.paper.adventure.PaperAdventure import net.minecraft.commands.CommandSource import net.minecraft.commands.CommandSourceStack import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent import net.minecraft.server.MinecraftServer import net.minecraft.world.phys.Vec2 import net.minecraft.world.phys.Vec3 import org.bukkit.command.CommandSender -import java.util.* object CommandContextAdapter { @@ -35,7 +32,7 @@ object CommandContextAdapter { if (argument is CustomArgument) return@associate Pair(argument.name) { argument.parse(it) } if (argument is LiteralStellarArgument) return@associate Pair(argument.name) { throw LiteralArgumentMismatchException() } Pair(argument.name) { - ArgumentHelper.getParsedArgument(context, argument) + ArgumentAdapter.getParsedArgument(context, argument) } } as CommandNode return com.undefined.stellar.data.argument.CommandContext( @@ -62,28 +59,23 @@ object CommandContextAdapter { val overworld = MinecraftServer.getServer().overworld() return CommandSourceStack( Source(sender), - Vec3.atLowerCornerOf(overworld.getSharedSpawnPos()), + Vec3.atLowerCornerOf(overworld.sharedSpawnPos), Vec2.ZERO, overworld, 4, sender.name, - TextComponent(sender.name), + Component.literal(sender.name), MinecraftServer.getServer(), null ) } - @Suppress("DEPRECATION") private data class Source(val sender: CommandSender) : CommandSource { - override fun sendMessage(message: Component, uuid: UUID) = - this.sender.sendMessage(LegacyComponentSerializer.legacySection().serialize(asAdventure(message))) + override fun sendSystemMessage(message: Component) = this.sender.sendMessage(PaperAdventure.asAdventure(message)) override fun acceptsSuccess(): Boolean = true override fun acceptsFailure(): Boolean = true override fun shouldInformAdmins(): Boolean = false override fun getBukkitSender(stack: CommandSourceStack): CommandSender = this.sender } - fun asAdventure(component: Component): net.kyori.adventure.text.Component = - GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(component)) - } \ No newline at end of file diff --git a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt similarity index 90% rename from paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt rename to paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt index c1c9f60..52a5c71 100644 --- a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt +++ b/paper/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt @@ -1,9 +1,9 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar.v1_21_4 import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.registrar.AbstractCommandRegistrar -import com.undefined.stellar.v1_17_1.BrigadierCommandHelper.dispatcher +import com.undefined.stellar.v1_21_4.BrigadierCommandHelper.dispatcher import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 988ab32..3612731 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,16 +1,22 @@ +import com.undefinedcreations.runServer.ServerType + plugins { kotlin("jvm") version "1.9.22" id("com.undefinedcreations.runServer") version "0.1.6" id("com.gradleup.shadow") version "8.3.5" } +repositories { + maven("https://repo.papermc.io/repository/maven-public/") +} + val versionVar = version val groupIdVar = "com.undefined" val artifactIdVar = "stellar" dependencies { - compileOnly("org.spigotmc:spigot-api:1.21.4-R0.1-SNAPSHOT") - implementation(project(":spigot:api")) + compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT") + implementation(project(":paper:api")) } tasks { @@ -30,6 +36,7 @@ tasks { minecraftVersion("1.21.4") serverFolderName { "run" } acceptMojangEula() + serverType(ServerType.PAPERMC) } } diff --git a/server/src/main/kotlin/com/undefined/stellar/Main.kt b/server/src/main/kotlin/com/undefined/stellar/Main.kt index 3f33fa7..bed3a3a 100644 --- a/server/src/main/kotlin/com/undefined/stellar/Main.kt +++ b/server/src/main/kotlin/com/undefined/stellar/Main.kt @@ -1,12 +1,17 @@ package com.undefined.stellar import com.undefined.stellar.data.suggestion.Suggestion +import org.bukkit.Bukkit import org.bukkit.World.Environment import org.bukkit.entity.Player +import org.bukkit.event.EventHandler +import org.bukkit.event.Listener +import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.plugin.java.JavaPlugin import java.util.concurrent.CompletableFuture class Main : JavaPlugin() { + override fun onEnable() { StellarCommand("test") .addEnumArgument("env") @@ -20,7 +25,8 @@ class Main : JavaPlugin() { return@supplyAsync listOf(Suggestion.withText("test")) } } - .addSuggestion(Suggestion.withText("text")) + .addSuggestion("a") .register(this) } + } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 30a5c39..dd767c7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,5 +35,5 @@ include( ":spigot:v1_21_4", ":paper:api", ":paper:common", - ":paper:v1_17_1", + ":paper:v1_21_4", ) \ No newline at end of file diff --git a/spigot/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt b/spigot/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt index aff150f..99da36b 100644 --- a/spigot/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt +++ b/spigot/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt @@ -1,5 +1,6 @@ package com.undefined.stellar.manager +import com.undefined.stellar.CommandRegistrar import com.undefined.stellar.listener.StellarListener import com.undefined.stellar.registrar.AbstractCommandRegistrar import org.bukkit.Bukkit @@ -28,7 +29,7 @@ object CommandManager { "1.16.4" to com.undefined.stellar.v1_16_4.CommandRegistrar::class, "1.16.5" to com.undefined.stellar.v1_16_5.CommandRegistrar::class, "1.17" to com.undefined.stellar.v1_17.CommandRegistrar::class, - "1.17.1" to com.undefined.stellar.v1_17_1.CommandRegistrar::class, + "1.17.1" to CommandRegistrar::class, "1.18" to com.undefined.stellar.v1_18_1.CommandRegistrar::class, "1.18.1" to com.undefined.stellar.v1_18_1.CommandRegistrar::class, "1.18.2" to com.undefined.stellar.v1_18_2.CommandRegistrar::class, diff --git a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/ArgumentHelper.kt b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/ArgumentHelper.kt index 9d1ab27..b8b210c 100644 --- a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/ArgumentHelper.kt +++ b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/ArgumentHelper.kt @@ -10,26 +10,21 @@ import com.mojang.brigadier.context.StringRange import com.mojang.brigadier.exceptions.CommandSyntaxException import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -74,12 +69,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> throwArgumentVersionException(argument) @@ -87,65 +82,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> throwArgumentVersionException(argument) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.TimeArgument -> throwArgumentVersionException(argument) is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -155,70 +150,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -227,47 +222,47 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.world.DimensionArgument -> throwArgumentVersionException(argument) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> throwArgumentVersionException(argument) - is VillagerTypeArgument -> throwArgumentVersionException(argument) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.BiomeArgument -> throwArgumentVersionException(argument) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> throwArgumentVersionException(argument) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> throwArgumentVersionException(argument) else -> throw UnsupportedArgumentException(argument) } } @@ -296,11 +291,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.b() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.b() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandAdapter.kt b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandAdapter.kt index aeb801a..297d622 100644 --- a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandAdapter.kt +++ b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_13_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandContextAdapter.kt b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandContextAdapter.kt index 66ebb57..36e0e2a 100644 --- a/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandContextAdapter.kt +++ b/spigot/v1_13/src/main/kotlin/com/undefined/stellar/v1_13/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/ArgumentHelper.kt b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/ArgumentHelper.kt index d8a46c4..95e4e1d 100644 --- a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/ArgumentHelper.kt +++ b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -78,14 +73,14 @@ object ArgumentHelper { ICompletionProvider.a(IRegistry.MOB_EFFECT.keySet(), builder) } is VillagerProfessionArgument -> throwArgumentVersionException(argument) - is VillagerTypeArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> throwArgumentVersionException(argument) else -> null } @@ -96,12 +91,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -109,65 +104,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.TimeArgument -> throwArgumentVersionException(argument) is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -177,70 +172,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -249,47 +244,47 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> throwArgumentVersionException(argument) - is VillagerTypeArgument -> throwArgumentVersionException(argument) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.BiomeArgument -> throwArgumentVersionException(argument) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> throwArgumentVersionException(argument) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> throwArgumentVersionException(argument) else -> throw UnsupportedArgumentException(argument) } } @@ -318,11 +313,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.b() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.b() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandAdapter.kt b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandAdapter.kt index 1dd7a83..194b3ac 100644 --- a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandAdapter.kt +++ b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_13_R2.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandContextAdapter.kt b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandContextAdapter.kt index 6c3244d..374b047 100644 --- a/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandContextAdapter.kt +++ b/spigot/v1_13_1/src/main/kotlin/com/undefined/stellar/v1_13_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/ArgumentHelper.kt b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/ArgumentHelper.kt index df8b8b4..88e9855 100644 --- a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/ArgumentHelper.kt +++ b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -78,14 +73,14 @@ object ArgumentHelper { ICompletionProvider.a(IRegistry.MOB_EFFECT.keySet(), builder) } is VillagerProfessionArgument -> throwArgumentVersionException(argument) - is VillagerTypeArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> throwArgumentVersionException(argument) else -> null } @@ -96,12 +91,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -109,65 +104,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.TimeArgument -> throwArgumentVersionException(argument) is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -177,70 +172,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> throwArgumentVersionException(argument) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -249,47 +244,47 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> throwArgumentVersionException(argument) - is VillagerTypeArgument -> throwArgumentVersionException(argument) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.BiomeArgument -> throwArgumentVersionException(argument) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> throwArgumentVersionException(argument) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> throwArgumentVersionException(argument) else -> throw UnsupportedArgumentException(argument) } } @@ -318,11 +313,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.b() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.b() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandAdapter.kt b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandAdapter.kt index a2230a4..1b7dbc5 100644 --- a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandAdapter.kt +++ b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_13_R2.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandContextAdapter.kt b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandContextAdapter.kt index 78985fe..10747e5 100644 --- a/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandContextAdapter.kt +++ b/spigot/v1_13_2/src/main/kotlin/com/undefined/stellar/v1_13_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/ArgumentHelper.kt b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/ArgumentHelper.kt index 40bc3fb..9f97e1e 100644 --- a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/ArgumentHelper.kt +++ b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.c(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandAdapter.kt b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandAdapter.kt index 3b11733..a8f021d 100644 --- a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandAdapter.kt +++ b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_14_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandContextAdapter.kt b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandContextAdapter.kt index 9aa6755..c93c164 100644 --- a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandContextAdapter.kt +++ b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandRegistrar.kt b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandRegistrar.kt index 208555e..a93d2cd 100644 --- a/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandRegistrar.kt +++ b/spigot/v1_14_1/src/main/kotlin/com/undefined/stellar/v1_14_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/ArgumentHelper.kt b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/ArgumentHelper.kt index 9a3f0fe..faf935f 100644 --- a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/ArgumentHelper.kt +++ b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.c(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandAdapter.kt b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandAdapter.kt index bf3ae7c..7fd9cd0 100644 --- a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandAdapter.kt +++ b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_14_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandContextAdapter.kt b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandContextAdapter.kt index a576a07..8dc4b5f 100644 --- a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandContextAdapter.kt +++ b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandRegistrar.kt b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandRegistrar.kt index d069f19..15d2dcd 100644 --- a/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandRegistrar.kt +++ b/spigot/v1_14_2/src/main/kotlin/com/undefined/stellar/v1_14_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/ArgumentHelper.kt b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/ArgumentHelper.kt index 3aa6283..7bfc790 100644 --- a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/ArgumentHelper.kt +++ b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.b()), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).b(), ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.c(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandAdapter.kt b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandAdapter.kt index e242aaf..af28a49 100644 --- a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandAdapter.kt +++ b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_14_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandContextAdapter.kt b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandContextAdapter.kt index 357da0d..049e6b7 100644 --- a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandContextAdapter.kt +++ b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandRegistrar.kt b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandRegistrar.kt index cc4457c..aa011f4 100644 --- a/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandRegistrar.kt +++ b/spigot/v1_14_3/src/main/kotlin/com/undefined/stellar/v1_14_3/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/ArgumentHelper.kt b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/ArgumentHelper.kt index fb891c3..a8e17b4 100644 --- a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/ArgumentHelper.kt +++ b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.c(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.c(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.c(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandAdapter.kt b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandAdapter.kt index 24447c6..fe9102c 100644 --- a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandAdapter.kt +++ b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_14_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandContextAdapter.kt b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandContextAdapter.kt index 7811c56..b9da00e 100644 --- a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandContextAdapter.kt +++ b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandRegistrar.kt b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandRegistrar.kt index 22926e5..bc2d3fc 100644 --- a/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandRegistrar.kt +++ b/spigot/v1_14_4/src/main/kotlin/com/undefined/stellar/v1_14_4/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/ArgumentHelper.kt b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/ArgumentHelper.kt index d4d1320..0c4a5ab 100644 --- a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/ArgumentHelper.kt +++ b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.d(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.d(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.d(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandAdapter.kt b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandAdapter.kt index 5635927..7022951 100644 --- a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandAdapter.kt +++ b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_15_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandContextAdapter.kt b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandContextAdapter.kt index aed4e40..f634288 100644 --- a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandContextAdapter.kt +++ b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandRegistrar.kt b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandRegistrar.kt index 02a17da..96ab9e4 100644 --- a/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandRegistrar.kt +++ b/spigot/v1_15/src/main/kotlin/com/undefined/stellar/v1_15/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/ArgumentHelper.kt b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/ArgumentHelper.kt index e54f140..0449466 100644 --- a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/ArgumentHelper.kt +++ b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.d(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.d(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.d(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandAdapter.kt b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandAdapter.kt index e53cd81..570ce1d 100644 --- a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandAdapter.kt +++ b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_15_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandContextAdapter.kt b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandContextAdapter.kt index 8f2676b..7320aef 100644 --- a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandContextAdapter.kt +++ b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandRegistrar.kt b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandRegistrar.kt index 0ff34bb..f590256 100644 --- a/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandRegistrar.kt +++ b/spigot/v1_15_1/src/main/kotlin/com/undefined/stellar/v1_15_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/ArgumentHelper.kt b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/ArgumentHelper.kt index 4faabcb..da63804 100644 --- a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/ArgumentHelper.kt +++ b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,16 +77,16 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -104,12 +99,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -117,65 +112,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -185,70 +180,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -257,49 +252,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.d(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.d(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) + is com.undefined.stellar.argument.world.DimensionArgument -> World.Environment.getEnvironment(ArgumentDimension.a(context, argument.name).dimensionID) is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> throwArgumentVersionException(argument) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.d(context, argument.name)] ) - is AttributeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.AttributeArgument -> throwArgumentVersionException(argument) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -355,11 +350,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandAdapter.kt b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandAdapter.kt index 041efa0..d06a9fb 100644 --- a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandAdapter.kt +++ b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_15_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandContextAdapter.kt b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandContextAdapter.kt index b647246..88c52ff 100644 --- a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandContextAdapter.kt +++ b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandRegistrar.kt b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandRegistrar.kt index 1003f19..f5e57a4 100644 --- a/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandRegistrar.kt +++ b/spigot/v1_15_2/src/main/kotlin/com/undefined/stellar/v1_15_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/ArgumentHelper.kt b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/ArgumentHelper.kt index 7571643..8e63737 100644 --- a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/ArgumentHelper.kt +++ b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,19 +77,19 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ATTRIBUTE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -107,12 +102,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -120,65 +115,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a() is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -188,70 +183,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -260,49 +255,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.e(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.e(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a(context, argument.name) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU[ArgumentMinecraftKeyRegistered.e(context, argument.name)] ) - is AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -359,11 +354,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandAdapter.kt b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandAdapter.kt index e9b5682..2806dab 100644 --- a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandAdapter.kt +++ b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_16_R1.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandContextAdapter.kt b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandContextAdapter.kt index 6a09f62..0f58270 100644 --- a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandContextAdapter.kt +++ b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandRegistrar.kt b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandRegistrar.kt index 842e751..475226d 100644 --- a/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandRegistrar.kt +++ b/spigot/v1_16_1/src/main/kotlin/com/undefined/stellar/v1_16_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/ArgumentHelper.kt b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/ArgumentHelper.kt index e263b88..8ca7817 100644 --- a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/ArgumentHelper.kt +++ b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,19 +77,19 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ATTRIBUTE.keySet(), builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -107,12 +102,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -120,65 +115,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a() - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a() + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a() is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -188,70 +183,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -260,49 +255,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.e(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.e(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a(context, argument.name) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU.d(ResourceKey.a(IRegistry.v, ArgumentMinecraftKeyRegistered.e(context, argument.name))) ) - is AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> throwArgumentVersionException(argument) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -359,11 +354,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandAdapter.kt b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandAdapter.kt index 5f727f9..a1c402f 100644 --- a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandAdapter.kt +++ b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_16_R2.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandContextAdapter.kt b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandContextAdapter.kt index 354f78b..cf61995 100644 --- a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandContextAdapter.kt +++ b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandRegistrar.kt b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandRegistrar.kt index 0ca268c..c97559b 100644 --- a/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandRegistrar.kt +++ b/spigot/v1_16_2/src/main/kotlin/com/undefined/stellar/v1_16_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/ArgumentHelper.kt b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/ArgumentHelper.kt index deede24..ec8a329 100644 --- a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/ArgumentHelper.kt +++ b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,10 +77,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -94,13 +89,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> CompletionProviders.c.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -113,12 +108,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -126,65 +121,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a() - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a() + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a() is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> ArgumentMinecraftKeyRegistered.a() is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -194,70 +189,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -266,49 +261,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.e(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.e(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a(context, argument.name) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU.d(ResourceKey.a(IRegistry.v, ArgumentMinecraftKeyRegistered.e(context, argument.name))) ) - is AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> throwArgumentVersionException(argument) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -365,11 +360,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandAdapter.kt b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandAdapter.kt index 9016c50..75773f4 100644 --- a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandAdapter.kt +++ b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_16_R2.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandContextAdapter.kt b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandContextAdapter.kt index b6648d1..aa2315a 100644 --- a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandContextAdapter.kt +++ b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandRegistrar.kt b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandRegistrar.kt index 395edbf..e9528af 100644 --- a/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandRegistrar.kt +++ b/spigot/v1_16_3/src/main/kotlin/com/undefined/stellar/v1_16_3/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/ArgumentHelper.kt b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/ArgumentHelper.kt index 2250b7c..3676f63 100644 --- a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/ArgumentHelper.kt +++ b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/ArgumentHelper.kt @@ -11,26 +11,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -82,10 +77,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -94,13 +89,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> CompletionProviders.c.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -113,12 +108,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -126,65 +121,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a() - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a() + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a() is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> ArgumentMinecraftKeyRegistered.a() is SoundArgument -> ArgumentMinecraftKeyRegistered.a() - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -194,70 +189,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -266,49 +261,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.e(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.e(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a(context, argument.name) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU.d(ResourceKey.a(IRegistry.v, ArgumentMinecraftKeyRegistered.e(context, argument.name))) ) - is AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -365,11 +360,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandAdapter.kt b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandAdapter.kt index b45ec2a..012d758 100644 --- a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandAdapter.kt +++ b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_16_R3.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandContextAdapter.kt b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandContextAdapter.kt index 649ae35..77b2218 100644 --- a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandContextAdapter.kt +++ b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandRegistrar.kt b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandRegistrar.kt index ad444d1..f8fab43 100644 --- a/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandRegistrar.kt +++ b/spigot/v1_16_4/src/main/kotlin/com/undefined/stellar/v1_16_4/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/ArgumentHelper.kt b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/ArgumentHelper.kt index 335e6a9..73b9c16 100644 --- a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/ArgumentHelper.kt +++ b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/ArgumentHelper.kt @@ -13,26 +13,21 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.EntityDisplayType -import com.undefined.stellar.argument.types.item.ItemSlotArgument -import com.undefined.stellar.argument.types.item.ItemSlotsArgument -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.HeightMapArgument -import com.undefined.stellar.argument.types.world.LocationArgument -import com.undefined.stellar.argument.types.world.LocationType +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.item.ItemSlotArgument +import com.undefined.stellar.argument.item.ItemSlotsArgument +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.HeightMapArgument +import com.undefined.stellar.argument.world.LocationArgument +import com.undefined.stellar.argument.world.LocationType import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -84,10 +79,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -96,13 +91,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> CompletionProviders.c.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> CompletionProviders.d.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> ICompletionProvider.a(IRegistry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -115,12 +110,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> ArgumentPosition.a() LocationType.LOCATION_2D -> ArgumentVec2I.a() @@ -128,65 +123,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> ArgumentVec2.a() } is BlockDataArgument -> ArgumentTile.a() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() - is com.undefined.stellar.argument.types.item.ItemArgument -> ArgumentItemStack.a() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ArgumentItemPredicate.a() - is com.undefined.stellar.argument.types.text.ColorArgument -> ArgumentChatFormat.a() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ArgumentChatComponent.a() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> ArgumentChat.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() - is com.undefined.stellar.argument.types.math.OperationArgument -> ArgumentMathOperation.a() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ArgumentParticle.a() - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a() - is com.undefined.stellar.argument.types.math.RotationArgument -> ArgumentRotation.a() - is DisplaySlotArgument -> ArgumentScoreboardSlot.a() - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a() - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> ArgumentBlockPredicate.a() + is com.undefined.stellar.argument.item.ItemArgument -> ArgumentItemStack.a() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ArgumentItemPredicate.a() + is com.undefined.stellar.argument.text.ColorArgument -> ArgumentChatFormat.a() + is com.undefined.stellar.argument.text.ComponentArgument -> ArgumentChatComponent.a() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> ArgumentChat.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ArgumentScoreboardObjective.a() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a() + is com.undefined.stellar.argument.math.OperationArgument -> ArgumentMathOperation.a() + is com.undefined.stellar.argument.world.ParticleArgument -> ArgumentParticle.a() + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a() + is com.undefined.stellar.argument.math.RotationArgument -> ArgumentRotation.a() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ArgumentScoreboardSlot.a() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b() } - is AxisArgument -> ArgumentRotationAxis.a() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() + is com.undefined.stellar.argument.math.AxisArgument -> ArgumentRotationAxis.a() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> ArgumentScoreboardTeam.a() is ItemSlotArgument -> ArgumentInventorySlot.a() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ArgumentMinecraftKeyRegistered.a() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> ArgumentAnchor.a() - is com.undefined.stellar.argument.types.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> ArgumentAnchor.a() + is com.undefined.stellar.argument.math.RangeArgument -> ReflectionUtil.executePrivateMethod, ArgumentCriterionValue<*>>("a") + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> ArgumentTime.a() + is com.undefined.stellar.argument.math.TimeArgument -> ArgumentTime.a() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a() is GameEventArgument -> ArgumentMinecraftKeyRegistered.a() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ArgumentMinecraftKeyRegistered.a() - is VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.AttributeArgument -> ArgumentMinecraftKeyRegistered.a() is FluidArgument -> ArgumentMinecraftKeyRegistered.a() is SoundArgument -> ArgumentMinecraftKeyRegistered.a() - is BiomeArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.BiomeArgument -> ArgumentMinecraftKeyRegistered.a() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ArgumentMinecraftKeyRegistered.a() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ArgumentMinecraftKeyRegistered.a() else -> throw UnsupportedArgumentException(argument) } @@ -196,70 +191,70 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> ArgumentEntity.b(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(ArgumentEntity.a(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> ArgumentProfile.a(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(ArgumentTile.a(context, argument.name).a()) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> ArgumentBlockPredicate.a(context, argument.name).test(ShapeDetectorBlock( context.source.world, BlockPosition(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy( + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy( ArgumentItemStack.a(context, argument.name).a(1, false) ) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ArgumentItemPredicate.a(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ArgumentChatFormat.a( context, argument.name ).character) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson() + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson() .deserialize(IChatBaseComponent.ChatSerializer.a( ArgumentChatComponent.a(context, argument.name) )) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null ).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize( IChatBaseComponent.ChatSerializer.a(ArgumentChat.a(context, argument.name)) ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective( ArgumentScoreboardObjective.a(context, argument.name).name ) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ArgumentScoreboardCriteria.a( context, argument.name ).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation( + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ArgumentParticle.a(context, argument.name) getParticleData(CraftParticle.toBukkit(particleOptions.particle), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> ArgumentAngle.a(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> ArgumentAngle.a(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = ArgumentRotation.a(context, argument.name).a(context.source) Location(context.source.world.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) { - ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) - ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ArgumentScoreboardSlot.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ArgumentScoreholder.a(context, argument.name) + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ArgumentScoreholder.b(context, argument.name) } - is AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( + is com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(ArgumentRotationAxis.a(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam( ArgumentScoreboardTeam.a(context, argument.name).name ) is ItemSlotArgument -> ArgumentInventorySlot.a(context, argument.name) @@ -268,49 +263,49 @@ object ArgumentHelper { ArgumentMinecraftKeyRegistered.e(context, argument.name).namespace, ArgumentMinecraftKeyRegistered.e(context, argument.name).key ) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName( + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName( getArgumentInput(context, argument.name) ?: return null ) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.math.RangeArgument -> { val range = ArgumentCriterionValue.b.a(context, argument.name) IntRange(range.a() ?: 1, range.b() ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> ArgumentDimension.a(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> ArgumentUUID.a(context, argument.name) is GameEventArgument -> throwArgumentVersionException(argument) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType( IRegistry.MENU.d(ResourceKey.a(IRegistry.v, ArgumentMinecraftKeyRegistered.e(context, argument.name))) ) - is AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -367,11 +362,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): ArgumentEntity = when (type) { - EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") - EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() - EntityDisplayType.PLAYER -> ArgumentEntity.c() - EntityDisplayType.PLAYERS -> ArgumentEntity.d() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): ArgumentEntity = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> ReflectionUtil.executePrivateMethod("a") + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> ArgumentEntity.multipleEntities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> ArgumentEntity.c() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> ArgumentEntity.d() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandAdapter.kt b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandAdapter.kt index 625c7ce..c6269ed 100644 --- a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandAdapter.kt +++ b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.server.v1_16_R3.CommandListenerWrapper import org.bukkit.Bukkit diff --git a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandContextAdapter.kt b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandContextAdapter.kt index 3a02298..5650278 100644 --- a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandContextAdapter.kt +++ b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandRegistrar.kt b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandRegistrar.kt index 6279ad6..bfec51c 100644 --- a/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandRegistrar.kt +++ b/spigot/v1_16_5/src/main/kotlin/com/undefined/stellar/v1_16_5/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/ArgumentHelper.kt b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/ArgumentHelper.kt index 94a42fe..198bfe4 100644 --- a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/ArgumentHelper.kt +++ b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/ArgumentHelper.kt @@ -13,23 +13,19 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -41,10 +37,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.SharedSuggestionProvider import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,10 +96,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -115,13 +108,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_SOUNDS.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_BIOMES.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -134,12 +127,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -147,65 +140,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() - is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() - 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) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceLocationArgument.id() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ResourceLocationArgument.id() - is VillagerTypeArgument -> ResourceLocationArgument.id() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceLocationArgument.id() is FluidArgument -> ResourceLocationArgument.id() is SoundArgument -> ResourceLocationArgument.id() - is BiomeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceLocationArgument.id() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceLocationArgument.id() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceLocationArgument.id() else -> throw UnsupportedArgumentException(argument) } @@ -215,93 +208,93 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source) Location(context.source.level.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name)) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(Registry.MENU.getOrThrow(ResourceKey.create(Registry.MENU_REGISTRY, ResourceLocationArgument.getId(context, argument.name)))) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -358,11 +351,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandAdapter.kt b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandAdapter.kt index 855a4ea..6bbc052 100644 --- a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandAdapter.kt +++ b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandContextAdapter.kt b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandContextAdapter.kt index d4551ee..74a5107 100644 --- a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandContextAdapter.kt +++ b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandRegistrar.kt b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandRegistrar.kt index a670c8d..410dab8 100644 --- a/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandRegistrar.kt +++ b/spigot/v1_17/src/main/kotlin/com/undefined/stellar/v1_17/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/ArgumentHelper.kt similarity index 65% rename from paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt rename to spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/ArgumentHelper.kt index d967e9f..d9cdd67 100644 --- a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt +++ b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/ArgumentHelper.kt @@ -1,6 +1,6 @@ @file:Suppress("DEPRECATION") -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar import com.mojang.brigadier.arguments.* import com.mojang.brigadier.builder.ArgumentBuilder @@ -13,23 +13,19 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -41,10 +37,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.SharedSuggestionProvider import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,10 +96,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -115,13 +108,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_SOUNDS.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_BIOMES.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -134,12 +127,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -147,65 +140,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() - is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() - 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) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceLocationArgument.id() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ResourceLocationArgument.id() - is VillagerTypeArgument -> ResourceLocationArgument.id() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceLocationArgument.id() is FluidArgument -> ResourceLocationArgument.id() is SoundArgument -> ResourceLocationArgument.id() - is BiomeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceLocationArgument.id() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceLocationArgument.id() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceLocationArgument.id() else -> throw UnsupportedArgumentException(argument) } @@ -215,93 +208,93 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source) Location(context.source.level.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name)) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(Registry.MENU.getOrThrow(ResourceKey.create(Registry.MENU_REGISTRY, ResourceLocationArgument.getId(context, argument.name)))) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -358,11 +351,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/BrigadierCommandHelper.kt similarity index 98% rename from spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt rename to spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/BrigadierCommandHelper.kt index c6baa95..68f49e5 100644 --- a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/BrigadierCommandHelper.kt +++ b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/BrigadierCommandHelper.kt @@ -1,11 +1,10 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.context.CommandContext import com.mojang.brigadier.suggestion.Suggestions import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.mojang.brigadier.tree.LiteralCommandNode -import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.data.help.CustomCommandHelpTopic import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer diff --git a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandAdapter.kt similarity index 95% rename from paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt rename to spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandAdapter.kt index 98509ce..8a68cb2 100644 --- a/paper/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandAdapter.kt +++ b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandAdapter.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar import com.mojang.brigadier.Command import com.mojang.brigadier.builder.ArgumentBuilder @@ -7,10 +7,9 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder import com.mojang.brigadier.context.StringRange import com.mojang.brigadier.suggestion.Suggestions import com.mojang.brigadier.suggestion.SuggestionsBuilder -import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit @@ -30,7 +29,7 @@ object CommandAdapter { if (command.executions.isNotEmpty() || command.executions.isNotEmpty()) brigadierCommand.executes { context -> object : BukkitRunnable() { - override fun run() = BrigadierCommandHelper.handleExecutions(command, context) + override fun run() = BrigadierCommandHelper.handleExecutions(command, context) }.runTask(CommandRegistrar.plugin) 1 } diff --git a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandContextAdapter.kt similarity index 95% rename from spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt rename to spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandContextAdapter.kt index b63b2f2..25e0033 100644 --- a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandContextAdapter.kt +++ b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandContextAdapter.kt @@ -1,11 +1,9 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar import com.mojang.brigadier.context.CommandContext -import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandRegistrar.kt similarity index 84% rename from spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt rename to spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandRegistrar.kt index c1c9f60..a02faa5 100644 --- a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/CommandRegistrar.kt +++ b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/CommandRegistrar.kt @@ -1,9 +1,7 @@ -package com.undefined.stellar.v1_17_1 +package com.undefined.stellar -import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.StellarCommands +import com.undefined.stellar.BrigadierCommandHelper.dispatcher import com.undefined.stellar.registrar.AbstractCommandRegistrar -import com.undefined.stellar.v1_17_1.BrigadierCommandHelper.dispatcher import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin @@ -12,7 +10,7 @@ object CommandRegistrar : AbstractCommandRegistrar { lateinit var plugin: JavaPlugin override fun register(command: AbstractStellarCommand<*>, plugin: JavaPlugin) { - this.plugin = plugin + CommandRegistrar.plugin = plugin BrigadierCommandHelper.handleHelpTopic(command) for (name in command.aliases + command.name) BrigadierCommandHelper.register(CommandAdapter.getBaseCommand(command, name)) @@ -25,7 +23,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt b/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt deleted file mode 100644 index d967e9f..0000000 --- a/spigot/v1_17_1/src/main/kotlin/com/undefined/stellar/v1_17_1/ArgumentHelper.kt +++ /dev/null @@ -1,443 +0,0 @@ -@file:Suppress("DEPRECATION") - -package com.undefined.stellar.v1_17_1 - -import com.mojang.brigadier.arguments.* -import com.mojang.brigadier.builder.ArgumentBuilder -import com.mojang.brigadier.builder.LiteralArgumentBuilder -import com.mojang.brigadier.builder.RequiredArgumentBuilder -import com.mojang.brigadier.context.CommandContext -import com.mojang.brigadier.context.ParsedArgument -import com.mojang.brigadier.context.StringRange -import com.mojang.brigadier.exceptions.CommandSyntaxException -import com.mojang.brigadier.suggestion.SuggestionProvider -import com.undefined.stellar.argument.AbstractStellarArgument -import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* -import com.undefined.stellar.data.argument.Anchor -import com.undefined.stellar.data.argument.Operation -import com.undefined.stellar.data.argument.ParticleData -import com.undefined.stellar.exception.ArgumentVersionMismatchException -import com.undefined.stellar.exception.LiteralArgumentMismatchException -import com.undefined.stellar.exception.UnsupportedArgumentException -import com.undefined.stellar.util.NMSVersion -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer -import net.minecraft.commands.CommandSourceStack -import net.minecraft.commands.SharedSuggestionProvider -import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument -import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument -import net.minecraft.commands.arguments.blocks.BlockPredicateArgument -import net.minecraft.commands.arguments.blocks.BlockStateArgument -import net.minecraft.commands.arguments.coordinates.* -import net.minecraft.commands.arguments.item.ItemArgument -import net.minecraft.commands.arguments.item.ItemPredicateArgument -import net.minecraft.commands.synchronization.SuggestionProviders -import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.core.Registry -import net.minecraft.core.particles.* -import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceKey -import net.minecraft.server.level.ColumnPos -import net.minecraft.world.inventory.MenuType -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.state.pattern.BlockInWorld -import net.minecraft.world.level.gameevent.BlockPositionSource -import net.minecraft.world.phys.Vec2 -import net.minecraft.world.phys.Vec3 -import org.bukkit.* -import org.bukkit.block.Block -import org.bukkit.block.data.BlockData -import org.bukkit.craftbukkit.v1_17_R1.CraftParticle -import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack -import org.bukkit.event.inventory.InventoryType -import org.bukkit.inventory.ItemStack -import org.bukkit.scoreboard.DisplaySlot -import java.util.* -import java.util.function.Predicate - -@Suppress("UNCHECKED_CAST") -object ArgumentHelper { - - fun getLiteralArguments(argument: AbstractStellarArgument<*>): List> { - val arguments: MutableList> = mutableListOf() - for (name in argument.aliases + argument.name) - arguments.add(LiteralArgumentBuilder.literal(name)) - return arguments - } - - fun getRequiredArgumentBuilder(argument: AbstractStellarArgument<*>): RequiredArgumentBuilder { - val argumentBuilder: RequiredArgumentBuilder = RequiredArgumentBuilder.argument(argument.name, getArgumentType(argument)) - getSuggestions(argument)?.let { argumentBuilder.suggests(it) } - return argumentBuilder - } - - private fun > getSuggestions(argument: T): SuggestionProvider? = - when (argument) { - is GameEventArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.GAME_EVENT.keySet(), builder) - } - is PotionEffectTypeArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.MOB_EFFECT.keySet(), builder) - } - is VillagerProfessionArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.VILLAGER_PROFESSION.keySet(), builder) - } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.VILLAGER_TYPE.keySet(), builder) - } - is AttributeArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.ATTRIBUTE.keySet(), builder) - } - is FluidArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.FLUID.keySet(), builder) - } - is SoundArgument -> SuggestionProvider { context, builder -> - SuggestionProviders.AVAILABLE_SOUNDS.getSuggestions(context, builder) - } - is BiomeArgument -> SuggestionProvider { context, builder -> - SuggestionProviders.AVAILABLE_BIOMES.getSuggestions(context, builder) - } - is EntityTypeArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.ENTITY_TYPE.keySet(), builder) - } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> - SharedSuggestionProvider.suggestResource(Registry.MEMORY_MODULE_TYPE.keySet(), builder) - } - else -> null - } - - private fun > getArgumentType(argument: T): ArgumentType<*> = - when (argument) { - is ListArgument<*> -> getArgumentType(argument.type) - is CustomArgument<*> -> getArgumentType(argument.type) - is StringArgument -> brigadier(argument.type) - is PhraseArgument -> brigadier(StringType.PHRASE) - is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) - is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) - is BooleanArgument -> BoolArgumentType.bool() - 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.LOCATION_3D -> BlockPosArgument.blockPos() - LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() - LocationType.PRECISE_LOCATION_2D -> Vec3Argument.vec3() - LocationType.PRECISE_LOCATION_3D -> Vec2Argument.vec2() - } - is BlockDataArgument -> BlockStateArgument.block() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() - is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() - 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) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> 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() - is ItemSlotsArgument -> throwArgumentVersionException(argument) - is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() - is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) - is HeightMapArgument -> throwArgumentVersionException(argument) - is LootTableArgument -> throwArgumentVersionException(argument) - is UUIDArgument -> UuidArgument.uuid() - is GameEventArgument -> ResourceLocationArgument.id() - is StructureTypeArgument -> throwArgumentVersionException(argument) - is PotionEffectTypeArgument -> throwArgumentVersionException(argument) - is BlockTypeArgument -> throwArgumentVersionException(argument) - is ItemTypeArgument -> throwArgumentVersionException(argument) - is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) - is VillagerProfessionArgument -> ResourceLocationArgument.id() - is VillagerTypeArgument -> ResourceLocationArgument.id() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) - is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceLocationArgument.id() - is FluidArgument -> ResourceLocationArgument.id() - is SoundArgument -> ResourceLocationArgument.id() - is BiomeArgument -> ResourceLocationArgument.id() - is StructureArgument -> throwArgumentVersionException(argument) - is TrimMaterialArgument -> throwArgumentVersionException(argument) - is TrimPatternArgument -> throwArgumentVersionException(argument) - is DamageTypeArgument -> throwArgumentVersionException(argument) - is WolfVariantArgument -> throwArgumentVersionException(argument) - is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) - is InstrumentArgument -> throwArgumentVersionException(argument) - is EntityTypeArgument -> ResourceLocationArgument.id() - is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceLocationArgument.id() - else -> throw UnsupportedArgumentException(argument) - } - - fun > getParsedArgument(context: CommandContext, argument: T): Any? { - return when (argument) { - is LiteralStellarArgument -> throw LiteralArgumentMismatchException() - is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) - is StringArgument -> StringArgumentType.getString(context, argument.name) - is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) - is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) - is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) - is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) - .map { it.bukkitEntity }.toMutableList() - .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) - is LocationArgument -> getLocation(context, argument) - is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> - BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( - context.source.level, - BlockPos(block.x, block.y, block.z), true - )) - } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> - ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) - } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( - getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { - val particleOptions = ParticleArgument.getParticle(context, argument.name) - getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) - } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { - val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source) - Location(context.source.level.world, rotation.x, rotation.y, rotation.z) - } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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) - is ItemSlotsArgument -> throwArgumentVersionException(argument) - is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { - val range = RangeArgument.Ints.getRange(context, argument.name) - IntRange(range.min ?: 1, range.max ?: 2) - } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() - is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) - is HeightMapArgument -> throwArgumentVersionException(argument) - is LootTableArgument -> throwArgumentVersionException(argument) - is UUIDArgument -> UuidArgument.getUuid(context, argument.name) - is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name)) - is StructureTypeArgument -> throwArgumentVersionException(argument) - is PotionEffectTypeArgument -> throwArgumentVersionException(argument) - is BlockTypeArgument -> throwArgumentVersionException(argument) - is ItemTypeArgument -> throwArgumentVersionException(argument) - is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) - is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) - is InventoryTypeArgument -> getInventoryType(Registry.MENU.getOrThrow(ResourceKey.create(Registry.MENU_REGISTRY, ResourceLocationArgument.getId(context, argument.name)))) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) - is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name)) - is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) - is StructureArgument -> throwArgumentVersionException(argument) - is TrimMaterialArgument -> throwArgumentVersionException(argument) - is TrimPatternArgument -> throwArgumentVersionException(argument) - is DamageTypeArgument -> throwArgumentVersionException(argument) - is WolfVariantArgument -> throwArgumentVersionException(argument) - is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) - is InstrumentArgument -> throwArgumentVersionException(argument) - is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name)) - is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) - else -> throw UnsupportedArgumentException(argument) - } - } - - fun getArgumentInput(context: CommandContext, name: String): String? { - val field = CommandContext::class.java.getDeclaredField("arguments") - field.isAccessible = true - val arguments: Map> = field.get(context) as Map> - val argument = arguments[name] ?: return null - val range = StringRange.between(argument.range.start, context.input.length) - return range.get(context.input) - } - - private fun getInventoryType(menu: MenuType<*>): InventoryType = when (menu) { - MenuType.GENERIC_9x1 -> InventoryType.CHEST - MenuType.GENERIC_9x2 -> InventoryType.CHEST - MenuType.GENERIC_9x3 -> InventoryType.CHEST - MenuType.GENERIC_9x4 -> InventoryType.CHEST - MenuType.GENERIC_9x5 -> InventoryType.CHEST - MenuType.GENERIC_9x6 -> InventoryType.CHEST - MenuType.GENERIC_3x3 -> InventoryType.WORKBENCH - MenuType.ANVIL -> InventoryType.ANVIL - MenuType.BEACON -> InventoryType.BEACON - MenuType.BLAST_FURNACE -> InventoryType.BLAST_FURNACE - MenuType.BREWING_STAND -> InventoryType.BREWING - MenuType.CRAFTING -> InventoryType.CRAFTING - MenuType.ENCHANTMENT -> InventoryType.ENCHANTING - MenuType.FURNACE -> InventoryType.FURNACE - MenuType.GRINDSTONE -> InventoryType.GRINDSTONE - MenuType.HOPPER -> InventoryType.HOPPER - MenuType.LECTERN -> InventoryType.LECTERN - MenuType.LOOM -> InventoryType.LOOM - MenuType.MERCHANT -> InventoryType.MERCHANT - MenuType.SHULKER_BOX -> InventoryType.SHULKER_BOX - MenuType.SMITHING -> InventoryType.SMITHING - MenuType.SMOKER -> InventoryType.SMOKER - MenuType.CARTOGRAPHY_TABLE -> InventoryType.CARTOGRAPHY - MenuType.STONECUTTER -> InventoryType.STONECUTTER - else -> throw IllegalStateException("No inventory type found! This is not intentional behaviour, please contact the developers.") - } - - @Throws(CommandSyntaxException::class) - private fun getId( - context: CommandContext, - name: String - ): NamespacedKey { - val key = ResourceLocationArgument.getId(context, name) - return NamespacedKey(key.namespace, key.path) - } - - private fun brigadier(type: StringType): StringArgumentType = when (type) { - StringType.WORD -> StringArgumentType.word() - StringType.QUOTABLE_PHRASE -> StringArgumentType.string() - StringType.PHRASE -> StringArgumentType.greedyString() - } - - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() - } - - private fun getBukkitAxis(argument: EnumSet): EnumSet = - argument.mapTo(EnumSet.noneOf(Axis::class.java)) { - when (it) { - Direction.Axis.X -> Axis.X - Direction.Axis.Y -> Axis.Y - Direction.Axis.Z -> Axis.Z - null -> Axis.X - } - } - - private fun getBukkitDisplaySlot(slot: Int): DisplaySlot = when (slot) { - 0 -> DisplaySlot.PLAYER_LIST - 2 -> DisplaySlot.BELOW_NAME - else -> DisplaySlot.SIDEBAR - } - - private fun getParticleData(context: CommandContext, particle: Particle, particleOptions: ParticleOptions): ParticleData<*> = when (particleOptions) { - is SimpleParticleType -> ParticleData(particle, null) - is BlockParticleOption -> ParticleData(particle, CraftBlockData.fromData(particleOptions.state)) - is DustColorTransitionOptions -> { - val fromColor = Color.fromRGB( - (particleOptions.fromColor.x() * 255.0f).toInt(), - (particleOptions.fromColor.y() * 255.0f).toInt(), - (particleOptions.fromColor.z() * 255.0f).toInt() - ) - val toColor = Color.fromRGB( - (particleOptions.toColor.x() * 255.0f).toInt(), - (particleOptions.toColor.y() * 255.0f).toInt(), - (particleOptions.toColor.z() * 255.0f).toInt() - ) - ParticleData(particle, Particle.DustTransition(fromColor, toColor, particleOptions.scale)) - } - is DustParticleOptions -> ParticleData( - particle, - Particle.DustOptions(Color.fromRGB( - (particleOptions.color.x() * 255.0f).toInt(), - (particleOptions.color.y() * 255.0f).toInt(), (particleOptions.color.z() * 255.0f).toInt() - ), particleOptions.scale) - ) - is ItemParticleOption -> ParticleData( - particle, - CraftItemStack.asBukkitCopy(particleOptions.item) - ) - is VibrationParticleOption -> { - val level: Level = context.source.level - - if (particleOptions.vibrationPath.destination is BlockPositionSource) { - val to = particleOptions.vibrationPath.destination.getPosition(level).get().toLocation(level.world) - val destination = Vibration.Destination.BlockDestination(Location(level.world, to.x, to.y, to.z)) - ParticleData(particle, Vibration(to, destination, particleOptions.vibrationPath.arrivalInTicks)) - } else { - ParticleData(particle, null) - } - } - else -> ParticleData(particle, null) - } - - private fun getLocation(context: CommandContext, command: LocationArgument): Location { - val world = context.source.level.world - return when (command.type) { - 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) - } - } - - 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()) - - private fun throwArgumentVersionException(argument: AbstractStellarArgument<*>): Nothing = - throw ArgumentVersionMismatchException(argument, NMSVersion.version) - -} \ No newline at end of file diff --git a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/ArgumentHelper.kt b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/ArgumentHelper.kt index a47d32b..22d287b 100644 --- a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/ArgumentHelper.kt +++ b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/ArgumentHelper.kt @@ -13,23 +13,19 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.SuggestionProvider import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.LootTableArgument -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.LootTableArgument +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -41,10 +37,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.SharedSuggestionProvider import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -100,10 +93,10 @@ object ArgumentHelper { is VillagerProfessionArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_PROFESSION.keySet(), builder) } - is VillagerTypeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.VILLAGER_TYPE.keySet(), builder) } - is AttributeArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.AttributeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ATTRIBUTE.keySet(), builder) } is FluidArgument -> SuggestionProvider { _, builder -> @@ -112,13 +105,13 @@ object ArgumentHelper { is SoundArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_SOUNDS.getSuggestions(context, builder) } - is BiomeArgument -> SuggestionProvider { context, builder -> + is com.undefined.stellar.argument.registry.BiomeArgument -> SuggestionProvider { context, builder -> SuggestionProviders.AVAILABLE_BIOMES.getSuggestions(context, builder) } is EntityTypeArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.ENTITY_TYPE.keySet(), builder) } - is MemoryKeyArgument -> SuggestionProvider { _, builder -> + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> SuggestionProvider { _, builder -> SharedSuggestionProvider.suggestResource(Registry.MEMORY_MODULE_TYPE.keySet(), builder) } else -> null @@ -131,12 +124,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -144,65 +137,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_3D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() - is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() - 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) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceLocationArgument.id() - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ResourceLocationArgument.id() - is VillagerTypeArgument -> ResourceLocationArgument.id() - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceLocationArgument.id() is FluidArgument -> ResourceLocationArgument.id() is SoundArgument -> ResourceLocationArgument.id() - is BiomeArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceLocationArgument.id() is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceLocationArgument.id() is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceLocationArgument.id() + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceLocationArgument.id() else -> throw UnsupportedArgumentException(argument) } @@ -212,90 +205,90 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source) Location(context.source.level.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) is LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name)) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(Registry.MENU.getOrThrow(ResourceKey.create(Registry.MENU_REGISTRY, ResourceLocationArgument.getId(context, argument.name)))) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> org.bukkit.Registry.ENTITY_TYPE.get(getId(context, argument.name)) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name)) else -> throw UnsupportedArgumentException(argument) } } @@ -352,11 +345,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandAdapter.kt b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandAdapter.kt index d5c7863..68ea956 100644 --- a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandAdapter.kt +++ b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandContextAdapter.kt b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandContextAdapter.kt index cb8130f..a713f1c 100644 --- a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandContextAdapter.kt +++ b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandRegistrar.kt b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandRegistrar.kt index af4892e..6b77226 100644 --- a/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandRegistrar.kt +++ b/spigot/v1_18_1/src/main/kotlin/com/undefined/stellar/v1_18_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/ArgumentHelper.kt b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/ArgumentHelper.kt index 37001ab..a00f731 100644 --- a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/ArgumentHelper.kt +++ b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/ArgumentHelper.kt @@ -11,22 +11,18 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import com.undefined.stellar.util.NMSVersion import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -97,12 +90,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -110,65 +103,65 @@ object ArgumentHelper { LocationType.PRECISE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block() - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() - is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item() - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() - 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) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate() + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item() + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate() + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registry.GAME_EVENT.key()) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registry.VILLAGER_PROFESSION.key()) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registry.VILLAGER_TYPE.key()) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registry.VILLAGER_TYPE.key()) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceKeyArgument.key(Registry.ATTRIBUTE.key()) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registry.ATTRIBUTE.key()) is FluidArgument -> ResourceKeyArgument.key(Registry.FLUID.key()) is SoundArgument -> ResourceKeyArgument.key(Registry.SOUND_EVENT.key()) - is BiomeArgument -> ResourceKeyArgument.key(Registry.BIOME_REGISTRY) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registry.BIOME_REGISTRY) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceKeyArgument.key(Registry.ENTITY_TYPE.key()) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registry.MEMORY_MODULE_TYPE.key()) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registry.MEMORY_MODULE_TYPE.key()) else -> throw UnsupportedArgumentException(argument) } @@ -178,93 +171,93 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source) Location(context.source.level.world, rotation.x, rotation.y, rotation.z) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> throwArgumentVersionException(argument) - is StructureRotationArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> throwArgumentVersionException(argument) is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registry.GAME_EVENT_REGISTRY)) - is StructureTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> throwArgumentVersionException(argument) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> throwArgumentVersionException(argument) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registry.VILLAGER_PROFESSION_REGISTRY)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registry.VILLAGER_TYPE_REGISTRY)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registry.VILLAGER_TYPE_REGISTRY)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registry.MENU_REGISTRY).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registry.ATTRIBUTE_REGISTRY)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registry.ATTRIBUTE_REGISTRY)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registry.FLUID_REGISTRY)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registry.SOUND_EVENT_REGISTRY)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registry.BIOME_REGISTRY)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registry.BIOME_REGISTRY)) is StructureArgument -> throwArgumentVersionException(argument) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.ArtArgument -> throwArgumentVersionException(argument) is InstrumentArgument -> throwArgumentVersionException(argument) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registry.MEMORY_MODULE_TYPE_REGISTRY)) else -> throw UnsupportedArgumentException(argument) } } @@ -353,11 +346,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandAdapter.kt b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandAdapter.kt index 3a15be8..68d6a74 100644 --- a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandAdapter.kt +++ b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandContextAdapter.kt b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandContextAdapter.kt index 6184af5..8916fa3 100644 --- a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandContextAdapter.kt +++ b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandRegistrar.kt b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandRegistrar.kt index 4348e99..0597d2b 100644 --- a/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandRegistrar.kt +++ b/spigot/v1_18_2/src/main/kotlin/com/undefined/stellar/v1_18_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt index 7993d09..f100846 100644 --- a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt +++ b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/ArgumentHelper.kt @@ -11,22 +11,18 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -import com.undefined.stellar.argument.types.misc.UUIDArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.player.GameModeArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -38,10 +34,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,65 +109,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle() - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registry.GAME_EVENT.key()) - is StructureTypeArgument -> ResourceKeyArgument.key(Registry.STRUCTURE_TYPE_REGISTRY) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registry.STRUCTURE_TYPE_REGISTRY) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> ResourceKeyArgument.key(Registry.FROG_VARIANT.key()) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registry.FROG_VARIANT.key()) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registry.VILLAGER_PROFESSION.key()) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registry.VILLAGER_TYPE.key()) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registry.VILLAGER_TYPE.key()) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceKeyArgument.key(Registry.ATTRIBUTE.key()) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registry.ATTRIBUTE.key()) is FluidArgument -> ResourceKeyArgument.key(Registry.FLUID.key()) is SoundArgument -> ResourceKeyArgument.key(Registry.SOUND_EVENT.key()) - is BiomeArgument -> ResourceKeyArgument.key(Registry.BIOME_REGISTRY) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registry.BIOME_REGISTRY) is StructureArgument -> ResourceKeyArgument.key(Registry.STRUCTURE_REGISTRY) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> ResourceKeyArgument.key(Registry.PAINTING_VARIANT.key()) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registry.PAINTING_VARIANT.key()) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceKeyArgument.key(Registry.ENTITY_TYPE.key()) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registry.MEMORY_MODULE_TYPE.key()) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registry.MEMORY_MODULE_TYPE.key()) else -> throw UnsupportedArgumentException(argument) } @@ -184,95 +177,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment is GameModeArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registry.GAME_EVENT_REGISTRY)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registry.STRUCTURE_TYPE_REGISTRY)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registry.STRUCTURE_TYPE_REGISTRY)) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registry.FROG_VARIANT_REGISTRY)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registry.FROG_VARIANT_REGISTRY)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registry.VILLAGER_PROFESSION_REGISTRY)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registry.VILLAGER_TYPE_REGISTRY)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registry.VILLAGER_TYPE_REGISTRY)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registry.MENU_REGISTRY).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registry.ATTRIBUTE_REGISTRY)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registry.ATTRIBUTE_REGISTRY)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registry.FLUID_REGISTRY)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registry.SOUND_EVENT_REGISTRY)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registry.BIOME_REGISTRY)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registry.BIOME_REGISTRY)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registry.STRUCTURE_REGISTRY)) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registry.PAINTING_VARIANT_REGISTRY)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registry.PAINTING_VARIANT_REGISTRY)) is InstrumentArgument -> throwArgumentVersionException(argument) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registry.MEMORY_MODULE_TYPE_REGISTRY)) else -> throw UnsupportedArgumentException(argument) } } @@ -379,11 +372,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandAdapter.kt b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandAdapter.kt index 1a9d626..e2feaa2 100644 --- a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandAdapter.kt +++ b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandContextAdapter.kt b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandContextAdapter.kt index 7144c3f..becd5b4 100644 --- a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandContextAdapter.kt +++ b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandRegistrar.kt b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandRegistrar.kt index 68e1bdd..263fbe5 100644 --- a/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandRegistrar.kt +++ b/spigot/v1_19_2/src/main/kotlin/com/undefined/stellar/v1_19_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt index fb67f70..0c240a8 100644 --- a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt +++ b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,67 +109,67 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle( + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle( COMMAND_BUILD_CONTEXT ) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time() + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time() is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -186,95 +179,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> throwArgumentVersionException(argument) is TrimPatternArgument -> throwArgumentVersionException(argument) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> throwArgumentVersionException(argument) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -364,11 +357,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandAdapter.kt b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandAdapter.kt index f9e8ce6..a6fc41f 100644 --- a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandAdapter.kt +++ b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandContextAdapter.kt b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandContextAdapter.kt index 628d36a..13445bc 100644 --- a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandContextAdapter.kt +++ b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandRegistrar.kt b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandRegistrar.kt index d82b728..f1ac3aa 100644 --- a/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandRegistrar.kt +++ b/spigot/v1_19_3/src/main/kotlin/com/undefined/stellar/v1_19_3/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt index 37191b4..50e3d8e 100644 --- a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt +++ b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,67 +109,67 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle( + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle( COMMAND_BUILD_CONTEXT ) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> throwArgumentVersionException(argument) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> throwArgumentVersionException(argument) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> throwArgumentVersionException(argument) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -186,95 +179,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) // TODO PAPER has it is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> throwArgumentVersionException(argument) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -364,11 +357,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandAdapter.kt b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandAdapter.kt index ffffc3e..89bf960 100644 --- a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandAdapter.kt +++ b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandContextAdapter.kt b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandContextAdapter.kt index fc9c193..69c90f5 100644 --- a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandContextAdapter.kt +++ b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandRegistrar.kt b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandRegistrar.kt index 59b91cc..076e991 100644 --- a/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandRegistrar.kt +++ b/spigot/v1_19_4/src/main/kotlin/com/undefined/stellar/v1_19_4/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt index 2ac7946..2242856 100644 --- a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt +++ b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,65 +109,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -184,95 +177,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.toBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min ?: 1, range.max ?: 2) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -362,11 +355,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandAdapter.kt b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandAdapter.kt index 76435c4..7df09d3 100644 --- a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandAdapter.kt +++ b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandContextAdapter.kt b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandContextAdapter.kt index 150937e..72f9692 100644 --- a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandContextAdapter.kt +++ b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandRegistrar.kt b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandRegistrar.kt index a1a2756..9380f7e 100644 --- a/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandRegistrar.kt +++ b/spigot/v1_20_1/src/main/kotlin/com/undefined/stellar/v1_20_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt index 9c7b4db..c909586 100644 --- a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt +++ b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,65 +109,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> throwArgumentVersionException(argument) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -184,95 +177,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> throwArgumentVersionException(argument) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> throwArgumentVersionException(argument) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> throwArgumentVersionException(argument) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> throwArgumentVersionException(argument) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -362,11 +355,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandAdapter.kt b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandAdapter.kt index 363a716..944891a 100644 --- a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandAdapter.kt +++ b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandContextAdapter.kt b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandContextAdapter.kt index 66ad60e..b137ea2 100644 --- a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandContextAdapter.kt +++ b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandRegistrar.kt b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandRegistrar.kt index 2c3869a..4aaae73 100644 --- a/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandRegistrar.kt +++ b/spigot/v1_20_2/src/main/kotlin/com/undefined/stellar/v1_20_2/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt index aac6b55..82a5855 100644 --- a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt +++ b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument import net.minecraft.commands.arguments.coordinates.* @@ -103,12 +96,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -116,65 +109,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() - is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style() - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent() + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style() + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -184,95 +177,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - 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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> throwArgumentVersionException(argument) is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.structure.LootTableArgument -> throwArgumentVersionException(argument) is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> org.bukkit.Registry.EFFECT.get(getId(context, argument.name, Registries.MOB_EFFECT)) is BlockTypeArgument -> throwArgumentVersionException(argument) is ItemTypeArgument -> throwArgumentVersionException(argument) is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT)) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> throwArgumentVersionException(argument) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> throwArgumentVersionException(argument) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> org.bukkit.Registry.DAMAGE_TYPE.get(getId(context, argument.name, Registries.DAMAGE_TYPE)) is WolfVariantArgument -> throwArgumentVersionException(argument) is PatternTypeArgument -> org.bukkit.Registry.BANNER_PATTERN.get(getId(context, argument.name, Registries.BANNER_PATTERN)) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -363,11 +356,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt index fde8bd9..c9504a8 100644 --- a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt +++ b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt index b12f8f0..38c5c54 100644 --- a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt +++ b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt index 30fa3ce..22eef54 100644 --- a/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt +++ b/spigot/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt index 7bef977..c748bed 100644 --- a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt +++ b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -37,10 +33,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.ResourceOrIdArgument.LootTableArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument @@ -104,12 +97,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -117,65 +110,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> SlotsArgument.slots() is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> ResourceKeyArgument.key(Registries.WOLF_VARIANT) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -185,94 +178,94 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(getParsedArgument(context, argument.type)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize(getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize(getArgumentInput(context, argument.name) ?: return null).style() + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - 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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> SlotsArgument.getSlots(context, argument.name).slots().toList() is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> org.bukkit.Registry.EFFECT.get(getId(context, argument.name, Registries.MOB_EFFECT)) is BlockTypeArgument -> org.bukkit.Registry.BLOCK.get(getId(context, argument.name, Registries.BLOCK_TYPE)) is ItemTypeArgument -> org.bukkit.Registry.ITEM.get(getId(context, argument.name, Registries.ITEM)) is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT)) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> org.bukkit.Registry.DAMAGE_TYPE.get(getId(context, argument.name, Registries.DAMAGE_TYPE)) is WolfVariantArgument -> org.bukkit.Registry.WOLF_VARIANT.get(getId(context, argument.name, Registries.WOLF_VARIANT)) is PatternTypeArgument -> org.bukkit.Registry.BANNER_PATTERN.get(getId(context, argument.name, Registries.BANNER_PATTERN)) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -363,11 +356,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt index 75c8ceb..6b699d9 100644 --- a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt +++ b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt index b0f3537..db4dd1d 100644 --- a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt +++ b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt index 8ae1012..fe7fa3b 100644 --- a/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt +++ b/spigot/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt index 068d756..7a19d2f 100644 --- a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt +++ b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -35,10 +31,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.ResourceOrIdArgument.LootTableArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument @@ -102,12 +95,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -115,65 +108,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> SlotsArgument.slots() is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> ResourceKeyArgument.key(Registries.WOLF_VARIANT) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -183,95 +176,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - 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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> SlotsArgument.getSlots(context, argument.name).slots().toList() is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> org.bukkit.Registry.EFFECT.get(getId(context, argument.name, Registries.MOB_EFFECT)) is BlockTypeArgument -> org.bukkit.Registry.BLOCK.get(getId(context, argument.name, Registries.BLOCK_TYPE)) is ItemTypeArgument -> org.bukkit.Registry.ITEM.get(getId(context, argument.name, Registries.ITEM)) is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT)) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> org.bukkit.Registry.DAMAGE_TYPE.get(getId(context, argument.name, Registries.DAMAGE_TYPE)) is WolfVariantArgument -> org.bukkit.Registry.WOLF_VARIANT.get(getId(context, argument.name, Registries.WOLF_VARIANT)) is PatternTypeArgument -> org.bukkit.Registry.BANNER_PATTERN.get(getId(context, argument.name, Registries.BANNER_PATTERN)) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -364,11 +357,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandAdapter.kt b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandAdapter.kt index ee734fb..74f6958 100644 --- a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandAdapter.kt +++ b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandContextAdapter.kt b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandContextAdapter.kt index f0a1ca7..b3c5fe5 100644 --- a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandContextAdapter.kt +++ b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandRegistrar.kt b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandRegistrar.kt index 827a5cf..341b179 100644 --- a/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandRegistrar.kt +++ b/spigot/v1_21_1/src/main/kotlin/com/undefined/stellar/v1_21_1/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt index 39b234c..bf843ca 100644 --- a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt +++ b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -35,10 +31,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.ResourceOrIdArgument.LootTableArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument @@ -102,12 +95,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -115,65 +108,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> SlotsArgument.slots() is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> ResourceKeyArgument.key(Registries.WOLF_VARIANT) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -183,95 +176,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) - 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 com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name).scoreboardName + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> SlotsArgument.getSlots(context, argument.name).slots().toList() is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> org.bukkit.Registry.EFFECT.get(getId(context, argument.name, Registries.MOB_EFFECT)) is BlockTypeArgument -> org.bukkit.Registry.BLOCK.get(getId(context, argument.name, Registries.BLOCK_TYPE)) is ItemTypeArgument -> org.bukkit.Registry.ITEM.get(getId(context, argument.name, Registries.ITEM)) is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT)) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> org.bukkit.Registry.DAMAGE_TYPE.get(getId(context, argument.name, Registries.DAMAGE_TYPE)) is WolfVariantArgument -> org.bukkit.Registry.WOLF_VARIANT.get(getId(context, argument.name, Registries.WOLF_VARIANT)) is PatternTypeArgument -> org.bukkit.Registry.BANNER_PATTERN.get(getId(context, argument.name, Registries.BANNER_PATTERN)) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -364,11 +357,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandAdapter.kt b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandAdapter.kt index 59d9e94..ab6c621 100644 --- a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandAdapter.kt +++ b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandContextAdapter.kt b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandContextAdapter.kt index bfed9ed..d75d20a 100644 --- a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandContextAdapter.kt +++ b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandRegistrar.kt b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandRegistrar.kt index 708ebbf..7649fae 100644 --- a/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandRegistrar.kt +++ b/spigot/v1_21_3/src/main/kotlin/com/undefined/stellar/v1_21_3/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context) diff --git a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt index 301066a..8ca5819 100644 --- a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt +++ b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/ArgumentHelper.kt @@ -11,21 +11,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.block.BlockDataArgument -import com.undefined.stellar.argument.types.custom.CustomArgument -import com.undefined.stellar.argument.types.custom.ListArgument -import com.undefined.stellar.argument.types.entity.* -import com.undefined.stellar.argument.types.item.* -import com.undefined.stellar.argument.types.math.AxisArgument -import com.undefined.stellar.argument.types.misc.NamespacedKeyArgument -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.ScoreHolderType -import com.undefined.stellar.argument.types.structure.MirrorArgument -import com.undefined.stellar.argument.types.structure.StructureRotationArgument -import com.undefined.stellar.argument.types.world.* +import com.undefined.stellar.argument.block.BlockDataArgument +import com.undefined.stellar.argument.custom.CustomArgument +import com.undefined.stellar.argument.custom.ListArgument +import com.undefined.stellar.argument.entity.* +import com.undefined.stellar.argument.item.* +import com.undefined.stellar.argument.misc.NamespacedKeyArgument +import com.undefined.stellar.argument.misc.UUIDArgument +import com.undefined.stellar.argument.primitive.* +import com.undefined.stellar.argument.registry.* +import com.undefined.stellar.argument.structure.MirrorArgument +import com.undefined.stellar.argument.world.* import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.argument.ParticleData @@ -35,10 +31,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.commands.CommandBuildContext import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.* -import net.minecraft.commands.arguments.DimensionArgument import net.minecraft.commands.arguments.EntityAnchorArgument -import net.minecraft.commands.arguments.EntityArgument -import net.minecraft.commands.arguments.ParticleArgument import net.minecraft.commands.arguments.ResourceOrIdArgument.LootTableArgument import net.minecraft.commands.arguments.blocks.BlockPredicateArgument import net.minecraft.commands.arguments.blocks.BlockStateArgument @@ -102,12 +95,12 @@ object ArgumentHelper { is StringArgument -> brigadier(argument.type) is PhraseArgument -> brigadier(StringType.PHRASE) is IntegerArgument -> IntegerArgumentType.integer(argument.min, argument.max) - is LongArgument -> LongArgumentType.longArg(argument.min, argument.max) - is FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.longArg(argument.min, argument.max) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.floatArg(argument.min, argument.max) is DoubleArgument -> DoubleArgumentType.doubleArg(argument.min, argument.max) is BooleanArgument -> BoolArgumentType.bool() - is com.undefined.stellar.argument.types.entity.EntityArgument -> brigadier(argument.type) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.gameProfile() + is com.undefined.stellar.argument.entity.EntityArgument -> brigadier(argument.type) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.gameProfile() is LocationArgument -> when (argument.type) { LocationType.LOCATION_3D -> BlockPosArgument.blockPos() LocationType.LOCATION_2D -> ColumnPosArgument.columnPos() @@ -115,65 +108,65 @@ object ArgumentHelper { 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.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.text.ColorArgument -> ColorArgument.color() - is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.text.MessageArgument -> MessageArgument.message() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() - is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) - 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 -> when (argument.type) { - ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() - ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() + is com.undefined.stellar.argument.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.ColorArgument -> ColorArgument.color() + is com.undefined.stellar.argument.text.ComponentArgument -> ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.StyleArgument -> StyleArgument.style(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.text.MessageArgument -> MessageArgument.message() + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() + is com.undefined.stellar.argument.math.OperationArgument -> OperationArgument.operation() + is com.undefined.stellar.argument.world.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.angle() + is com.undefined.stellar.argument.math.RotationArgument -> RotationArgument.rotation() + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.scoreHolder() + com.undefined.stellar.argument.scoreboard.ScoreHolderType.MULTIPLE -> ScoreHolderArgument.scoreHolders() } - is AxisArgument -> SwizzleArgument.swizzle() - is com.undefined.stellar.argument.types.scoreboard.TeamArgument -> TeamArgument.team() + is com.undefined.stellar.argument.math.AxisArgument -> SwizzleArgument.swizzle() + is com.undefined.stellar.argument.scoreboard.TeamArgument -> TeamArgument.team() is ItemSlotArgument -> SlotArgument.slot() is ItemSlotsArgument -> SlotsArgument.slots() is NamespacedKeyArgument -> ResourceLocationArgument.id() - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() - is com.undefined.stellar.argument.types.math.RangeArgument -> RangeArgument.intRange() - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.dimension() - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameModeArgument.gameMode() - is com.undefined.stellar.argument.types.math.TimeArgument -> TimeArgument.time(argument.minimum) + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> EntityAnchorArgument.anchor() + is com.undefined.stellar.argument.math.RangeArgument -> RangeArgument.intRange() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.dimension() + is com.undefined.stellar.argument.player.GameModeArgument -> GameModeArgument.gameMode() + is com.undefined.stellar.argument.math.TimeArgument -> TimeArgument.time(argument.minimum) is MirrorArgument -> TemplateMirrorArgument.templateMirror() - is StructureRotationArgument -> TemplateRotationArgument.templateRotation() + is com.undefined.stellar.argument.structure.StructureRotationArgument -> TemplateRotationArgument.templateRotation() is HeightMapArgument -> HeightmapTypeArgument.heightmap() - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.lootTable(COMMAND_BUILD_CONTEXT) is UUIDArgument -> UuidArgument.uuid() is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT) - is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE) is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT) is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE) is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM) is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT) - is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT) is VillagerProfessionArgument -> ResourceKeyArgument.key(Registries.VILLAGER_PROFESSION) - is VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) - is MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> ResourceKeyArgument.key(Registries.VILLAGER_TYPE) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> ResourceKeyArgument.key(Registries.MAP_DECORATION_TYPE) is InventoryTypeArgument -> ResourceKeyArgument.key(Registries.MENU) - is AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) + is com.undefined.stellar.argument.registry.AttributeArgument -> ResourceKeyArgument.key(Registries.ATTRIBUTE) is FluidArgument -> ResourceKeyArgument.key(Registries.FLUID) is SoundArgument -> ResourceKeyArgument.key(Registries.SOUND_EVENT) - is BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) + is com.undefined.stellar.argument.registry.BiomeArgument -> ResourceKeyArgument.key(Registries.BIOME) is StructureArgument -> ResourceKeyArgument.key(Registries.STRUCTURE) is TrimMaterialArgument -> ResourceKeyArgument.key(Registries.TRIM_MATERIAL) is TrimPatternArgument -> ResourceKeyArgument.key(Registries.TRIM_PATTERN) is DamageTypeArgument -> ResourceKeyArgument.key(Registries.DAMAGE_TYPE) is WolfVariantArgument -> ResourceKeyArgument.key(Registries.WOLF_VARIANT) is PatternTypeArgument -> ResourceKeyArgument.key(Registries.BANNER_PATTERN) - is ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) + is com.undefined.stellar.argument.registry.ArtArgument -> ResourceKeyArgument.key(Registries.PAINTING_VARIANT) is InstrumentArgument -> ResourceKeyArgument.key(Registries.INSTRUMENT) is EntityTypeArgument -> ResourceKeyArgument.key(Registries.ENTITY_TYPE) is PotionArgument -> ResourceKeyArgument.key(Registries.POTION) - is MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> ResourceKeyArgument.key(Registries.MEMORY_MODULE_TYPE) else -> throw UnsupportedArgumentException(argument) } @@ -183,95 +176,95 @@ object ArgumentHelper { is CustomArgument<*> -> argument.parse(CommandContextAdapter.getStellarCommandContext(context)) is StringArgument -> StringArgumentType.getString(context, argument.name) is IntegerArgument -> IntegerArgumentType.getInteger(context, argument.name) - is LongArgument -> LongArgumentType.getLong(context, argument.name) - is FloatArgument -> FloatArgumentType.getFloat(context, argument.name) + is com.undefined.stellar.argument.primitive.LongArgument -> LongArgumentType.getLong(context, argument.name) + is com.undefined.stellar.argument.primitive.FloatArgument -> FloatArgumentType.getFloat(context, argument.name) is DoubleArgument -> DoubleArgumentType.getDouble(context, argument.name) is BooleanArgument -> BoolArgumentType.getBool(context, argument.name) is ListArgument<*> -> argument.parse(StringArgumentType.getString(context, argument.name)) - is com.undefined.stellar.argument.types.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) + is com.undefined.stellar.argument.entity.EntityArgument -> EntityArgument.getEntities(context, argument.name) .map { it.bukkitEntity }.toMutableList() .addAll(listOf(EntityArgument.getEntity(context, argument.name).bukkitEntity)) - is com.undefined.stellar.argument.types.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) + is com.undefined.stellar.argument.player.GameProfileArgument -> GameProfileArgument.getGameProfiles(context, argument.name) is LocationArgument -> getLocation(context, argument) is BlockDataArgument -> CraftBlockData.fromData(BlockStateArgument.getBlock(context, argument.name).state) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> Predicate { block: Block -> + is com.undefined.stellar.argument.block.BlockPredicateArgument -> Predicate { block: Block -> BlockPredicateArgument.getBlockPredicate(context, argument.name).test(BlockInWorld( context.source.level, BlockPos(block.x, block.y, block.z), true )) } - is com.undefined.stellar.argument.types.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> Predicate { item: ItemStack -> + is com.undefined.stellar.argument.item.ItemArgument -> CraftItemStack.asBukkitCopy(ItemArgument.getItem(context, argument.name).createItemStack(1, false)) + is com.undefined.stellar.argument.item.ItemPredicateArgument -> Predicate { item: ItemStack -> ItemPredicateArgument.getItemPredicate(context, argument.name).test(CraftItemStack.asNMSCopy(item)) } - is com.undefined.stellar.argument.types.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) - is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + is com.undefined.stellar.argument.text.ColorArgument -> ChatColor.getByChar(ColorArgument.getColor(context, argument.name).char) + is com.undefined.stellar.argument.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( getArgumentInput(context, argument.name) ?: return null).style() - is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) - is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name - is com.undefined.stellar.argument.types.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.world.ParticleArgument -> { + is com.undefined.stellar.argument.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name), COMMAND_BUILD_CONTEXT)) + is com.undefined.stellar.argument.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) + is com.undefined.stellar.argument.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name + is com.undefined.stellar.argument.math.OperationArgument -> Operation.getOperation(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.world.ParticleArgument -> { val particleOptions = ParticleArgument.getParticle(context, argument.name) getParticleData(context, CraftParticle.minecraftToBukkit(particleOptions.type), particleOptions) } - is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) - is com.undefined.stellar.argument.types.math.RotationArgument -> { + is com.undefined.stellar.argument.math.AngleArgument -> AngleArgument.getAngle(context, argument.name) + is com.undefined.stellar.argument.math.RotationArgument -> { val coordinates = RotationArgument.getRotation(context, argument.name) val position = coordinates.getPosition(context.source) val rotation = coordinates.getRotation(context.source) Location(context.source.level.world, position.x, position.y, position.z, rotation.x, rotation.y) } - is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(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).map { it.scoreboardName } + is com.undefined.stellar.argument.scoreboard.DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.ScoreHolderArgument -> when (argument.type) { + com.undefined.stellar.argument.scoreboard.ScoreHolderType.SINGLE -> ScoreHolderArgument.getName(context, argument.name) + com.undefined.stellar.argument.scoreboard.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 com.undefined.stellar.argument.math.AxisArgument -> getBukkitAxis(SwizzleArgument.getSwizzle(context, argument.name)) + is com.undefined.stellar.argument.scoreboard.TeamArgument -> Bukkit.getScoreboardManager()!!.mainScoreboard.getTeam(TeamArgument.getTeam(context, argument.name).name) is ItemSlotArgument -> SlotArgument.getSlot(context, argument.name) is ItemSlotsArgument -> SlotsArgument.getSlots(context, argument.name).slots().toList() is NamespacedKeyArgument -> NamespacedKey(ResourceLocationArgument.getId(context, argument.name).namespace, ResourceLocationArgument.getId(context, argument.name).path) - is com.undefined.stellar.argument.types.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) - is com.undefined.stellar.argument.types.math.RangeArgument -> { + is com.undefined.stellar.argument.entity.EntityAnchorArgument -> Anchor.getFromName(getArgumentInput(context, argument.name) ?: return null) + is com.undefined.stellar.argument.math.RangeArgument -> { val range = RangeArgument.Ints.getRange(context, argument.name) IntRange(range.min.orElse(1), range.max.orElse(2)) } - is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment - is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) - is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() + is com.undefined.stellar.argument.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment + is com.undefined.stellar.argument.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id) + is com.undefined.stellar.argument.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong() is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name) - is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) + is com.undefined.stellar.argument.structure.StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name) is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name) - is com.undefined.stellar.argument.types.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable + is com.undefined.stellar.argument.structure.LootTableArgument -> LootTableArgument.getLootTable(context, argument.name).value().craftLootTable is UUIDArgument -> UuidArgument.getUuid(context, argument.name) is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT)) - is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) + is com.undefined.stellar.argument.registry.StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE)) is PotionEffectTypeArgument -> org.bukkit.Registry.EFFECT.get(getId(context, argument.name, Registries.MOB_EFFECT)) is BlockTypeArgument -> org.bukkit.Registry.BLOCK.get(getId(context, argument.name, Registries.BLOCK_TYPE)) is ItemTypeArgument -> org.bukkit.Registry.ITEM.get(getId(context, argument.name, Registries.ITEM)) is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT)) - is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) + is com.undefined.stellar.argument.registry.FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT)) is VillagerProfessionArgument -> org.bukkit.Registry.VILLAGER_PROFESSION.get(getId(context, argument.name, Registries.VILLAGER_PROFESSION)) - is VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) - is MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) + is com.undefined.stellar.argument.registry.VillagerTypeArgument -> org.bukkit.Registry.VILLAGER_TYPE.get(getId(context, argument.name, Registries.VILLAGER_TYPE)) + is com.undefined.stellar.argument.registry.MapDecorationTypeArgument -> org.bukkit.Registry.MAP_DECORATION_TYPE.get(getId(context, argument.name, Registries.MAP_DECORATION_TYPE)) is InventoryTypeArgument -> getInventoryType(resolveKey(context, argument.name, Registries.MENU).value()) - is AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) + is com.undefined.stellar.argument.registry.AttributeArgument -> org.bukkit.Registry.ATTRIBUTE.get(getId(context, argument.name, Registries.ATTRIBUTE)) is FluidArgument -> org.bukkit.Registry.FLUID.get(getId(context, argument.name, Registries.FLUID)) is SoundArgument -> org.bukkit.Registry.SOUNDS.get(getId(context, argument.name, Registries.SOUND_EVENT)) - is BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) + is com.undefined.stellar.argument.registry.BiomeArgument -> org.bukkit.Registry.BIOME.get(getId(context, argument.name, Registries.BIOME)) is StructureArgument -> org.bukkit.Registry.STRUCTURE.get(getId(context, argument.name, Registries.STRUCTURE)) is TrimMaterialArgument -> org.bukkit.Registry.TRIM_MATERIAL.get(getId(context, argument.name, Registries.TRIM_MATERIAL)) is TrimPatternArgument -> org.bukkit.Registry.TRIM_PATTERN.get(getId(context, argument.name, Registries.TRIM_PATTERN)) is DamageTypeArgument -> org.bukkit.Registry.DAMAGE_TYPE.get(getId(context, argument.name, Registries.DAMAGE_TYPE)) is WolfVariantArgument -> org.bukkit.Registry.WOLF_VARIANT.get(getId(context, argument.name, Registries.WOLF_VARIANT)) is PatternTypeArgument -> org.bukkit.Registry.BANNER_PATTERN.get(getId(context, argument.name, Registries.BANNER_PATTERN)) - is ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) + is com.undefined.stellar.argument.registry.ArtArgument -> org.bukkit.Registry.ART.get(getId(context, argument.name, Registries.PAINTING_VARIANT)) is InstrumentArgument -> org.bukkit.Registry.INSTRUMENT.get(getId(context, argument.name, Registries.INSTRUMENT)) 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)) + is com.undefined.stellar.argument.registry.MemoryKeyArgument -> org.bukkit.Registry.MEMORY_MODULE_TYPE.get(getId(context, argument.name, Registries.MEMORY_MODULE_TYPE)) else -> throw UnsupportedArgumentException(argument) } } @@ -364,11 +357,11 @@ object ArgumentHelper { StringType.PHRASE -> StringArgumentType.greedyString() } - private fun brigadier(type: EntityDisplayType): EntityArgument = when (type) { - EntityDisplayType.ENTITY -> EntityArgument.entity() - EntityDisplayType.ENTITIES -> EntityArgument.entities() - EntityDisplayType.PLAYER -> EntityArgument.player() - EntityDisplayType.PLAYERS -> EntityArgument.players() + private fun brigadier(type: com.undefined.stellar.argument.entity.EntityDisplayType): EntityArgument = when (type) { + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITY -> EntityArgument.entity() + com.undefined.stellar.argument.entity.EntityDisplayType.ENTITIES -> EntityArgument.entities() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYER -> EntityArgument.player() + com.undefined.stellar.argument.entity.EntityDisplayType.PLAYERS -> EntityArgument.players() } private fun getBukkitAxis(argument: EnumSet): EnumSet = diff --git a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt index 7c0b845..e2f2104 100644 --- a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt +++ b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandAdapter.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.primitive.PhraseArgument +import com.undefined.stellar.argument.primitive.PhraseArgument import com.undefined.stellar.data.suggestion.Suggestion import net.minecraft.commands.CommandSourceStack import org.bukkit.Bukkit diff --git a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt index 02cda1c..c391a08 100644 --- a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt +++ b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandContextAdapter.kt @@ -5,7 +5,7 @@ import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.argument.AbstractStellarArgument import com.undefined.stellar.argument.LiteralStellarArgument -import com.undefined.stellar.argument.types.custom.CustomArgument +import com.undefined.stellar.argument.custom.CustomArgument import com.undefined.stellar.data.argument.CommandNode import com.undefined.stellar.data.argument.PhraseCommandContext import com.undefined.stellar.exception.DuplicateArgumentNameException diff --git a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt index 9e05a96..52a5c71 100644 --- a/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt +++ b/spigot/v1_21_4/src/main/kotlin/com/undefined/stellar/v1_21_4/CommandRegistrar.kt @@ -25,7 +25,7 @@ object CommandRegistrar : AbstractCommandRegistrar { if (results.reader.remainingLength == 0) return false if (context.nodes.isEmpty()) return false - val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name)!! + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(context.nodes[0].node.name) ?: return false val argument = BrigadierCommandHelper.getArguments(baseCommand, context).lastOrNull() argument?.let { BrigadierCommandHelper.handleFailureMessageAndExecutions(argument, context)