Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.plugin.java.JavaPlugin;
- import com.turt2live.xmail.XMail;
- import com.turt2live.xmail.api.XMailAPI;
- import com.turt2live.xmail.commands.ArgumentHandler;
- public class SampleCustomArgument extends JavaPlugin {
- @Override
- public void onEnable(){
- // Insert xMail-is-actually-here check
- // Get the xMail plugin, you can do this in 2 ways...
- // Way 1:
- XMail xmail = XMail.getInstance();
- // Way 2:
- xmail = new XMailAPI().getPlugin();
- // Create your argument handler object
- MyArgumentHandler handler = new MyArgumentHandler();
- // Tell xMail to use that handler for that argument
- xmail.getCommandHandler().registerArgument("myargument", handler);
- xmail.getCommandHandler().registerArgument("myargument2", handler);
- // You can use the same handler for 2 arguments!
- }
- // Usually this would go in another file...
- public static class MyArgumentHandler implements ArgumentHandler {
- @Override
- public void runArgument(CommandSender sender, Command command, String[] args, String passedArgument){
- // sender = Who sent the command
- // command = xMail
- // args = Arguments after your argument. So "/xmail 1 2" would have the args "2" (if "1" was our defined argument)
- // passedArgument = "1" in the previous listing
- // Here you can run whatever code you need. Note that xMail's command handler does not
- // work like Bukkit's. You will need to do usage handling on your own (sorry!)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment