├── FunctionAnalyser
├── .gitignore
├── AdvancedText
│ ├── AdvancedText.csproj
│ ├── Colour.cs
│ ├── ILogger.cs
│ └── TextComponent.cs
├── CommandParser
│ ├── Arguments
│ │ ├── AdvancementArgument.cs
│ │ ├── AngleArgument.cs
│ │ ├── AttributeArgument.cs
│ │ ├── BiomeArgument.cs
│ │ ├── BlockArgument.cs
│ │ ├── BlockPosArgument.cs
│ │ ├── BooleanArgument.cs
│ │ ├── BossbarArgument.cs
│ │ ├── ColourArgument.cs
│ │ ├── ColumnPosArgument.cs
│ │ ├── ComponentArgument.cs
│ │ ├── CompoundTagArgument.cs
│ │ ├── DimensionArgument.cs
│ │ ├── DoubleArgument.cs
│ │ ├── DoubleRangeArgument.cs
│ │ ├── EntityAnchorArgument.cs
│ │ ├── EntityArgument.cs
│ │ ├── EntitySummonArgument.cs
│ │ ├── FloatArgument.cs
│ │ ├── FloatRangeArgument.cs
│ │ ├── FunctionArgument.cs
│ │ ├── GamemodeArgument.cs
│ │ ├── IArgument.cs
│ │ ├── IntegerArgument.cs
│ │ ├── IntegerRangeArgument.cs
│ │ ├── ItemArgument.cs
│ │ ├── ItemComponentArgument.cs
│ │ ├── ItemEnchantmentArgument.cs
│ │ ├── ItemModifierArgument.cs
│ │ ├── ItemSlotArgument.cs
│ │ ├── LongArgument.cs
│ │ ├── LootTableArgument.cs
│ │ ├── MessageArgument.cs
│ │ ├── MobEffectArgument.cs
│ │ ├── NbtPathArgument.cs
│ │ ├── NbtTagArgument.cs
│ │ ├── ObjectiveArgument.cs
│ │ ├── ObjectiveCriterionArgument.cs
│ │ ├── OperationArgument.cs
│ │ ├── ParticleArgument.cs
│ │ ├── PredicateArgument.cs
│ │ ├── RecipeArgument.cs
│ │ ├── ResourceLocationArgument.cs
│ │ ├── RotationArgument.cs
│ │ ├── ScoreHolderArgument.cs
│ │ ├── ScoreboardSlotArgument.cs
│ │ ├── SoundArgument.cs
│ │ ├── StorageArgument.cs
│ │ ├── StringArgument.cs
│ │ ├── StructureMirrorArgument.cs
│ │ ├── StructureRotationArgument.cs
│ │ ├── SwizzleArgument.cs
│ │ ├── TeamArgument.cs
│ │ ├── TimeArgument.cs
│ │ ├── UuidArgument.cs
│ │ ├── Vec2Argument.cs
│ │ └── Vec3Argument.cs
│ ├── BedrockStringReader.cs
│ ├── Collections
│ │ ├── Anchors.cs
│ │ ├── BlockState.cs
│ │ ├── Blocks.cs
│ │ ├── Colours.cs
│ │ ├── Components.cs
│ │ ├── Enchantments.cs
│ │ ├── Entities.cs
│ │ ├── EntitySelectorOption.cs
│ │ ├── EntitySelectorOptions.cs
│ │ ├── Gamemodes.cs
│ │ ├── ItemSlots.cs
│ │ ├── Items.cs
│ │ ├── MobEffects.cs
│ │ ├── ObjectiveCriteria.cs
│ │ ├── ObjectiveCriterion.cs
│ │ ├── Operations.cs
│ │ ├── Particles.cs
│ │ ├── ScoreboardSlot.cs
│ │ ├── ScoreboardSlots.cs
│ │ ├── Sorts.cs
│ │ ├── StructureMirrors.cs
│ │ ├── StructureRotations.cs
│ │ └── TimeScalars.cs
│ ├── CommandError.cs
│ ├── CommandParser.csproj
│ ├── Context
│ │ ├── CommandContext.cs
│ │ ├── ParsedArgument.cs
│ │ └── Range.cs
│ ├── Converters
│ │ ├── AbstractJsonConverter.cs
│ │ ├── ComponentConverter.cs
│ │ ├── NodeContainerConverter.cs
│ │ └── NodeConverter.cs
│ ├── Dispatcher.cs
│ ├── DispatcherResources.cs
│ ├── IStringReader.cs
│ ├── Minecraft
│ │ ├── Coordinates
│ │ │ ├── Angle.cs
│ │ │ ├── ICoordinates.cs
│ │ │ ├── LocalCoordinates.cs
│ │ │ ├── Rotation.cs
│ │ │ ├── WorldCoordinate.cs
│ │ │ └── WorldCoordinates.cs
│ │ ├── GameType.cs
│ │ ├── Nbt
│ │ │ ├── NbtParser.cs
│ │ │ ├── NbtUtilities.cs
│ │ │ ├── Path
│ │ │ │ └── NbtPath.cs
│ │ │ └── Tags
│ │ │ │ ├── ByteArrayNbtTag.cs
│ │ │ │ ├── ByteNbtTag.cs
│ │ │ │ ├── CompoundNbtTag.cs
│ │ │ │ ├── DoubleNbtTag.cs
│ │ │ │ ├── FloatNbtTag.cs
│ │ │ │ ├── INbtCollectionTag.cs
│ │ │ │ ├── INbtTag.cs
│ │ │ │ ├── IntegerArrayNbtTag.cs
│ │ │ │ ├── IntegerNbtTag.cs
│ │ │ │ ├── ListNbtTag.cs
│ │ │ │ ├── LongArrayNbtTag.cs
│ │ │ │ ├── LongNbtTag.cs
│ │ │ │ ├── ShortNbtTag.cs
│ │ │ │ └── StringNbtTag.cs
│ │ └── ResourceLocation.cs
│ ├── Parsers
│ │ ├── BlockParser.cs
│ │ ├── ComponentParser
│ │ │ ├── ComponentArguments
│ │ │ │ ├── ComponentAny.cs
│ │ │ │ ├── ComponentArgument.cs
│ │ │ │ ├── ComponentArray.cs
│ │ │ │ ├── ComponentArrayOrRoot.cs
│ │ │ │ ├── ComponentBinding.cs
│ │ │ │ ├── ComponentNumber.cs
│ │ │ │ ├── ComponentObject.cs
│ │ │ │ ├── ComponentResourceLocation.cs
│ │ │ │ ├── ComponentRoot.cs
│ │ │ │ ├── ComponentRootObject.cs
│ │ │ │ ├── ComponentString.cs
│ │ │ │ └── ComponentUuid.cs
│ │ │ ├── ComponentCommandError.cs
│ │ │ └── ComponentReader.cs
│ │ ├── Coordinates
│ │ │ ├── AngleParser.cs
│ │ │ ├── LocalCoordinatesParser.cs
│ │ │ ├── RotationParser.cs
│ │ │ ├── WorldCoordinateParser.cs
│ │ │ └── WorldCoordinatesParser.cs
│ │ ├── EntitySelectorParser.cs
│ │ ├── ItemParser.cs
│ │ ├── JsonParser
│ │ │ ├── JsonArgumentType.cs
│ │ │ ├── JsonArguments
│ │ │ │ ├── IJsonArgument.cs
│ │ │ │ ├── JsonArray.cs
│ │ │ │ ├── JsonBoolean.cs
│ │ │ │ ├── JsonNull.cs
│ │ │ │ ├── JsonNumber.cs
│ │ │ │ ├── JsonObject.cs
│ │ │ │ └── JsonString.cs
│ │ │ ├── JsonCharacterProvider.cs
│ │ │ ├── JsonCommandError.cs
│ │ │ └── JsonReader.cs
│ │ ├── ObjectiveCriterionParser.cs
│ │ ├── RangeParser.cs
│ │ └── ScoreboardSlotParser.cs
│ ├── Providers
│ │ ├── NodeBuilder.cs
│ │ └── NumberProvider.cs
│ ├── Results
│ │ ├── Arguments
│ │ │ ├── Advancement.cs
│ │ │ ├── Anchor.cs
│ │ │ ├── Attribute.cs
│ │ │ ├── Biome.cs
│ │ │ ├── Block.cs
│ │ │ ├── Bossbar.cs
│ │ │ ├── Colour.cs
│ │ │ ├── Component.cs
│ │ │ ├── Dimension.cs
│ │ │ ├── Enchantment.cs
│ │ │ ├── Entity.cs
│ │ │ ├── EntitySelector.cs
│ │ │ ├── Function.cs
│ │ │ ├── Item.cs
│ │ │ ├── ItemComponent.cs
│ │ │ ├── ItemModifier.cs
│ │ │ ├── ItemSlot.cs
│ │ │ ├── Literal.cs
│ │ │ ├── LootTable.cs
│ │ │ ├── Message.cs
│ │ │ ├── MobEffect.cs
│ │ │ ├── Objective.cs
│ │ │ ├── ObjectiveCriterion.cs
│ │ │ ├── Operation.cs
│ │ │ ├── Particle.cs
│ │ │ ├── Predicate.cs
│ │ │ ├── Range.cs
│ │ │ ├── Recipe.cs
│ │ │ ├── ScoreHolder.cs
│ │ │ ├── ScoreboardSlot.cs
│ │ │ ├── Sound.cs
│ │ │ ├── Storage.cs
│ │ │ ├── StructureMirror.cs
│ │ │ ├── StructureRotation.cs
│ │ │ ├── Team.cs
│ │ │ └── Time.cs
│ │ ├── CommandResults.cs
│ │ ├── ParseResults.cs
│ │ └── ReadResults.cs
│ ├── StringReader.cs
│ └── Tree
│ │ ├── ArgumentNode.cs
│ │ ├── LiteralNode.cs
│ │ ├── Node.cs
│ │ └── RootNode.cs
├── ErrorCraft.CommandParser.Tests
│ ├── ErrorCraft.CommandParser.Tests.csproj
│ └── StringReaderTests.cs
├── ErrorCraft.CommandParser
│ ├── ErrorCraft.CommandParser.csproj
│ ├── IStringReader.cs
│ └── StringReader.cs
├── ErrorCraft.FunctionAnalyser.UI.Avalonia
│ ├── .gitignore
│ ├── App.axaml
│ ├── App.axaml.cs
│ ├── Assets
│ │ └── avalonia-logo.ico
│ ├── AvaloniaLogger.cs
│ ├── Controls
│ │ ├── BorderedPanel.axaml
│ │ └── BorderedPanel.axaml.cs
│ ├── ErrorCraft.FunctionAnalyser.UI.Avalonia.csproj
│ ├── Program.cs
│ ├── ViewLocator.cs
│ ├── ViewModels
│ │ ├── MainWindowViewModel.cs
│ │ └── ViewModelBase.cs
│ └── Views
│ │ ├── MainWindow.axaml
│ │ └── MainWindow.axaml.cs
├── FunctionAnalyser.sln
├── FunctionAnalyser
│ ├── Builders
│ │ ├── Collections
│ │ │ ├── AnchorsBuilder.cs
│ │ │ ├── BlocksBuilder.cs
│ │ │ ├── ColoursBuilder.cs
│ │ │ ├── CommandsBuilder.cs
│ │ │ ├── ComponentsBuilder.cs
│ │ │ ├── EnchantmentsBuilder.cs
│ │ │ ├── EntitiesBuilder.cs
│ │ │ ├── GamemodesBuilder.cs
│ │ │ ├── IBuilder.cs
│ │ │ ├── ItemSlotsBuilder.cs
│ │ │ ├── ItemsBuilder.cs
│ │ │ ├── MobEffectsBuilder.cs
│ │ │ ├── ObjectiveCriteriaBuilder.cs
│ │ │ ├── OperationsBuilder.cs
│ │ │ ├── ParticlesBuilder.cs
│ │ │ ├── ScoreboardSlotsBuilder.cs
│ │ │ ├── SelectorArgumentsBuilder.cs
│ │ │ ├── SortsBuilder.cs
│ │ │ ├── StructureMirrorsBuilder.cs
│ │ │ ├── StructureRotationsBuilder.cs
│ │ │ └── TimeScalarsBuilder.cs
│ │ ├── Definitions.cs
│ │ ├── DispatcherResourcesBuilder.cs
│ │ ├── ResourceBuilder.cs
│ │ ├── ResponseException.cs
│ │ └── Versions
│ │ │ ├── VersionResourceKeys.cs
│ │ │ ├── VersionResources.cs
│ │ │ └── VersionsBuilder.cs
│ ├── FunctionAnalyser.csproj
│ ├── FunctionData.cs
│ ├── FunctionOptions.cs
│ ├── FunctionProgress.cs
│ ├── FunctionReader.cs
│ ├── MessageProvider.cs
│ ├── Results
│ │ ├── Command.cs
│ │ ├── CommandUsage.cs
│ │ ├── IResult.cs
│ │ ├── SelectorCount.cs
│ │ ├── SelectorResult.cs
│ │ ├── SimpleResult.cs
│ │ └── SortType.cs
│ └── VersionName.cs
├── ProgramUpdater
│ ├── Assets.cs
│ ├── Converters
│ │ └── TagNameConverter.cs
│ ├── ProgramUpdater.csproj
│ ├── Update.cs
│ ├── Updater.cs
│ └── Version.cs
├── Tests
│ ├── Arguments
│ │ ├── AdvancementArgumentTests.cs
│ │ ├── AngleArgumentTests.cs
│ │ ├── AttributeArgumentTests.cs
│ │ ├── BiomeArgumentTests.cs
│ │ ├── BlockArgumentTests.cs
│ │ ├── BlockPosArgumentTests.cs
│ │ ├── BooleanArgumentTests.cs
│ │ ├── BossbarArgumentTests.cs
│ │ ├── ColourArgumentTests.cs
│ │ ├── ColumnPosArgumentTests.cs
│ │ ├── ComponentArgumentTests.cs
│ │ ├── CompoundTagArgumentTests.cs
│ │ ├── DimensionArgumentTests.cs
│ │ ├── DoubleArgumentTests.cs
│ │ ├── DoubleRangeArgumentTests.cs
│ │ ├── EntityAnchorArgumentTests.cs
│ │ ├── EntityArgumentTests.cs
│ │ ├── EntitySummonArgumentTests.cs
│ │ ├── FloatArgumentTests.cs
│ │ ├── FloatRangeArgumentTests.cs
│ │ ├── FunctionArgumentTests.cs
│ │ ├── IntegerArgumentTests.cs
│ │ ├── IntegerRangeArgumentTests.cs
│ │ ├── ItemArgumentTests.cs
│ │ ├── ItemEnchantmentArgumentTests.cs
│ │ ├── ItemModifierArgumentTests.cs
│ │ ├── ItemSlotArgumentTests.cs
│ │ ├── LongArgumentTests.cs
│ │ ├── LootTableArgumentTests.cs
│ │ ├── MessageArgumentTests.cs
│ │ ├── MobEffectArgumentTests.cs
│ │ ├── NbtPathArgumentTests.cs
│ │ ├── NbtTagArgumentTests.cs
│ │ ├── ObjectiveArgumentTests.cs
│ │ ├── ObjectiveCriterionArgumentTests.cs
│ │ ├── OperationArgumentTests.cs
│ │ ├── ParticleArgumentTests.cs
│ │ ├── PredicateArgumentTests.cs
│ │ ├── RecipeArgumentTests.cs
│ │ ├── ResourceLocationArgumentTests.cs
│ │ ├── RotationArgumentTests.cs
│ │ ├── ScoreHolderArgumentTests.cs
│ │ ├── ScoreboardSlotArgumentTests.cs
│ │ ├── SoundArgumentTests.cs
│ │ ├── StorageArgumentTests.cs
│ │ ├── StringArgumentTests.cs
│ │ ├── SwizzleArgumentTests.cs
│ │ ├── TeamArgumentTests.cs
│ │ ├── TimeArgumentTests.cs
│ │ ├── UuidArgumentTests.cs
│ │ ├── Vec2ArgumentTests.cs
│ │ └── Vec3ArgumentTests.cs
│ ├── Parsers
│ │ ├── JsonParserTests.cs
│ │ ├── NbtParserTests.cs
│ │ ├── ResourceLocationParserTests.cs
│ │ └── UuidParserTests.cs
│ ├── Tests.csproj
│ └── Tree
│ │ ├── ArgumentNodeTests.cs
│ │ ├── LiteralNodeTests.cs
│ │ └── NodeTests.cs
├── UserInterface
│ ├── AnalyserLogger.cs
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AssemblyInfo.cs
│ ├── UserInterface.csproj
│ ├── UserInterface.csproj.user
│ ├── ViewModels
│ │ ├── CommandVersionViewModel.cs
│ │ ├── CrashWindowViewModel.cs
│ │ ├── MainWindowViewModel.cs
│ │ ├── SortTypeViewModel.cs
│ │ └── UpdateWindowViewModel.cs
│ ├── Views
│ │ ├── CrashWindow.xaml
│ │ ├── CrashWindow.xaml.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── UpdateWindow.xaml
│ │ └── UpdateWindow.xaml.cs
│ ├── WpfExtensions.cs
│ └── command_block.ico
└── Utilities
│ ├── EnumExtensions.cs
│ ├── Generic.cs
│ ├── UUID.cs
│ └── Utilities.csproj
├── README.md
└── resources
├── anchors
└── java.json
├── blocks
└── java.json
├── colours
└── java.json
├── commands
├── bedrock.json
├── java-test.json
└── java.json
├── components
├── bedrock.json
└── java.json
├── data-debug.json
├── data.json
├── definitions-debug.json
├── definitions.json
├── enchantments
└── java.json
├── entities
└── java.json
├── gamemodes
├── bedrock.json
├── java-test.json
└── java.json
├── item_components
└── bedrock.json
├── item_slots
├── bedrock.json
└── java.json
├── items
└── java.json
├── mob_effects
└── java.json
├── objective_criteria
├── bedrock.json
└── java.json
├── operations
└── java.json
├── particles
└── java.json
├── scoreboard_slots
├── bedrock.json
└── java.json
├── selector_arguments
├── bedrock.json
└── java.json
├── sorts
└── java.json
├── structure_mirrors
├── bedrock.json
└── java.json
├── structure_rotations
├── bedrock.json
└── java.json
└── time_scalars
└── java.json
/FunctionAnalyser/AdvancedText/AdvancedText.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/AdvancedText/ILogger.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AdvancedText
4 | {
5 | public interface ILogger
6 | {
7 | void Log(TextComponent component);
8 | void Log(List component);
9 | void Clear();
10 | string GetFlatString();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AdvancementArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class AdvancementArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Advancement result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation advancement);
13 | if (readResults.Successful) result = new Advancement(advancement);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AngleArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class AngleArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Angle result) {
8 | int start = reader.GetCursor();
9 | ReadResults readResults = new AngleParser(reader).Read(out result);
10 | if (!readResults.Successful) return readResults;
11 |
12 | if (float.IsNaN(result.Value) || float.IsInfinity(result.Value)) {
13 | reader.SetCursor(start);
14 | return ReadResults.Failure(CommandError.InvalidAngle().WithContext(reader));
15 | }
16 | return ReadResults.Success();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AttributeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class AttributeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Attribute result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation attribute);
13 | if (readResults.Successful) result = new Attribute(attribute);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BiomeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class BiomeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Biome result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation biome);
13 | if (readResults.Successful) result = new Biome(biome);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BlockArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class BlockArgument : IArgument
9 | {
10 | [JsonProperty("for_testing")]
11 | private readonly bool ForTesting;
12 |
13 | [JsonProperty("use_bedrock")]
14 | private readonly bool UseBedrock;
15 |
16 | public BlockArgument(bool forTesting = false, bool useBedrock = false)
17 | {
18 | ForTesting = forTesting;
19 | UseBedrock = useBedrock;
20 | }
21 |
22 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Block result)
23 | {
24 | return new BlockParser(reader, ForTesting, resources, UseBedrock).Parse(out result);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BlockPosArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class BlockPosArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | if (reader.CanRead() && reader.Peek() == '^') {
13 | return new LocalCoordinatesParser(reader, UseBedrock).Parse(out result);
14 | }
15 | return new WorldCoordinatesParser(reader, UseBedrock).ParseInteger(out result);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BooleanArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 |
3 | namespace CommandParser.Arguments
4 | {
5 | public class BooleanArgument : IArgument
6 | {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out bool result)
8 | {
9 | return reader.ReadBoolean(out result);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BossbarArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class BossbarArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Bossbar result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation bossbar);
13 | if (readResults.Successful) result = new Bossbar(bossbar);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ColourArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ColourArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Colour result)
9 | {
10 | result = default;
11 | ReadResults readResults = reader.ReadUnquotedString(out string colour);
12 | if (!readResults.Successful) return readResults;
13 |
14 | if (!resources.Colours.Contains(colour))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownColour(colour));
17 | }
18 |
19 | result = new Colour(colour);
20 | return ReadResults.Success();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ColumnPosArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class ColumnPosArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | return new WorldCoordinatesParser(reader, UseBedrock).ParseIntegerFlat(out result);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ComponentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.ComponentParser;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 | using CommandParser.Results.Arguments;
6 |
7 | namespace CommandParser.Arguments
8 | {
9 | public class ComponentArgument : IArgument
10 | {
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Component result)
12 | {
13 | result = default;
14 | if (!reader.CanRead()) return ReadResults.Failure(CommandError.IncorrectArgument().WithContext(reader));
15 | int start = reader.GetCursor();
16 |
17 | ReadResults readResults = new JsonReader(reader).ReadAny(out IJsonArgument json);
18 | if (!readResults.Successful) return readResults;
19 | result = new Component(json);
20 | return new ComponentReader(reader, start, resources).ValidateFromRoot(json, resources.Components);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/CompoundTagArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Nbt;
2 | using CommandParser.Minecraft.Nbt.Tags;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class CompoundTagArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out INbtTag result) {
8 | return new NbtParser(reader).ReadCompound(out result);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/DimensionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class DimensionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Dimension result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation dimension);
13 | if (readResults.Successful) result = new Dimension(dimension);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/DoubleRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class DoubleRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public DoubleRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(double.TryParse, CommandError.InvalidDouble, double.NegativeInfinity, double.PositiveInfinity, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/EntityAnchorArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class EntityAnchorArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Anchor result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string anchor);
13 | if (!readResults.Successful) return readResults;
14 |
15 | if (!resources.Anchors.Contains(anchor))
16 | {
17 | reader.SetCursor(start);
18 | return ReadResults.Failure(CommandError.InvalidEntityAnchor(anchor).WithContext(reader));
19 | }
20 |
21 | result = new Anchor(anchor);
22 | return ReadResults.Success();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/EntitySummonArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class EntitySummonArgument : IArgument
9 | {
10 | [JsonProperty("use_bedrock")]
11 | private readonly bool UseBedrock;
12 |
13 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Entity result)
14 | {
15 | result = default;
16 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation entity);
17 | if (!readResults.Successful) return readResults;
18 |
19 | // Temporary
20 | if (UseBedrock)
21 | {
22 | result = new Entity(entity);
23 | return ReadResults.Success();
24 | }
25 |
26 | if (!resources.Entities.Contains(entity))
27 | {
28 | return ReadResults.Failure(CommandError.UnknownEntity(entity));
29 | }
30 | result = new Entity(entity);
31 | return ReadResults.Success();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/FloatRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class FloatRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public FloatRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(float.TryParse, CommandError.InvalidFloat, float.NegativeInfinity, float.PositiveInfinity, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/FunctionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class FunctionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Function result)
10 | {
11 | result = default;
12 | bool isTag = false;
13 | if (reader.CanRead() && reader.Peek() == '#')
14 | {
15 | reader.Skip();
16 | isTag = true;
17 | }
18 |
19 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation function);
20 | if (readResults.Successful) result = new Function(function, isTag);
21 | return readResults;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/GamemodeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class GamemodeArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out GameType result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string gamemode);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.Gamemodes.TryGet(gamemode, out result))
15 | {
16 | reader.SetCursor(start);
17 | return ReadResults.Failure(CommandError.UnknownGamemode(gamemode).WithContext(reader));
18 | }
19 |
20 | return ReadResults.Success();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/IArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 |
3 | namespace CommandParser.Arguments
4 | {
5 | public interface IArgument
6 | {
7 | ReadResults Parse(IStringReader reader, DispatcherResources resources, out T result);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/IntegerRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class IntegerRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public IntegerRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(int.TryParse, CommandError.InvalidInteger, int.MinValue, int.MaxValue, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class ItemArgument : IArgument-
9 | {
10 | [JsonProperty("for_testing")]
11 | private readonly bool ForTesting;
12 |
13 | [JsonProperty("use_bedrock")]
14 | private readonly bool UseBedrock;
15 |
16 | public ItemArgument(bool forTesting = false, bool useBedrock = false)
17 | {
18 | ForTesting = forTesting;
19 | UseBedrock = useBedrock;
20 | }
21 |
22 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Item result)
23 | {
24 | return new ItemParser(reader, resources, ForTesting, UseBedrock).Parse(out result);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemComponentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.ComponentParser;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 | using CommandParser.Results.Arguments;
6 |
7 | namespace CommandParser.Arguments
8 | {
9 | public class ItemComponentArgument : IArgument
10 | {
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemComponent result)
12 | {
13 | result = default;
14 | if (!reader.CanRead()) return ReadResults.Failure(CommandError.IncorrectArgument().WithContext(reader));
15 | int start = reader.GetCursor();
16 |
17 | ReadResults readResults = new JsonReader(reader).ReadAny(out IJsonArgument json);
18 | if (!readResults.Successful) return readResults;
19 | result = new ItemComponent(json);
20 | return new ComponentReader(reader, start, resources).ValidateFromRoot(json, resources.ItemComponents);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemEnchantmentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ItemEnchantmentArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Enchantment result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation enchantment);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.Enchantments.Contains(enchantment))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownEnchantment(enchantment));
17 | }
18 | result = new Enchantment(enchantment);
19 | return ReadResults.Success();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemModifierArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ItemModifierArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemModifier result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation itemModifier);
13 | if (readResults.Successful) result = new ItemModifier(itemModifier);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemSlotArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ItemSlotArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemSlot result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string slot);
13 |
14 | if (!readResults.Successful) return readResults;
15 | if (!resources.ItemSlots.Contains(slot))
16 | {
17 | reader.SetCursor(start);
18 | return ReadResults.Failure(CommandError.UnknownSlot(slot).WithContext(reader));
19 | }
20 | result = new Results.Arguments.ItemSlot(slot);
21 | return ReadResults.Success();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/LootTableArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class LootTableArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out LootTable result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation lootTable);
13 | if (readResults.Successful) result = new LootTable(lootTable);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/MobEffectArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class MobEffectArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out MobEffect result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation mobEffect);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.MobEffects.Contains(mobEffect))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownEffect(mobEffect));
17 | }
18 | result = new MobEffect(mobEffect);
19 | return ReadResults.Success();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/NbtTagArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Nbt;
2 | using CommandParser.Minecraft.Nbt.Tags;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class NbtTagArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out INbtTag result) {
8 | return new NbtParser(reader).ReadValue(out result);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ObjectiveArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 | using Newtonsoft.Json;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ObjectiveArgument : IArgument
8 | {
9 | [JsonProperty("use_bedrock")]
10 | private readonly bool UseBedrock;
11 |
12 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Objective result)
13 | {
14 | result = default;
15 | ReadResults readResults;
16 | string objective;
17 |
18 | if (UseBedrock) readResults = reader.ReadString(out objective);
19 | else readResults = reader.ReadUnquotedString(out objective);
20 |
21 | if (!readResults.Successful) return readResults;
22 | if (objective.Length > 16)
23 | {
24 | return ReadResults.Failure(CommandError.ObjectiveNameTooLong());
25 | }
26 | result = new Objective(objective);
27 | return ReadResults.Success();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ObjectiveCriterionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ObjectiveCriterionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ObjectiveCriterion result)
10 | {
11 | return new ObjectiveCriterionParser(reader, resources).ByName(out result);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/OperationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class OperationArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Operation result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | while (!reader.AtEndOfArgument()) reader.Skip();
13 | string operation = reader.GetString()[start..reader.GetCursor()];
14 |
15 | if (!resources.Operations.Contains(operation))
16 | {
17 | return ReadResults.Failure(CommandError.InvalidOperation());
18 | }
19 |
20 | result = new Operation(operation);
21 | return ReadResults.Success();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/PredicateArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class PredicateArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Predicate result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation predicate);
13 | if (readResults.Successful) result = new Predicate(predicate);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/RecipeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class RecipeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Recipe result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation recipe);
13 | if (readResults.Successful) result = new Recipe(recipe);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ResourceLocationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ResourceLocationArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ResourceLocation result)
9 | {
10 | return ResourceLocation.TryRead(reader, out result);
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/RotationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class RotationArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Rotation result) {
12 | return new RotationParser(reader, UseBedrock).Parse(out result);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ScoreboardSlotArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ScoreboardSlotArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ScoreboardSlot result)
10 | {
11 | return new ScoreboardSlotParser(reader, resources).Read(out result);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/SoundArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class SoundArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Sound result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation sound);
13 | if (readResults.Successful) result = new Sound(sound);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/StorageArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class StorageArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Storage result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation storage);
13 | if (readResults.Successful) result = new Storage(storage);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/StructureMirrorArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class StructureMirrorArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out StructureMirror result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | while (reader.CanRead() && IsUnquotedStringPart(reader.Peek())) reader.Skip();
13 | string structureMirror = reader.GetString()[start..reader.GetCursor()];
14 |
15 | if (!resources.StructureMirrors.Contains(structureMirror))
16 | {
17 | return ReadResults.Failure(CommandError.UnknownStructureMirror(structureMirror));
18 | }
19 |
20 | result = new StructureMirror(structureMirror);
21 | return ReadResults.Success();
22 | }
23 |
24 | private static bool IsUnquotedStringPart(char c)
25 | {
26 | return c >= '0' && c <= '9' ||
27 | c >= 'A' && c <= 'Z' ||
28 | c >= 'a' && c <= 'z' ||
29 | c == '_' || c == '-' ||
30 | c == '.' || c == '§';
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/StructureRotationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class StructureRotationArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out StructureRotation result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | while (reader.CanRead() && IsUnquotedStringPart(reader.Peek())) reader.Skip();
13 | string structureRotation = reader.GetString()[start..reader.GetCursor()];
14 |
15 | if (!resources.StructureRotations.Contains(structureRotation))
16 | {
17 | return ReadResults.Failure(CommandError.UnknownStructureRotation(structureRotation));
18 | }
19 |
20 | result = new StructureRotation(structureRotation);
21 | return ReadResults.Success();
22 | }
23 |
24 | private static bool IsUnquotedStringPart(char c)
25 | {
26 | return c >= '0' && c <= '9' ||
27 | c >= 'A' && c <= 'Z' ||
28 | c >= 'a' && c <= 'z' ||
29 | c == '_' || c == '-' ||
30 | c == '.' || c == '§';
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/SwizzleArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class SwizzleArgument : IArgument>
8 | {
9 | [JsonProperty("characters")]
10 | private readonly HashSet Characters;
11 |
12 | public SwizzleArgument(HashSet characters = null)
13 | {
14 | Characters = characters ?? new HashSet();
15 | }
16 |
17 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out HashSet result)
18 | {
19 | result = new HashSet();
20 | int start = reader.GetCursor();
21 |
22 | while (!reader.AtEndOfArgument())
23 | {
24 | char c = reader.Read();
25 | if (!Characters.Contains(c) || result.Contains(c))
26 | {
27 | reader.SetCursor(start);
28 | return ReadResults.Failure(CommandError.InvalidSwizzle(Characters).WithContext(reader));
29 | }
30 | result.Add(c);
31 | }
32 | return ReadResults.Success();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/TeamArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class TeamArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Team result)
9 | {
10 | ReadResults readResults = reader.ReadUnquotedString(out string team);
11 | result = new Team(team);
12 | return readResults;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/TimeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class TimeArgument : IArgument