Permissions error

Discussion in 'Plugin Development' started by BMX_ATVMAN14, Jul 11, 2012.

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

    BMX_ATVMAN14

  2. Offline

    Vinceguy1

    The error lies within the plugin.yml the permission node "needtown.use" needs to be spaced in, also rename commandLabel to label and instead of using label.equalsignorecase("needtown") use cmd.getName().equalsignorecase("needtown"), that way in the plugin.yml they can add aliases so if they wanted to use /poop to do /needtown they could.

    needtown:
    description: Broadcast out a message for a request!
    pemission: needtown.use

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  3. Offline

    BMX_ATVMAN14

    Code:
    permissions:
     needtown.use:
      description: Allows the use of the needtown command
    Like that??

    Code:
     if (Label.cmd.getName().equalsignorecase("needtown")) {
    ??
    (Still a noob ^_^ )
    Thanks for the reply

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  4. Offline

    Vinceguy1

    take off the Label part, and as for the plugin.yml i showed you exactly how to do it
    ----------------
    needtown:
    description: Broadcast out a message for a request!
    pemission: needtown.use
    ----------------
     
  5. Offline

    BMX_ATVMAN14

    Thanks, but now it doesn't recognize the command?

    Code:
    name: NeedTown
    version: 1.0
    main: me.BMX_ATVMAN14.bukkit.NeedTown.NeedTown
    description: Need a town? Just ask for it!
    commands:
    needtown:
    description: Broadcast out a message for a request!
    pemission: needtown.use
     
  6. Offline

    Vinceguy1

    its needs to be spaced out, like this
    Code:
    commands:
      needtown:
        description:
        permission: needtown.use
        aliases: []
     
  7. Offline

    BMX_ATVMAN14

    AWESOME!
    Thanks SOOOOO much :)
    One more thing though, how do I make a custom message when they don't have the permission?
    It's reading out the please contact the administration one.
    I want it to say:
    Error: You do not have permission to do that!
    or something...
    Thanks!
     
  8. Offline

    Vinceguy1

    if(player.h
    if(player.haspemission("needtown.use"){
    }
    else
    {
    player.sendmessage(ChatColor.RED + "Error: You do not have permission to do that!")
    }
     
  9. Offline

    BMX_ATVMAN14

    Nope, I'm doing something wrong, probably spacing,
    http://pastie.org/4242259
     
  10. Offline

    Vinceguy1

    Code:
              public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String args[]) {
                  Player player = (Player)sender;
                  if (player.hasPermission("needtown.use")){
                    if (cmd.getName().equalsIgnoreCase("needtown")) {
                      Bukkit.broadcastMessage((new StringBuilder()).append(ChatColor.GOLD).append(player.getDisplayName()).append(ChatColor.AQUA).append(" would like to be invited to a town! ").append(ChatColor.RED).append("Town owners").append(ChatColor.AQUA).append(" make sure to invite ").append(ChatColor.GOLD).append(player.getDisplayName()).append(ChatColor.AQUA).append("!").toString());
                    }
                }
                else
                {
                    player.sendMessage(ChatColor.RED + "Error: You do not have permission to do that!");
                }
                return false;
                }
                
     
  11. Offline

    BMX_ATVMAN14

    Wow I was way off!

    Anyway nope, still nothing :/
     
  12. Offline

    Vinceguy1

    works just fine for me.
     
  13. Offline

    BMX_ATVMAN14

  14. Offline

    EnvisionRed

    Why are you using a stringbuilder when you can just combine strings like:
    Code:
    Bukkit.getServer.broadcastMessage(ChatColor.GOLD + "The player's name is " + playerName + " and he would like to join your town!");
    The reason it isn't working is because you're having it return false.
     
  15. Offline

    BMX_ATVMAN14

    Idk, I used a stringbuilder cause it seems to be easier for me :)
     
  16. Offline

    EnvisionRed

    It's dreadfully inneficient also, how is
    Code:
    Bukkit.broadcastMessage((new StringBuilder()).append(ChatColor.GOLD).append(player.getDisplayName()).append(ChatColor.AQUA).append(" would like to be invited to a town! ").append(ChatColor.RED).append("Town owners").append(ChatColor.AQUA).append(" make sure to invite ").append(ChatColor.GOLD).append(player.getDisplayName()).append(ChatColor.AQUA).append("!").toString());
    easier than
    Code:
    Bukkit.getServer().broadcastMessage(ChatColor.GOLD + player.getDisplayName() + ChatColor.AQUA + "would like to be invited to a town!" + ChatColor.RED + "Town owners" + ChatColor.AQUA + " make sure to invite " + ChatColor.GOLD + player.getDisplayName() + ChatColor.AQUA + "!");
    It uses way less space and is much more readable.

    Anyway, here's how your code should be if you want it to work: http://pastie.org/4242412

    Your code is a mess though..
     
  17. Offline

    BMX_ATVMAN14

    How is it messy? Could you show me what to change? I'm new to this so I'm trying to pick up on this stuff

    Edit
    It still doesn't show the message if they don't have the permission it just says contact administration
     
  18. Offline

    EnvisionRed

    Er, after you have it do something you have to have it return true or it will show the usage for the command you just used.
     
Thread Status:
Not open for further replies.

Share This Page