Skip to content

Custom Command Creator #1

@Straikerinos

Description

@Straikerinos

Ability to create custom commands using the CommandStructure API from TheAPI

Pros:

  • Complexity of the whole code is simplified many times
  • Easy binding of subcommands, selectors and argument searching
  • Tabcompleter will also automatically build

Cons:

  • Code can be quite messy as CommandStructure is made in spaghetti code style
  • It doesn't contain all the necessary Selectors, such as searching for entities under a certain NBT and so on

Example:

myCommand:
  # https://github.com/TheDevTec/CraftyServerSystem/blob/main/files/cooldowns.yml
  cooldown: mycmd
  permission: "css.cmd.myCommand"
  # Selectors:
  # PLAYER
  # OFFLINE_PLAYER (Callable argument -> API#offlineCache().getQueries())
  # NUMBER (Double, Integer, Long..) - Variable option "shouldFormat: true/false"
  # INTEGER (Integer) - Variable option "shouldFormat: true/false"
  # ARGUMENT(String value)
  # STRING(length: **-1** = unlimited, defaulty **1**)
  # WORLD (world, world_nether..)
  # MATERIAL (STONE, DIRT..)
  # BIOME_TYPE (PLAINS, OCEAN..)
  # ENTITY_SELECTOR (@a, @e, @r, @p, @s, PLAYER)
  # ENTITY_TYPE (ZOMBIE, CHICKEN..)
  # POSITION (~, NUMBER) - Variable option "shouldFormat: true/false"
  # TIME (STRING(1) -> Will be formatted via TimeUtils#timeToString(long))
  args:
    0:
      selector: PLAYER
      messages: "/myCommand [player] [hello/message]"
      args:
        0:
          selector: ARGUMENT("hello")
          commands: "tellraw {arg0} {\"text\":\"Hello sir, how do you do?\"}"
        1:
          selector: STRING(-1)
           permission: "css.cmd.myCommand.customMessage"
          commands: "tellraw {arg0} {\"text\":\"{arg1}\"}"
    1:
      selector: ARGUMENT(test)
      messages: "You have used /myCommand test command!"
      commands:
      - "say {sender} used test command!"
      # https://github.com/TheDevTec/CraftyServerSystem/blob/main/files/cooldowns.yml
      cooldown: mycmd-test
      onCooldown:
        messages: "You are in cooldown, please wait {time} before using command."
        commands: []

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions