[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

    WhaleAnarchy

    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.

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


    Plugin.yml:
    Code:java
    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.

    getCommand("example").setExecutor(this);

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

    Goblom

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

    Code:
    name: Example
    version: 1.0
    author: WhaleAnarchy
    main: Main
    commmands:
      example:
        description: Example Command
    permissions:
      example.*
        description: Example
        default: OP
      example.kit:
        description: Example
        default: OP
      example.kit2:
        description: Example
        default: OP
     
  4. Offline

    Garris0n

  5. Offline

    WhaleAnarchy

    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

    beastman3226

    WhaleAnarchy
    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

    WhaleAnarchy

    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()?

    beastman3226

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

    WhaleAnarchy

    Bump...

    CAN SOMEONE PLZ HELP MEEEE!? :(

    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

    mbcx2

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

    Garris0n

    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

    mbcx2

    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

    EcMiner

    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

    Garris0n


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

    1Rogue


    Setting parent nodes
     
  17. Offline

    Nateb1121

    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

    1Rogue


    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

    WhaleAnarchy

    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

    Garris0n

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


     
  21. Offline

    Gater12

    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

    Nateb1121

    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

    WhaleAnarchy

    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