help with a code

Discussion in 'Spigot Plugin Development' started by Elho, Jun 16, 2015.

  1. Any errors? Can't do anything if you have no errors, in that case there is nothing you need help with and the plugin is fine
     
  2. Even if you do not have permissions "test.test", the command will still trigger.
    In your code, you are checking whether the player has permissions and if he does not, send him a message and continue. You need to change this by checking whether the player has permission, then doing the command.
     
  3. not needed, you can check if the player doesn't have the permission, then tell the player they don't have the permission then return true to say that the commnd has executed successfully, return true will also stop any other code after it being triggered
     
    • Agree Agree x 1
  4. Code (Text):
    if (!sender.hasPermission("test.test")) {
                 sender.sendMessage(ChatColor.RED + "No permissions.");
    return true;
             }
             if(args.length < 2) {
                 sender.sendMessage(ChatColor.GREEN + "Use /report <player> <reason>");
    return true;
             }
    Change whatever you have to this and it should work.

    You have to add "return true" after you check if someone doesn't have a certain permission or if the player is using incorrect arguments. This will stop any further code from running.
     
  5. True, never thought of those.
     
    • Like Like x 1