Skip to content

art-framework/core

Repository files navigation

Actions Requirements Trigger (ART) Framework

Build Status Netlify jitpack status codecov GitHub release (latest SemVer including pre-releases) Commitizen friendly semantic-release

This framework enables you to easily provide actions, requirements and triggers that can be used in configs for any number of plugins. One very common use case would be to support the art-framework additionally to executing commands for giving rewards or doing stuff when something in your plugin happens.


    

Features

  • Easy to use API. ART.load(...) is all you need!
  • Support for multiple parsers and one built in flow-parser.
  • Easy to learn configuration syntax: !action, ?requirement, @trigger.
  • Classpath scanning to remove tedious configuration code.
  • Extremly modular. Every provider and configuration can be changed.
  • Platform independent, can be implemented for use in Minecraft plugins or any other software.
    Available platforms: Bukkit/Spigot/Paper
  • Enhanced command usage: /minecraft:give(cooldown:4h) ${player} golden_apple 5
  • PlaceholderAPI support: !money.add %vault_eco_balance% doubles the players balance.

Example

You have a plugin that allows the configuration of executable commands when an action in your plugin occurs, e.g. for giving rewards.

One of many use cases of the art-framework is to empower exactly those plugins that use commands as a compability layer between other plugins.

Take the following art-example:

# you can use ART inside any of your configs mixed with all of you config stuff
...
# then put an ART section somewhere, which you can load inside your plugin
# see the developer documentation for more details on how to do that
rewards:
  # no need to depend on vault directly to give players money
  - '!vault:player.money.add 1000'
  # you want to add some custom items from an unknown plugin?
  # no problem!
  - '!my-custom-item-plugin:player.item.add mighty-sword_1337, amount=5'
  - '?permission ranks.donor'
  # fallback to using commands enhanced with the power of the art-framework
  - '/goldencrates(cooldown:24h) givekey art-somekey'
  # every reward has a cost!
  # damage the player for 10 hitpoints
  # but only if his health is above 15 hitpoint
  - '?player.health >=15'
  - '!player.damage damage=10'

That was the configuration side, and here is how you can implement exactly that in your plugin:

try {
  // parse the config and get your art result
  ArtContext rewards = ART.load(config.getStringList("rewards"));
  // execute all configured rewards
  result.execute(player);
} catch (ParseException e) {
  // invalid art configuration
}

That is for loading and using art. Here is a veriy basic example on how to create art, e.g. the vault:player.money.add action.

@ART(
  value = "vault:player.money.add",
  description = "Adds the given amount of money to the player. Can be an offline player.",
  alias = {"money.add", "player.money.add", "money", "vault:money.add", "vault:money"}
)
public class AddMoneyAction implements Action<OfflinePlayer> {

  private final Economy economy;

  public AddMoneyAction(Economy economy) {
    this.economy = economy;
  }

  @ConfigOption(
    required = true,
    position = 0,
    description = "The amount of money that should be added to the player."
  )
  private int amount;

  @Override
  public Result execute(@NonNull Target<OfflinePlayer> target, @NonNull ExecutionContext<ActionContext<OfflinePlayer>> context) {

    economy.depositPlayer(target.source(), amount);

    return success();
  }
}

Roadmap

The following is planned for the future of the art-framework:

  • Online editor with auto completion support
  • Public registry of art-modules
  • Auto downloading of required art-modules from the registry

About

A Spigot Actions Requirements Trigger framework and API to use in multiple plugins.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages