[Not Solved] Plugin.yml = Devil 3

Discussion in 'Plugin Development' started by WhaleAnarchy, Oct 7, 2013.

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


    Hello again Bukkit,

    I have recently run into a problem with plugin.ymls again. I am developing a nice kit plugin for my server and it has arguments (of course), and I try and add permissions to them and the entire thing goes to hell! I am not going to give my code out however, so here is a little example of what I am saying.

    1. public void onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    2. Player player = (Player) sender;
    4. if(commandLabel.equalsIgnoreCase("example") && (args.length == 0)) {
    5. player.sendMessage("Example");
    7. } else if(args.length == 1) {
    9. if(args[0].equalsIgnoreCase("kit")) {
    10. if(player.hasPermission("example.kit") {
    11. player.sendMessage("Example");
    12. }
    14. } else if(args[0].equalsIgnoreCase("kit2")) {
    15. if(player.hasPermission("example.kit2") {
    16. player.sendMessage("Example 2");
    17. }
    19. }
    20. }
    21. }

    1. name: Example
    2. version: 1.0
    3. author: WhaleAnarchy
    4. main: Main
    5. commands:
    6. example:
    7. description: Example Command
    8. permissions:
    9. example.*
    10. description: Example
    11. default: OP
    12. example.kit:
    13. description: Example
    14. default: OP
    15. example.kit2:
    16. description: Example
    17. default: OP

    - WhaleAnarchy

  2. Instead of command label i would register the command.

    At command i would use only args.


    1. if (args.length > 0) {
    2. if (args[0].equalsIgnoreCase("example")) {
    3. if(player.hasPermission("nyancat.fly.example") {
  3. Offline


    Your plugin.yml has too many spaces under the commands Here is it fixed

    name: Example
    version: 1.0
    author: WhaleAnarchy
    main: Main
        description: Example Command
        description: Example
        default: OP
        description: Example
        default: OP
        description: Example
        default: OP
  4. Offline


  5. Offline


    Ok, I see that I am not getting my point across. I am trying to tell the plugin to connect the "permissions" with the command, but as you can see and know, with arguments you don't need to put them in the plugin.yml. So how would I point the permissions from the plugin.yml to their correct command?
  6. Offline

    Mathias Eklund

    Is there any errors or what? Why wont you give the code you have? As there might be something different about it?
  7. Offline


    Add the "permission" node under your command. That is the only way you can link permissions by using cmd.getPermission(). However, your code looks fine. If you donot want to use cmd.getPermission(). Simply type out the node. I would also check for the permission before I do anything else.
  8. Offline


    Ok, I will do that when I get back from school. Thanks beastman3226

    P.S. I probably won't respond soon

    Ok, so I am new, I have looked up what you told me and I found nothing. Can you tell me what you mean by cmd.getPermission()?


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




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

    Mathias Eklund

    remove the default notation.
  11. Offline


    Do not bump a lot, it is not allowed! ;)
  12. Offline


    It's allowed as long as you wait 24 hours (some people say 12, not sure), which he did just fine.

    WhaleAnarchy You must do your permission checks in the code with if(player.hasPermission("permission.permission") just like you did in the initial code you posted. You can't register them to the commands in the plugin.yml because you're using subcommands.
  13. Offline


    Oh I see, I did not look at the date the post is posted :p I know that 24/12 hour rule (I take the 24 hour rule :p, But I don't jump my threads, Just post updates)
  14. Offline


    mbcx2 Garris0n beastman3226 Goblom DreTaX Can anybody tell me the use of registering permissions in your plugin.yml? I mean, it works just fine without registering them in your plugin.yml, so why do that?
  15. Offline


    Setting descriptions, defaults, allowing other plugins / admins to see them, and stuff like that. It's not required.
  16. Offline


    Setting parent nodes
  17. Offline


    Alright. You want permissions in your Plugin.yml and you want the plugin.yml to handle permission things if I get you correctly. Here's everything you could possibly want to know: http://wiki.bukkit.org/Plugin_YAML

    The example there will show you how to do commands+permissions just fine. This should allow you to not need to do the whole "sender.hasPermission("x.x");" if I remember correctly. This will only apply to your main command, not subcommands (like ./kit 2) if you wanna do that, you'll need to do the "sender.hasPerm..." code.

    Oh, and when asking for help a few things:
    1) Don't explicitly tell people you won't give out your code, we get that, just supply the simpler version and apply the fixes we give you to your source.
    2) Don't just say, "entire thing goes to hell!" tell us what it's doing. We don't know if you're getting an error, what error, if your YAML isn't spaced right, etc. Be specific in your errors.
    3) Don't get defensive, don't use ALL CAPITOLS SINCE IT'S ANNOYING.
  18. Offline


    I would disagree with this. A simpler version might actually fix the issue since it could be something small causing a large issue. If you are coming here for help with your code then it probably isn't so exceptional or intuitive that no one else has ever done something similar. Avoiding showing your code is the same as avoiding an explanation of what's wrong.
  19. Offline


    Nateb1121 the thing is, and yes, I am going to use all caps because yolo, THERE ARE NO ERRORS! The plugin simply won't load. And why I said "the entire thing goes to hell!", is because that is EXACTLY what it does.

    And btw, when using subcommands you can't make the permissions in the plugin.yml connect directly to the subcommand and recognize it... so I am stumped on what to do.
  20. Offline


    Well I'm not sure exactly what's wrong with your code because

  21. Offline


    WhaleAnarchy I don't see anything wrong but then again it's an example and I may be blind too. What do you mean by "point the permission"? It's checking to see if player has the permission amd if it does then it executes it. At least that's what my mind says. Maybe showing the original code can help you, like maybe there's a flaw in the original that won't load the plugin or do what you desire for it to do.
  22. Offline


    You expect to get help then act like a child, show some respect for the people trying to help you. Going to hell is very different from won't load.

    Anyway, you say "The plugin simply won't load." Well, you should of said that in the first post. Do you have the jar saved correctly? Do you extend JavaPlugin? Do you know if the plugin is even running? (./pl should show you this, if your description of it not loading is true, it shouldn't show there) If the plugin "won't load" Bukkit will provide an error as to why it won't load the plugin.
  23. Offline


    Well, I don't know what I did but I fixed it somehow...
    Thanks for the help guys (Nateb1121 is an exception).

    - WhaleAnarchy
Thread Status:
Not open for further replies.

Share This Page