Expanding commands

Discussion in 'Plugin Development' started by javoris767, Mar 29, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    javoris767

    When It comes to commands like this /supachat player prefix set <player> <prefix>, I get confused. Its like I don't know how to get from /supachat player to /supachat player prefix and that to /supachat player prefix set. Then the set to the <player> and that to <prefix>.

    Any tips or examples?

    Code:
                public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
                {
                    if (command.getName().equalsIgnoreCase("supachat")) {
                        if (((sender instanceof Player)) && (!this.API.checkPermissions((Player)sender, "supachat.reload").booleanValue())) {
                            sender.sendMessage("[SupaChat] Permission Denied");
                            return true;
                        }
                        sender.sendMessage("/supachat reload - Used to reload SupaChat's config.");
                        sender.sendMessage("/supachat prefix - Shows commands to this.");
                        
                    }
                    if (((sender instanceof Player)) && (!this.API.checkPermissions((Player)sender, "supachat.reload").booleanValue())) {
                        sender.sendMessage("[SupaChat] Permission Denied");
                        return true;
                    }
                    if (args.length != 1) return false;
                    if (args[0].equalsIgnoreCase("player")) {
                        sender.sendMessage("/supachat player prefix set <player> <prefix> - Shows commands to this.");
                        sender.sendMessage("/supachat player suffix set <player> <prefix> - Shows commands to this.");
                    }
                    if(args.length == 2) {
                        if (args[0].equalsIgnoreCase("player")) {
                            
                        }
                        }
                    return false;
                }
     
  2. Offline

    chasechocolate

    It's basically just a lot of args checks. In your case, you would need to check if the args.length is 5, 0 is player, 1 is prefix, 2 is set, and so on.
     
Thread Status:
Not open for further replies.

Share This Page