First Plugin. Need help with commands?

Discussion in 'Plugin Development' started by HDlowrider, Jul 20, 2012.

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

    HDlowrider

    So I am trying to have it so if a user types /website they will get the message "Test"
    This is the command part of the main class:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args){
       
        if(commandlabel.equalsIgnoreCase("website")){
        sender.sendMessage("Test");
        }
        return true;
    }
    Here is all of my main class:
    Code:
    package com.github.HDlowrider.WhatWebsite;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
     
    public class WhatWebsite extends JavaPlugin {
     
     
    public void onEnable(){
    PluginInfo("Enabled");
    }
     
    public void onDisable(){
    PluginInfo("Disabled");
    }
    public static void PluginInfo (String message){
    String v="0.1";
    System.out.println("WhatWebsite?"+v+" "+"has been"+message);
    }
    public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args){
       
        if(commandlabel.equalsIgnoreCase("website")){
        sender.sendMessage("Test");
        }
        return true;
    }
    }
     
    
    And finnally here is a screenshot of my Eclipse:
    [​IMG]
     
  2. Offline

    killjoy64

    Did you by chance register the command in the plugin.yml?
     
  3. Offline

    HDlowrider

    Yes.
    Here is my plugin.yml:
    Code:
    name: WhatWebsite
    main: com.github.HDlowrider.WhatWebsite.WhatWebsite
    version: 0.1
    website:
        description: Displays the servers website URL
        usage: /website
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Please read the documentation that is not the correct format, http://wiki.bukkit.org/Plugin_YAML
     
  5. plugin.yml not config.yml.
    You have that too but it's placed wrongly, I suggest you move it near config.yml and if you don't use a config (getConfig() ?) you should delete config.yml.

    Also, you should learn how to indent code or at least let Eclipse indent it for you, just press ctrl+i, you'll find code alot easier to read... and that helps us as well to understand your code alot easier.
     
  6. Offline

    HDlowrider

    Sorry, I said it wrong. I edited my post. I eddited my plugin.yml to this:
    Code:
    name: WhatWebsite
    main: com.github.HDlowrider.WhatWebsite.WhatWebsite
    version: 0.1
    commands:
      website:
        description: Displays the servers website URL.
        usage: Do /website to get the URL of this servers website.
    
    Reloaded my plugin, yet it still doesn't work :(
     
Thread Status:
Not open for further replies.

Share This Page