GithubHelp home page GithubHelp logo

advancementcommand's Introduction

AdvancementCommand

Runs a command, optionally as console or permission elevated when receiving advancements

Downloads

See Releases

Documentation

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.

Keys

  • 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:
      permissions:
        - 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.

Variables

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.

Examples

on_advancement:
  # 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
    commands: 
      - 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

Tricks

You may define fake advancement keys, to define a list of actions, and then use them inside of your alias targets.

Contributing

See Issues section.

Join #aikar on Spigot IRC - irc.spi.gt to discuss.

Or Code With Aikar Discord.

Other projects by Aikar / Empire Minecraft

  • ACF - Annotation Command Framework - The most powerful command framework for Bukkit, Sponge, BungeeCoord, JDA and any other platform. Build rich command definitions powered by annotations.
  • TaskChain - Powerful context control to dispatch tasks Async, then access the result sync for API usage. Concurrency controls too.
  • Minecraft Timings - Add Timings to your plugin in a safe way that works on all Bukkit platforms (CraftBukkit - no timings, Spigot - Timings v1, Paper and Paper forks - Timings v2)

License

As with all my other public projects

Commands (c) Daniel Ennis (Aikar) 2018.

Commands is licensed MIT. See LICENSE

advancementcommand's People

Contributors

aikar avatar bilguun0203 avatar shikendon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

advancementcommand's Issues

Variables are not working

I have tried both case sensitive and running as console or player.

[21:24:55 INFO]: [BlatantDecoy] I just got the advancement %ADVANCEMENT
[21:24:55 INFO]: [LP] %player is not a valid username/uuid.

config.yml:

  • advancement: namespace:advancement
    run_as: console
    command: lp user %player permission set my.permission.node true
  • advancement: namespace:advancement
    run_as: player
    command: say I just got the advancement %ADVANCEMENT

Result:
[21:24:55 INFO]: [BlatantDecoy] I just got the advancement %ADVANCEMENT
[21:24:55 INFO]: [LP] %player is not a valid username/uuid.

I have also tried other commands such as kick
command: kick %player

Can't use alias key

Plugin expecting to have command/commands for advancement with alias key.

Example config.yml

on_advancement:
  - advancement: myplugin:broadcast_hello
    run_as: player
    command: broadcast hello
  - advancement: minecraft:husbandry/tame_an_animal
    alias: myplugin:broadcast_hello

Result

Error during startup
[AdvancementCommand] Error in Command Configuration for advancement minecraft:husbandry/tame_an_animal at entry 2: Commands can not be empty

Replacement Alias doesn't work

So, I was attempting to use this plugin to give a player some special permissions when they got an advancement.... I set up a command, but when the advancement was achieved, the console spat out that it couldn't find a player named %player

(this is on Spigot 1.14.4, by the way, Java 1.8.0_251)

I looked at your code, and this line: private static final Pattern PLAYER = Pattern.compile("%player\b", Pattern.CASE_INSENSITIVE);

You've got this "\b" in there, I tested it out in a fiddle, and it doesn't seem to match the pattern unless the string has the backspace control character at the end. Of course, if I try to put the backspace control character at the end in the yaml, it won't run.

If you change the pattern to: private static final Pattern PLAYER = Pattern.compile("%player\b", Pattern.CASE_INSENSITIVE);
then the code will work as I believe you wanted it to. You actually have a pull request already from someone who found and fixed this problem, if you could just merge it I think we'd be good.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.