From 683fb6ad8afe5979ffa50ef856ce4f0d19f73c59 Mon Sep 17 00:00:00 2001 From: Stijn Bannink <stijnbannink40@gmail.com> Date: Fri, 10 Nov 2023 11:48:33 +0100 Subject: [PATCH] Added API info to README --- README.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be58380..4206121 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,77 @@ A plugin to easily create shows with multiple elements like Animatronics, Firewo Check out the description on [Spigot](https://www.spigotmc.org/resources/showcontrol.112641/) or [Polymart](https://polymart.org/resource/showcontrol.4793) for more information. ## Developer API -This project contains a Developer API, which makes it possible to add your own show elements. For more information, check out the [JavaDoc](#). +This project contains a Developer API, which makes it possible to add your own show elements. For more information, check out the [JavaDoc](https://sbdevelopment.tech/javadoc/showcontrol/). + +### Including using Maven +The project is on our Maven repository, add the following to your `pom.xml` file: +```xml +<repository> + <id>sbdevelopment-repo-releases</id> + <name>SBDevelopment Repository</name> + <url>https://repo.sbdevelopment.tech/releases</url> +</repository> + +<dependency> + <groupId>tech.sbdevelopment</groupId> + <artifactId>ShowControl</artifactId> + <version>1.5</version> + <scope>provided</scope> +</dependency> +``` + +### Controlling shows +You can find all the methods you need in the `SCAPI` class. + +### Creating your own trigger +To learn how to implement your own triggers, check out [the default triggers](https://github.com/SBDPlugins/ShowControl/tree/master/src/main/java/tech/sbdevelopment/showcontrol/api/triggers/impl) for an example. + +First, you need to create a new class inside your project. Use the following as a basis: +```java +import lombok.NoArgsConstructor; +import org.bukkit.entity.Player; +import tech.sbdevelopment.showcontrol.api.triggers.Trigger; +import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier; + +import java.util.List; + +@NoArgsConstructor(force = true) +@TriggerIdentifier(value = "changeme", minArgs = 1, argDesc = "<arg0>", item = Material.GRASS_BLOCK) +public class MyTrigger extends Trigger { + public MyTrigger(String[] data) throws InvalidArgumentException { + super(data); + //TODO Do something with the data, whatever you want. + //You can throw InvalidArgumentException if an argument is invalid (not the type you except). + } + + @Override + public void trigger() { + //TODO Called when the show reaches this trigger in one of its cues, execute the trigger here. + } + + @Override + public List<String> getArgumentTabComplete(Player player, int index, String arg) { + //TODO Called when a user is adding this trigger as a cue, return a list of values for the provided arg. Starts on 0, which is the first argument of your trigger. + return List.of(); + } + + @Override + public void remove() { + //TODO Called when the trigger cue is removed from a show, optional method! + } +} +``` + +Then, you need to register your trigger(s) inside your plugin's Main class. +```java +@Override +public void onEnable() { + //Insert this inside your onEnable method: + SCAPI.index(YourMainClass.class, "the.path.to.the.package.containing.the.triggers.you.created"); +} +``` + +Lastly, don't forget to include this plugin (`ShowControl`) inside your plugin.yml as a dependency. ## License This project is licensed under the [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0).