PermissionsBukkit integration

Discussion in 'Plugin Development' started by black_ixx, Jan 22, 2012.

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

    Im new in developing, and have my first testplugin, which gives armor per command
    /diamond gives diamond armor
    etc.

    Now I wanna add permissionsBukkit, can anyone help me please?


    PS: The plugin is in theLINK and his name is Java ^^
     
  2. Offline

    ItsHarry

    In your onCommand, use:

    if (sender.hasPermission("permission.node"))

    where permission.node is your permission node :D

    Also, you can add some stuff to your plugin.yml, check the WIKI to find out
     
    black_ixx likes this.
  3. Thanks :D
    Now it looks like that:
    http://www.pastie.org/3230358

    How can I make, that it says a other message, if a player has no permissions for a command?
     
  4. Offline

    Seadragon91

    Code:
    if (sender.hasPermission("permission.node")) {
    //your code if the Player has the Permission
    } else {
    player.sendMessage(ChatColor.RED + "Your are not authorized!");
    }
     
    black_ixx likes this.
  5. Thanks thats great :D

    Thats the plugin now:

    name: giveArmor
    version: 0.1
    description: Gives Armor
    author: Black_ixx
    website: http://felix.neuby.de
    main: me.black_ixx.giveArmor.giveArmor
    commands:
    diamond:
    description: Give Diamond Armor
    usage: /diamond
    iron:
    description: Give Iron Armor
    usage: /iron
    gold:
    description: Give Gold Armor
    usage: /gold
    chain:
    description: Give Chain Armor
    usage: /chain
    leather:
    description: Give leather Armor
    usage: /leather


    Works with Permissions Bukkit:

    Permissions:

    givearmor.leather
    givearmor.iron
    givearmor.gold
    givearmor.diamond
    givearmor.chain


    No only one thing :

    The config.yml

    I would be glad, if someone will help me with this...

    MFG
    Black_ixx


    Download Link:

    giveArmor


    Edit: I dont want to publish this plugin, its only to learn how to develop plugins for me, which are better and which I publish at BukkitDev if they are good, and I think for plugins the config is important, so I wanna add this

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 25, 2020
  6. Offline

    theguynextdoor

    If you wanna add a config, take a good read of
    http://forums.bukkit.org/threads/making-configs.52476/
    Making config files really is not very hard.
     
    black_ixx likes this.
  7. Ok Thanks :)

    I only dont know what I can do there ( sorry, im new in developing but I will learn ) :oops: :
    http://www.pastie.org/3231954


    More detailed:

    I want, that the Server Owners can decide, which message players gets, if they make something with the plugin.

    Example:

    #Message if Players have no permissions
    NoPermissions: <Own Text>

    etc.
     
  8. At my config code now, it dont knows "config" at "p.sendMessage(Config.getString("Example.String"));"
    Do you know the problem?
     
  9. Offline

    theguynextdoor

    You called your config variable config - good
    But when you went to get the string you said Config - thats the problem
    Change it to
    Code:
    p.sendMessage(config.getString("Example.String"));
     
  10. First I have tested it with "config" but it was wrong, so I tested Config, but eclipse dont know whats "config" and "Config"
     
  11. Offline

    theguynextdoor

    In that case use
    this.getConfig().getString("Example.String")
     
    black_ixx likes this.
  12. Yeah :D Now the plugin can create, use and save the config

    How can I create a command variable, so that the plugin-user can decide, which command he want to use?

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

    theguynextdoor

    Can you explain this a bit more?
     
  14. Ok:

    Example:

    The player write in the config AcceptRules , so if he write /acceptrules ingame, he gets a better rank
    If he write Hello in the config, he can type /hello
    So I thought, I have to use a variable in the plugin.yml
     
  15. Offline

    theguynextdoor

    Hmm, never done this before. I suppose you could possibly use
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("derp") || commandLabel.equalsIgnoreCase(config.getString("Command.stuff")) {

    But like i said, never done this before so i can not guarantee it will work
     
  16. It dont know, whats "config again. But I think that you only can use commands that are in the plugin.yml, and there, you cant add variables.
     
Thread Status:
Not open for further replies.

Share This Page