Can't get plugin.yml to work for multiple commands

Discussion in 'Plugin Development' started by kmccmk9, Nov 10, 2012.

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

    kmccmk9

    Hello, I'm trying to get the plugin.yml to work for multiple commands but it keeps giving me errors when it tries to load the plugin. What did I do wrong?

    Code:
    name: HDSkinner
    main: com.kmccmk9.HDSkinner.HDSkinner
    version: 0.1
    author: kmccmk9
    description: A plugin that allows you to change your skin and cape!
    commands:
        skin:
            description: Change your skin to the url provided.
            usage: /<command> [url]
        cape:
            description: Change your cape to the url provided.
            usage: /<command> [url]
           
    permissions:
     
    gomeow likes this.
  2. Offline

    gomeow

    Maybe it's a problem with your code?
     
  3. Offline

    kmccmk9

    Thanks for the reply, here is my code. The first command works, but the other one does not.

    Code:
    package com.kmccmk9.HDSkinner;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Server;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.getspout.spoutapi.SpoutManager;
    import org.getspout.spoutapi.player.SpoutPlayer;
     
    public class HDSkinner extends JavaPlugin {
        //Variables
        Server server;
       
        public void onDisable()
        {
            System.out.print("HDSkinner is disabled");
        }
       
        public void onEnable()
        {
            System.out.print("HDSkinner is enabled");
            server = this.getServer();
        }
       
        public boolean onCommand(CommandSender sender,Command command, String commandLabel,String args[])
        {
            if (sender instanceof Player)
            {
                Player player = (Player) sender;
                SpoutPlayer splayer = SpoutManager.getPlayer(player);
                if(commandLabel.equalsIgnoreCase("skin"))
                {
                    if (args.length == 1)
                    {
                        if (args[0].equalsIgnoreCase("help"))
                        {
                            player.sendMessage(ChatColor.BLUE + "Type the command skin followed by the url to change your skin to that url.");
                        }
                        else
                        {
                            splayer.setSkin(args[0]);
                        }
                    }
                    else
                    {
                        player.sendMessage(ChatColor.DARK_RED + "Arguments mismatch. Type the skin command followed by help.");
                    }
                }
                else if(commandLabel.equalsIgnoreCase("cape"))
                {
                    if (args.length == 1)
                    {
                        if (args[0].equalsIgnoreCase("help"))
                        {
                            player.sendMessage(ChatColor.BLUE + "Type the command cape followed by the url to change your cape to that url.");
                        }
                        else
                        {
                            splayer.setCape(args[0]);
                        }
                    }
                    else
                    {
                        player.sendMessage(ChatColor.DARK_RED + "Arguments mismatch. Type the cape command followed by help.");
                    }
                }
            }
            return true;   
        }
     
    }
    
     
  4. Offline

    gomeow

    Have you tried taking out the first command and just including the second one?
     
  5. Offline

    GodzOfMadness

    I think the problem is with his plugin.yml
    it could be wrong spacing or you are using TAB
    you have to get it correct or it wont work

    Edit: it could also be your doing else if(
    all you have to do is if(cmd.getName().equalsIgnoreCase("whatever")){
     
  6. Offline

    gomeow

    He said it worked for the first command though

    But for yml, 2 spaces instead of tab
     
  7. Offline

    GodzOfMadness

    i know he said for the first command but if he put tabs in the second command on his .yml
    then it wouldnt work
     
  8. Offline

    Sagacious_Zed Bukkit Docs

    Curious but what error was bukkit giving you before hand? And it is better to separate your command logic into different executors.
     
  9. Offline

    kmccmk9

    Okay well I did use the TAB so that could be the issue. The error is that it didn't like the /symbol in my plugin.yml before cape.

    What exactly do you mean?

    Both commands in the yml have tabs

    I will change it to an if statement.

    Okay, just to update these are my updated files and it still creates an error on enable...

    Plugin YML
    Code:
    name: HDSkinner
    main: com.kmccmk9.HDSkinner.HDSkinner
    version: 0.1
    author: kmccmk9
    description: A plugin that allows you to change your skin and cape!
    commands:
      skin:
        description: Change your skin to the url provided.
          usage: /<command> [url]
      cape:
        description: Change your cape to the url provided.
          usage: /<command> [url]
         
    permissions:
    Jar File
    Code:
    package com.kmccmk9.HDSkinner;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Server;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.getspout.spoutapi.SpoutManager;
    import org.getspout.spoutapi.player.SpoutPlayer;
     
    public class HDSkinner extends JavaPlugin {
    //Variables
    Server server;
     
    public void onDisable()
    {
    System.out.print("HDSkinner is disabled");
    }
     
    public void onEnable()
    {
    System.out.print("HDSkinner is enabled");
    server = this.getServer();
    }
     
    public boolean onCommand(CommandSender sender,Command command, String commandLabel,String args[])
    {
    if (sender instanceof Player)
    {
    Player player = (Player) sender;
    SpoutPlayer splayer = SpoutManager.getPlayer(player);
    if(commandLabel.equalsIgnoreCase("skin"))
    {
    if (args.length == 1)
    {
    if (args[0].equalsIgnoreCase("help"))
    {
    player.sendMessage(ChatColor.BLUE + "Type the command skin followed by the url to change your skin to that url.");
    }
    else
    {
    splayer.setSkin(args[0]);
    }
    }
    else
    {
    player.sendMessage(ChatColor.DARK_RED + "Arguments mismatch. Type the skin command followed by help.");
    }
    }
    if(commandLabel.equalsIgnoreCase("cape"))
    {
    if (args.length == 1)
    {
    if (args[0].equalsIgnoreCase("help"))
    {
    player.sendMessage(ChatColor.BLUE + "Type the command cape followed by the url to change your cape to that url.");
    }
    else
    {
    splayer.setCape(args[0]);
    }
    }
    else
    {
    player.sendMessage(ChatColor.DARK_RED + "Arguments mismatch. Type the cape command followed by help.");
    }
    }
    }
    return true;
    }
     
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  10. Offline

    fireblast709

    http://yaml-online-parser.appspot.com/ for validating (and testing if it is correct, and trying to get it correct etc)
    Code:
    name: HDSkinner
    main: com.kmccmk9.HDSkinner.HDSkinner
    version: 0.1
    author: kmccmk9
    description: A plugin that allows you to change your skin and cape!
    commands:
      skin:
        description: Change your skin to the url provided.
        usage: /<command>
      cape:
        description: Change your cape to the url provided.
        usage: /<command> permissions: 
    the correct YAML
     
  11. Offline

    kmccmk9

    Even with what you posted it gives this error
     
  12. Offline

    fireblast709

    a copy-paste failure of me:
    Code:
    name: HDSkinner
    main: com.kmccmk9.HDSkinner.HDSkinner
    version: 0.1
    author: kmccmk9
    description: A plugin that allows you to change your skin and cape!
    commands:
      skin:
        description: Change your skin to the url provided.
        usage: /<command>
      cape:
        description: Change your cape to the url provided.
        usage: /<command>
    permissions: 
     
  13. Offline

    kmccmk9

    Cool, well this is what I have but my server is still throwing the same error and I don't know why.

    Code:
    name: HDSkinner
    main: com.kmccmk9.HDSkinner.HDSkinner
    version: 0.1
    author: kmccmk9
    description: A plugin that allows you to change your skin and cape!
    commands:
      skin:
        description: Change your skin to the url provided.
        usage: /<command> [url]
      cape:
        description: Change your cape to the url provided.
        usage: /<command> [url]
     
  14. Offline

    gomeow

    Can you post the error
     
  15. Offline

    fireblast709

    weird because this is telling me it is correct (ignore the weird version number in the right):
    shortened it because it was too long in text

    Still the error at the '/'? Because it does not complain if I put it in my plugin.yml... Can you post a stacktrace?

    Code:
    found character'\t' that cannot start any token
    It found a tab character. Try finding that one and remove it.

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

    kmccmk9

    That's the thing I can't find one. I used spaces only.

    I don't know if anyone will believe me but I just tried running the server again and it worked this time...

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

    gomeow

    Hmm, do you have a extra line at the end?

    Oh, well then, good job

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

Share This Page