Sueta
SI

SignLib

1.0.1

The Best Sign API out here, Easy manage UserInput.

·Plugin

Sign API
by: x313

This plugin is for Developers to help them opening Signs, or getting sign input from users.

Permissions:

  1. SignLib.* (all permissions)
  2. SignLib.set (set the sign)
  3. SignLib.remove (remove the sign)
  4. 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 →