Skip to content

Command support #161

Closed
Closed

Description

@caelunshun

Currently, commands entered by a player will appear in chat as if they were a normal chat message. Correctly handle chat messages prefixed with a "/" and reroute to command handler.

How this will be structured is yet to be seen—a system per command seems somewhat messy.

Activity

  1. added this to the 0.7 milestone on Oct 6, 2019
  2. caelunshun commented on Oct 6, 2019

    @caelunshun
    MemberAuthor

    It might be a good idea to start by having commands take World as a parameter and running them sequentially at the end of the tick. There's no real need to run them in parallel, so this is a fine way to begin.

  3. DarkWeird commented on Nov 13, 2019

    @DarkWeird

    Maybe use Fn fields for component and grouped commands by parameters?
    Then you can expand it with future plugins ... Potentially, because it is part of ECS.

    But introducing the system as a team sounds good for ECS and further expansion. You can implement the command macro for convenience.

  4. caelunshun commented on Nov 13, 2019

    @caelunshun
    MemberAuthor

    With the Tonks rewrite, this will become a lot easier, because we will be able to schedule arbitrary systems on demand.

  5. Defman commented on Feb 25, 2020

    @Defman
    Member

    What would be involved in command support? Are we talking about a low-level system triggering all "/" or more in-depth with argument parsing like Mojang/bridgadier or both?

    Further more if we are talking about a more fully featured command framework, should it be similar to bridgadier since thats how vanilla commands are handled.

  6. Defman commented on Mar 30, 2020

    @Defman
    Member

    I have been looking into implementing this and found it should support the following.

    1. Syntax/usage generation for each command.
    2. Branching based on Arguments. This will require the parsing of Args partially and not totally.
    3. Description of each command.
    struct Command<Args, F>
    where
      Args: PartialParse,
      F: Fn(Args) -> CommandResult,
    {
      args: PhantomData<Args>,
      function: F,
      description: Option<String>,
    }

    The arguments should be stored as some graph, and each node may have a command attached. The function attached to said command has the Argument which is the sum of all parent's arguments. Such that we can pass all previously partial parsed arguments from the graph as the total argument for the function.

    struct Argument<T>
    where
      T: Parse
    {
      name: String,
      ty: PhantomData<T>,
    }
    impl<T, Args> PartialParse<T, Args> for Argument<T>
    where
      T: Parse,
      Args: PartialParse
    {
    ...
    }
  7. added a commit that references this issue on May 18, 2020
    1615989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: hardenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions