Advancement Command 1.1.0

Run commands, potentially with elevated permissions, once a player has earned an advancement.

  1. Aikar
    Tested Minecraft Versions:
    • 1.12
    Source Code:
    Runs a command, optionally as console or permission elevated when receiving advancements

    See examples below for format

    Each entry must define:

    • advancement
    • command OR commands OR alias
    An advancement can be defined multiple times in the list to perform multiple commands.

    If no other configuration is provided, it will be ran as the player without op or any elevated permissions.

    Alias will alias one advancement to run the same commands as another, so you don't have to duplicate it.

    • advancement: the advancement key such as minecraft:husbandry/root to trigger on
    • command: what command to run, see variables below for template variables
    • commands: Alternatively, a list of what command to run, see variables below for template variables
    • run_as: player or console - who receives the command feedback
    • op: Should player be given temporary op for this command. Unnecessary for run_as: console
    • permission: Permission node to give temporarily for this command. Example:
      permission: minecraft.command.teleport
    • permissions: Same as above, but a list of permission nodes. Example:
      - minecraft.command.teleport
      - some.other.perm
    • alias: Alias this advancement to run the same command information as another advancement defined here. You may still define permissions, run_as and op on the aliased entry, which will be added onto the permissions granted by the alias target.
      In other words, you can alias foo to bar, where bar is defined to have permission b, and foo (the alias) is defined to have permission a, the command defined in bar will have both a and b permissions.
    Inside of a command, you may use the following variables

    • %PLAYER: The name of the player earning the advancement.
    • %UUID: The UUID of the player earning the advancement.
    • %PLAYERDISPLAYNAME: The display name of the player earning the advancement. (might be the same as player)
    • %ADVANCEMENT: The advancement key (eg minecraft:adventure/root) being earned.
    Code (Text):

      # example of running command temporarily as op - be careful, any sub commands of this command will have op too!
      - advancement: minecraft:example
        run_as: player
        command: ranks add %player rank1
        op: true
      # run a standard command with no permissions
      - advancement: minecraft:example
        run_as: player
          - say Hey I just got an advancement!
          - me Dances!
        op: false
      # run a command as the console (command feedback to console instead of the player, ideal for rank changes)
      - advancement: myplugin:gainrank1
        run_as: console
        command: ranks add %player rank1
        op: false
      # run a command temporarily given a specific permission node, but not op
      - advancement: myplugin:teleport_to_secret
        run_as: player
        command: teleport %player some secret coords
        permission: minecraft.command.teleport
      - advancement: minecraft:husbandry/tame_an_animal
        alias: myplugin:teleport_to_secret
      - advancement: minecraft:husbandry/plant_seed
        alias: myplugin:teleport_to_secret

Recent Reviews

  1. Scholler
    Version: 1.1.0
    Very good resource:) Also wanna help you a little bit with this resource rating because you're a smart guy and deserve it :D
  2. Kremes
    Version: 1.1.0
    placeholder %PLAYER dont work for me please fix that then I give 5 stars :) thanks
    1. Aikar
      Author's Response
      Can you please file an issue on github and provide more details like what config you used. I can't see a fault in the code currently.