onCommand... again plygin.yml

Discussion in 'Plugin Development' started by Moon_werewolf, Mar 3, 2011.

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

    Moon_werewolf

    i have tryed the past 3 days to get the stuped onCommand to work but i dont know why i wount :(

    plygin.yml
    Code:
    public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
        {
            sender.sendMessage("You did a command!");
            return false;
        }
     
  2. Offline

    Raider

    your yml file needs to be properly indented
    Code:
    name: mGold
    main: com.moon_werewolf.mGold.mGold
     version: 0.95
     command:
        shop:
           description: Use the shop
           usage: /<command>
    
    Remember that you will need to do /shop for it to send the message
    ps version and command arent meant to be indented.. dont know why it appears like that -.-'
     
  3. Offline

    Moon_werewolf

    it don't work. nothing happens :/
     
  4. Offline

    Raider

    did you do /shop?
    Also, are you putting onCommand in your playerlistener class, or the main class?
    --- merged: Mar 3, 2011 9:29 AM ---
    did you do /shop?
    Also, are you putting onCommand in your playerlistener class, or the main class?
     
  5. Offline

    Moon_werewolf

    i tried both
     
  6. Offline

    Android

    The command needs to be in your main class.

    Also, the sender isn't always a player, so you need to check for that as well. Ex:

    Code:
     public boolean onCommand(CommandSender sender, Command command, String label,String[] args){
    	if (!(sender instanceof player))
    		return false;
    	sender.sendMessage("You did a command!");
    	return true; }
     
  7. Offline

    Moon_werewolf

    still dont work :/ adn i can't understand why

    here is a part of my mGold.java file
    http://pastebin.com/hyuaYiBE

    and here is the plugin.yml
    http://pastebin.com/Vwi8aUUp
     
  8. Offline

    petteyg359

    Your plugin.yml is still not right. Indentation is four spaces per level.
     
  9. Offline

    xZise

    Is it my browser or is the version/command tag intended with one space?

    Fabian
     
  10. Offline

    Moon_werewolf

    the are no spaces on both of them

    who should it be with the spaces? like


     
  11. Offline

    xZise

    Yep but multiply them by 4:
    Code:
    name: mGold
     main: com.moon_werewolf.mGold.mGold
     version: 0.95
     command:
     ␣␣␣␣shop:
     ␣␣␣␣␣␣␣␣description: Use the shop
    ␣␣␣␣␣␣␣␣usage: /<command>
    Replace the ␣ by a space.

    Fabian
     
  12. Offline

    Moon_werewolf

    still not working :confused: i dont get any error messages except

     
  13. Offline

    xZise

    This is strange. Is the plugin loaded? And do you get any exception?

    Fabian
     
  14. Offline

    Moon_werewolf

    yes it is loaded

    i currently moved the some functions to PLAYER_CHAT and used - instead of / so i could test if they worked. but the code with /shop don't work :confused:

    start log
     
  15. Offline

    xZise

    What happens if you execute "shop" in the console. Also two spaces working instead of four.

    Fabian
     
  16. Offline

    Moon_werewolf

    "unknow console command" and with 2 space with "shop" still the same :/
     
  17. Offline

    xZise

    Okay that is strange. How old is your craftbukkit version? I see you using not the one from jenkins (as there is no build number). Also could you please check if the correct version is loaded (not an outdated)?

    Fabian
     
  18. Offline

    Moon_werewolf

    I'm using eclipse to download the version. i tested to download newest from this homepage http://ci.bukkit.org/job/dev-CraftBukkit/ but it was exactly like the other version i haved
     
  19. Offline

    GDorn

    I'm having the exact same problem. I checked with getCommand("recipes") and got null, and my yml looks like:

    Code:
    name: AlchemicalCauldron
    main: com.foo.alchemicalcauldron.AlchemicalCauldron
    version: 0.0.6
    command:
      recipes:
        description: Display a list of known alchemy recipes.
        usage: /<command>
     
  20. Offline

    Jonbas

    You guys are including bukkit in your eclipse build right? Not craftbukkit.

    And you spelled it plugin.yml not plygin.yml, right?
     
  21. Offline

    Moon_werewolf

    yes. my plugin works (the damage block part) but no the onCommand :/
     
  22. Offline

    xZise

    Why should this be relevant?
    Then the plugin won't load.

    Fabian
     
  23. Offline

    tickleman

    Try commands with an "s" instead of command, I'm sure this will be better.
    Thanks for your topic, which made me understand we needed a "commands" configuration section into the plugin.yml file.
     
  24. Offline

    Moon_werewolf

    nope that don't work :(
     
  25. Offline

    tickleman

    Here is mine, that do work :
    Be sure tabs are spaces characters and 4 spaces long !

    Code:
    name: RealShop
    main: fr.crafter.tickleman.RealShop.RealShopPlugin
    version: 0.37
    authors:
        - tickleman1
    commands:
        shop:
            description: chest-shops commands
            usage : /<command>
    
     
  26. Offline

    Moon_werewolf

    THX :D !!!! finally something that works. god i HATE plygin.yml (it is so picky)
     
  27. Offline

    xZise

    Ehr remove the space between the colon and usage! Also my plugin.yml configuration uses only 2 spaces for indentation!

    Fabian
     
  28. Offline

    tickleman

    I'm not a pro in yml files format. It's true that the important is spaces, and neat indentation, always same sized.
    Thanks for the 2 spaces, that's my prefferred indentation too... I probably will update my ymls too !

    have fun !
     
  29. Offline

    Moon_werewolf

    it work even with spaces. why my file din't work was for i was missing "authors:"
     
  30. Offline

    xZise

    I don't think so, because authors is an optional parameter. It's because you have to use “commands” instead of “command”.

    Fabian
     
Thread Status:
Not open for further replies.

Share This Page