Action Implementation
public class MyOwnAction {
/**
* Injects the action into the script executor, this will allow the action to be used in scripts
* <p>
* Also beware that it wraps brackets around the action name, so if you want to use the action in a script, you would use it like this:
* [GIVE_ITEM]
*/
public void injectAction() {
ScriptExecutor.registerAction("GIVE_ITEM", (executor, data) -> {
String[] parts = data.split(" ");
Material material = Material.valueOf(parts[0].toUpperCase());
int amount = Integer.parseInt(parts[1]);
ItemStack item = new ItemStack(material, amount);
executor.player.getInventory().addItem(item);
executor.player.sendMessage(Color.hex("&aYou have been given " + amount + " " + material.name() + "."));
});
}
}Last updated