Subcommands

Discussion in 'Plugin Development' started by carlgo11, Sep 3, 2012.

?

how to make subcommands

  1. idk what this is

    0 vote(s)
    0.0%
  2. -_-

    0 vote(s)
    0.0%
Multiple votes are allowed.
Thread Status:
Not open for further replies.
  1. Offline

    carlgo11

    I don't know how to make subcommands like /command help .
    What is the code for that?

    /Carlgo11
     
  2. Offline

    MrFigg

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
        if(args.length<=0) {
            args = new String[]{ "help" };
        }
        if(args[0].equalsIgnoreCase("help")) {
            // Print Help Here
            return true;
        }
        if(args[0].equalsIgnoreCase("justinbieberforever")) {
            if(sender instanceof Player) {
                Player player = (Player) sender;
                for(int i = 0; i < 10; i++) player.getWorld().spawnCreature(player.getLocation(), EntityType.CREEPER);
            }
            sender.sendMessage(">=(");
            return true;
        }
        sender.sendMessage("Unrecognized Command");
        return false;
    }
     
Thread Status:
Not open for further replies.

Share This Page