A simple sign API to make a players interact with signs.
This project was made because I just wanted a simple sign API that I could quickly import into my projects thru JitPack. This has been tested on 1.17 but it should work older versions.
All you need to run this is Spigot and ProtocolLib installed on your server (make sure you add it as depend in your plugin.yml)
You will need to install this thru Maven or something similar.
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>dev.pns</groupId>
<artifactId>SignAPI</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
Initilize the API with the following code:
public class Example extends JavaPlugin {
private SignAPI signAPI;
@Override
public void onEnable() {
signAPI = new SignAPI(this);
}
}
When you want to use the API just call the method inside the api:
This takes a list of strings and an interface which will be called when the player exists the sign. Then you need to open the menu for a player. Here's how you can do that:
Make sure you're using the SignGUI
class which is returned by the createGUI method.
Player player = (Player) sender;
SignGUI gui = api.createGUI(
Arrays.asList("", "^^^^^^^^^^^^^^^","Enter the force", "amount above"),
((p, strings) -> {
p.sendMessage("You entered: " + strings[0]);
})
);
gui.open(player);