Solved Permissions

Discussion in 'Plugin Development' started by beachyboy18, Jun 23, 2014.

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

    beachyboy18

    Can't seem to get my plugin working with permissions. I've added my node 'autosave.save' to pex and all but it still says I do not have access to that command? Here is my code:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    2. {
    3.  
    4. if(cmd.getName().equalsIgnoreCase("save") && sender instanceof Player);
    5. {
    6. Player player = (Player) sender;
    7. if(player.hasPermission("autosave.save"))
    8. {
    9.  
    10. Bukkit.broadcastMessage(ChatColor.WHITE + "[" + ChatColor.DARK_AQUA+ "SaveAutomatic" + ChatColor.WHITE + "] " +
    11. ChatColor.DARK_PURPLE + player.getName() + ChatColor.GOLD + " is saving, expect lag");
    12. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "save-all");
    13. Bukkit.broadcastMessage(ChatColor.WHITE + "[" + ChatColor.DARK_AQUA+ "SaveAutomatic" + ChatColor.WHITE + "] " +
    14. ChatColor.GOLD + "Save complete");
    15.  
    16. } else {
    17.  
    18. player.sendMessage(ChatColor.RED + "You do not have access to this command.");
    19.  
    20. }
    21. }
    22.  
    23. return true;
    24.  
    25. }

    Any help would be appreciated!
     
  2. Offline

    mythbusterma

    I'm not sure if this makes a difference, but is the permission declared in "permissions" in your plugin.yml?
     
  3. Offline

    beachyboy18

    This is my plugin.yml:
     
  4. Offline

    mythbusterma

  5. Offline

    beachyboy18

    It says that 'Permission registration is optional, can also be done from code'
     
  6. Offline

    mythbusterma

    Did you register the permission in your code?
     
  7. Offline

    beachyboy18

    I'm not sure how to, partly the reason why I posted this thread
     
  8. Offline

    mythbusterma

    beachyboy18 Register it in the plugin.yml, it makes more sense as it is not a dynamically changing or declared permission. I.e. will never change.
     
  9. Offline

    beachyboy18

    I tried but it came up with an error in the console, here is my new plugin.yml:
     
  10. Offline

    mythbusterma

  11. Offline

    es359


    You have a semicolon on the end of your if() statement. That would make the statement more or less useless.

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("save") && sender instanceof Player);
    2. {
    3.  
    4. }
     
Thread Status:
Not open for further replies.

Share This Page