Need to fix permissions.

Discussion in 'Plugin Development' started by mrdude123, Jul 13, 2015.

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

    mrdude123

    Okay, I have the node and everything set up in both GroupManager and in the plugin. However, where would I put this snippet of code ? Thanks.

    if(!sender.hasPermission("coinflip.sendresult")){
    sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
    }


    Code:
                //coinflip [player] (START)
               
                Player target = Bukkit.getServer().getPlayer(args[0]);
                if(target == null){
                    sender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "CoinFlip Error" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " + ChatColor.RED + "Player not found.");
                    return true;
                }
                Random r = new Random();
                int num = r.nextInt(2);
               
                if(num == 0){
                    sender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "CoinFlip" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " +ChatColor.GREEN + "You flipped a " + ChatColor.YELLOW + "tails.");
                    target.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "CoinFlip" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " +ChatColor.GREEN + sender.getName() + " flipped a " + ChatColor.YELLOW + "tails.");
                }else{
                    sender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "CoinFlip" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " +ChatColor.GREEN + "You flipped a " + ChatColor.YELLOW + "heads.");
                    target.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "CoinFlip" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " +ChatColor.GREEN + sender.getName() + " flipped a " + ChatColor.YELLOW + "heads.");
                }
                return true;
                // coinflip [player] (END)
               
            }
           
            return false;
        }
    
    }
    
    That's only a snippet. I can provide the full source code if needed (you shouldn't need it ;))
     
  2. Offline

    _Error

    Can we see the plugin.yml?
     
  3. Offline

    mrdude123

    Sure.
    Code:
    name: CoinFlipPlus
    author: TheCerealKill3r
    version: 1.0
    description: Flip a coin.
    main: me.thecerealkill3r.CoinFlip.Main
    commands:
      coinflip:
        description: The main command for CoinFlip.
     
  4. Offline

    _Error

    Where's the permission part?
    Code:
    commands:
      coinflip:
        description: The main command for CoinFlip.
        permission: coinflip.sendresult
    permissions:
          coinflip.sendresult:
          description: Does stuff
          default: op
    
    
     
  5. Offline

    mrdude123

    @_Error You don't need that. My other two permissions that I have set up work fine. Just this one permission doesn't work.
     
  6. Offline

    _Error

    Strange, The same thing happened to me last time and it got fixed that way.
    But ill look deeply into it, Might find something else.

    Edit: did you try putting debug messages or something?
     
  7. Offline

    mrdude123

    @_Error Nope.

    EDIT: I think it's primarily about my placement in the class.
     
  8. Offline

    _Error

    Oh okay. Sorry for not being able to help, But we only got a small part of the class
     
  9. Offline

    mrdude123

    @_Error
    Do you want the full class?
     
  10. Offline

    Zombie_Striker

    @mrdude123
    1. If that is your actual code, just the way it is, then there is no way it would ever work. If there is more to your class/method, then why did you not post it?
    2. Why are you creating new instances of Random.?
    3. Why is it a boolean? Is this apart of a onCommand? If so, this should be in it's own method.
    4. Instead of having BLUE +""+Bold ..ect for every chat message, create a String called prefix that contains the prefix.
     
  11. Offline

    mrdude123

    @Zombie_Striker
    1. I didn't think you would need it.
    2. Stupid mistake.
    3. It seems to be working fine, nonetheless.
    4. Stupid mistake.

    @Zombie_Striker Do you know why this isn't working properly? It seems like you know what you're doing much better than I do.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page