Making a /report command, need help

Discussion in 'Plugin Development' started by FreeMotion45, Sep 21, 2015.

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

    FreeMotion45

    Hello, I am a new coder so please don't shout on me that I did it wrong because I already know that.

    So here is my code :

    Code:
    else if(commandLabel.equalsIgnoreCase("report"))
                {
                    if(sender.hasPermission("sc.report"))
                    {
                        {
                            {
                                sender.sendMessage(ChatColor.RED + "Thank you for reporting. Abusing /report may cause a ban / kick");
                                String args1 = "args.length > 1";
                                String argsplayer = "args.length == 1";
                                for(Player p : Bukkit.getOnlinePlayers())
    
                                if(p.hasPermission("servercontrol.phreceive"))
                                {
                                    p.sendMessage(ChatColor.RED + sender.getName() + " Has reported " + argsplayer + "reason :" + args1 + ChatColor.YELLOW + "What will you do ?");
                                }
                                else sender.sendMessage(ChatColor.RED + "Not enough arguments ! Correct usage : /report <Player> <Reason>");
                            }
                        }
                    }
                }
    If anyone can help me I will be glad. Please if you can explain what have I done wrong, so next time I will be able to do it by myself.

    I am mostly confused about how can I copy the <Reason> which is argument/s and so people with permission.reportreceive will receive the report in chat.

    Best regards, and thank you, FreeMotion.
     
  2. Offline

    bwfcwalshy Retired Staff

    @FreeMotion45 1. Use cmd.getName() not commandLabel.
    2. Erm... Why is your string "args.length > 1" That's a check.. Can you please explain why this is a String?
    3. Same as above with argsplayer
     
  3. Offline

    FreeMotion45

    I am very new, and I mostly confused about Strings/Arrays..... I am still learning how to use those. And I already wrote above that I am new to those.
    But if you could explain me how I can fix it and what was my problem I will be glad. Thanks .
     
  4. Offline

    Zombie_Striker

    Why three brackets? I know one is for the if statement, but what are the other two for?

    Also, stick to Formatting Conventions. Try to keep the open/close brackets on the same line as the if statement.
    These are just strings. It will return those sets a characters and not the actual args.

    I think what you want a String builder to turn all the args after args[0] into one string, and args[0] to get the first argument.
     
Thread Status:
Not open for further replies.

Share This Page