API Tutorial
API Tutorial
This plugin has a very simple API.
First of all, you need a SignWallController. This can be any class that extends the class de.bibercraft.bcsignwalls.api.SignWallController.
Here is a simple examle, it's the SignWallController of bcSpleef:
package de.bibercraft.bcspleef.signwalls; import de.bibercraft.bcsignwalls.api.SignWallController; import de.bibercraft.bcsignwalls.wall.SignWall; import de.bibercraft.bcspleef.BCSpleef; import java.util.ArrayList; /** * * @author Bernhard Geisberger */ public class SpleefSignWallController implements SignWallController { private final BCSpleef plugin; private final ArrayList<ArenaWall> arenaWalls; public SpleefSignWallController(BCSpleef plugin) { this.plugin = plugin; this.arenaWalls = new ArrayList<>(); } public void updateArenaWalls() { for (ArenaWall w : arenaWalls) { w.updateAllDisplayWalls(); } } @Override public SignWall getWall(String name, String arg) { switch (name) { case "lobbywall": if (arg == null || arg.equals("")) { ArenaWall w = new ArenaWall(plugin, 1); arenaWalls.add(w); return w; } else { try { ArenaWall w = new ArenaWall(plugin, Integer.parseInt(arg)); arenaWalls.add(w); return w; } catch (NumberFormatException e) { } } break; } return null; } }
You have to register this Controller at the plugin. This is done like this:
BCSignWallsPlugin signWalls = ((BCSignWallsPlugin)plugin.getServer().getPluginManager().getPlugin("bcsignwalls")); signWalls .registerPluginController("spleef", new SpleefSignWallController(plugin));
You also need some classes, which provide the content of a SignWall. For that, you have to create a class which extends de.bibercraft.bcsignwalls.wall.SignWall .
This class has one abstract method, which is
public abstract BcWallSign[][] getContent(int width, int height);
You only have to implement this method. The given width and height are the actual width and height of the display wall. The returned array must be created like this:
BcWallSign[][] content = new BcWallSign[height][width];
After that, you only have to insert your BCWallSigns into the array. The class BCWallSign is a container for the four lines of a sign and the commands which should exectued when clicking onto the sign. To understand how to create it, just look at the source: CLICK ME
Any questions?
Just ask them on the main page, you'll get an answer soon.