Plugin Help Need help with my plugin

Discussion in 'Plugin Help/Development/Requests' started by sammyg7241, Dec 16, 2014.

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

    sammyg7241

    Hi, I am making just a short little plugin just to start out, but when I try to run my command tester, it says unknown command. Can anyone help me out?

    Here is my main class file.
    Code:
    package me.sammyg7241.tester;
    
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Tester extends JavaPlugin{
        public static Tester instance;
        public final static Logger log = Logger.getLogger("Minecraft");
       
        public void onEnable() {
            Tester.instance = this;
            this.log("Tester has been enabled!", Level.INFO);
        }
       
        public void onDisbale() {
            this.log("Tester has been disabled!", Level.INFO);
        }
    
        public void log(String s, Level l) {
            Tester.log.log(l, "[Tester] "+s);
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
           
            if(!cmd.getName().equalsIgnoreCase("tester"))
                return false;
           
            if(sender instanceof Player) {
                // TODO Run command from player
                sender.sendMessage("This server is running version 1.0.0 of Tester. For a list of commands, type /tester help");
            }else {
                //TODO Run from console
                sender.sendMessage("You need to be a player to run this command!");
            }
           
            return true;
        }
       
    }
    
    Thanks!
     
  2. Offline

    timtower Administrator Administrator Moderator

    @sammyg7241 Did you register the command in your commands.yml?
     
  3. Offline

    sammyg7241

    No I didn't. Didn't even know I had to. Thanks :)

    Is there a tutorial for how to make the commands.yml for your plugin?

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

    timtower Administrator Administrator Moderator

    Bukkit has a wiki, there is a complete plugin tutorial and every file is explained.
     
Thread Status:
Not open for further replies.

Share This Page