CommandBlocker API
-
Hello!
This wiki tutorial will teach you all about the new API for CommandBlocker!
CommandBlocker is a new plugin to block any command!
Usage:
Events:
First, let's do our events; The current events are "BlockCommandEvent" and "UnblockCommandEvent"
Code (Text):@EventHandler
public void cmdBlock(BlockCommandEvent event) {
}
@EventHandler
public void cmdBlock(UnblockCommandEvent event) {
}
Next, we want to find the command that was blocked and who blocked it!
Code (Text):@EventHandler
public void cmdBlock(BlockCommandEvent event) {
String command = event.getCommand();
CommandSender creator = event.getCreator();
}
@EventHandler
public void cmdBlock(UnblockCommandEvent event) {
String command = event.getCommand();
CommandSender creator = event.getCreator();
}
Code (Text):@EventHandler
public void cmdBlock(BlockCommandEvent event) {
String command = event.getCommand();
CommandSender creator = event.getCreator();
if (creator instanceof Player) {
creator.sendMessage("You unblocked the command /" + command + "!")
}
}
@EventHandler
public void cmdBlock(UnblockCommandEvent event) {
String command = event.getCommand();
CommandSender creator = event.getCreator();
if (creator instanceof Player) {
creator.sendMessage("You unblocked the command /" + command + "!")
}
}
Those are the events, and of course, you can do anything you want in the event.
Main API:
The main API can create or delete blocked commands whenever. It can be used in other commands or events!
To get the main API instance, add this to your code:
Code (Text):CommandBlocker cb = new CommandBlocker("SomeCommand");
Note that the plugin does currently NOT support sub-commands, if you use them in the code it will block the main command.
Now let's decide what we want to do with this command, Should we block it or unblock it? Here's how to do both!
Block:
Code (Text):cb.addCommand();
Code (Text):if (cb.isBlocked()) {
cb.removeCommand();
}
That's currently it for this API! Make sure to PM @iShadey with API suggestions for this plugin! - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM