Need help with commands.

Discussion in 'Plugin Development' started by ZaneBaney, Jun 1, 2013.

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


    Hey all, new to java here. I just made a simple plugin which returns a message to the command sender, The plugin shows up when I type /plugins (Comes up as 'Plugin' because that is what I named it I'm guessing) However when I type the command /sendme it does not return the message; Any help guys?? Here is the code: (Sorry for the terrible laying out, I'm new as I said)
    package me.Zane_Collix.plugin;
    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;

    public class Plugin extends JavaPlugin{
    public static Logger Logger = java.util.logging.Logger.getLogger("Minecraft");
    public static Plugin plugin;

    public void onDisable() {
    PluginDescriptionFile pdfFile = this.getDescription(); + " Has Been Disabled!");

    public void onEnable() {

    PluginDescriptionFile pdfFile = this.getDescription(); + " " + pdfFile.getVersion() + " Has Been Enabled!");


    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,String[] args) {
    Player player = (Player) sender;
    if(commandLabel.equalsIgnoreCase("sendme")) {
    player.sendMessage(ChatColor.AQUA + "Plugin is working!");

    return false;



    And just incase you need it the plugin.yml:

    name: Plugin
    main: me.Zane_Collix.plugin.Plugin
    version: 1.0
    description: >
    Youtube Plugin.
    description: Sends the player a message!
  2. Offline


    Not too sure how the brackets work as I'm on a phone but one of the issues is that you are returning false when the command was executed.

    Also, player sender is not needed as you defined the command sender before, CommandSender sender so sender.sendMessage works like a charm.
  3. Offline


    themadman300 It's not an issue when you return false. Basically returning false sends you a message of the usage. If there is no usage in your plugin.yml then it just sends you the command name. So like if i were to type /bet and when I return false it's going to message me "/bet"
Thread Status:
Not open for further replies.

Share This Page