If statement problems

Discussion in 'Plugin Development' started by RealDope, Oct 5, 2012.

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

    RealDope

    Code:
            if(cmd.getName().equalsIgnoreCase("tban")) {
                if(args.length == 0) {
                    sender.sendMessage("ARGS LENGTH 0");
                    sender.sendMessage(prefix + "/tban ban player length m/h/d reason");
                    sender.sendMessage(prefix + "/tban unban player");
                    sender.sendMessage(prefix + "/tban reload");
                }
                else if(args.length == 1) {
                    if(args[0] == "reload") {
                        try {
                        config.reload();
                        sender.sendMessage(prefix + "Bans reloaded.");
                        }
                        catch(Exception e) {
                            getLogger().log(Level.SEVERE, "Failed to reload TempBans.yml, ban data may be lost!");
                        }
                    }
                    else {
                        sender.sendMessage("args[0] DIDNT == RELOAD");
                        sender.sendMessage(prefix + "/tban ban player length m/h/d reason");
                        sender.sendMessage(prefix + "/tban unban player");
                        sender.sendMessage(prefix + "/tban reload");
                    }
            }
    Just trying to do a simple dealing with args and if statements to figure out what args the players are entering.

    For some reason, when I run /tban reload, it gives me the "args[0] DIDNT == RELOAD", which I added in to see where the problem was.

    It's not even calling the config.reload() and sender.sendMessage(msg); in the first part of the if statement.
     
  2. Offline

    CorrieKay

    use .equals() when dealing with strings.
     
  3. Offline

    MrFigg

    Use args[0].equalsIgnoreCase("reload").
     
Thread Status:
Not open for further replies.

Share This Page