Sign API
by: x313
This plugin is for Developers to help them opening Signs, or getting sign input from users.
Permissions:
- SignLib.* (all permissions)
- SignLib.set (set the sign)
- SignLib.remove (remove the sign)
- SignLib.test (test the sign)
Commands:
The base command is /SignLib
Arguments:
- setsign (Set the sign, need permission 1 or 2)
- removesign (Remove the sign, need permission 1 or 3)
- test (Test of the signLib is working, need permission 1 or 4)
Plugins that use this API:
-
your plugin here? contact me!
Setup for Owners:
To get this API working you need to set a sign.
here you see how to setup the sign
1. place down a sign
2. go stand in the sign
3. type /signlib setsign (you need the permission 1 or 2)
4. if you get the message "Saved this sign as writing sign!" you are done, otherwise go stand in the sign!
Setup for developers:
first you implement the plugin, at the same way you implemented Spigot
Opening a sign:
Sign sign = SignLib.getSignAt(player.getLocation());
Opening a sign to get the input from a user!
first you need to implent SignListener
public class Test extends JavaPlugin implements SignListener
this will give you this method:
@Override
public void onSignInput(SignAPIEvent event) {
// TODO Auto-generated method stub
}
this is for later use.
now we are going to create a new SignAPIEvent
SignLib lib = SignLib.getSignLib();
lib.addEvent(new SignAPIEvent(this, player));
This will open the sign for the player and if he close the sign it will fire the onSignInput event.
now you can get the text like this:
@Override
public void onSignInput(SignAPIEvent event) {
event.getPlayer().sendMessage(event.getText());
}
this code will send the player the text they typed in.
you can also use indicators, in case you have multiple signs you want to open:
SignLib lib = SignLib.getSignLib();
lib.addEvent(new SignAPIEvent(this, player. "test1"));
@Override
public void onSignInput(SignAPIEvent event) {
if(event.getIndicator().equals("test1") {
event.getPlayer().sendMessage(event.getText());
}
}
full working code:
public class Test extends JavaPlugin implements SignListener{
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(commandLabel.equalsIgnoreCase("test")) {
if(sender instanceof Player) {
Player player = (Player) sender;
SignLib lib = SignLib.getSignLib();
lib.addEvent(new SignAPIEvent(this, player));
}
}
return false;
}
@Override
public void onSignInput(SignAPIEvent event) {
event.getPlayer().sendMessage(event.getText());
}
}
need help or a more indept description??
add me on discord: x313#0313
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta