Need Help Making a SimplePlugin - 1st Time

Discussion in 'Plugin Development' started by GamerTechz, Jul 28, 2012.

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

    GamerTechz

    Ok so I would like to develop plugins for minecraft and I am following a tutorial and I did EVERY thing right, but the plugin wont work on the server.

    Please check over my code and make sure I am doing everything right, and If im not then please tell me the problem, this plugin is really simple, and Its suppoesed to say a message when the user types in the command "/sendme" without the quotes.

    The code:
    Code:
    package me.GamerTechzTTG.Simple;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import com.sun.istack.internal.logging.Logger;
     
    public class Simple extends JavaPlugin{
     
        public final Logger logger = Logger.getLogger("Minecraft", null);
       
        public static Simple plugin;
       
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + "  Has Been Disabled!");
           
           
        }
       
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + 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 + "This is a plugin created by TTGMaker");
               
            }
            return false;
           
        }
       
    }
    
     
  2. Offline

    Yocole

    Did you follow the tutorial by insanj? If you did his tutorial is out of date and the coding you do may not work.
     
  3. Offline

    GamerTechz

    No I followed a tutorial by : TheBcBroz
     
  4. Offline

    Butkicker12

    Moved to the plugin development forum.
     
  5. Offline

    JOPHESTUS

    Did you put the command in your plugin.yml?
     
  6. Offline

    d0de

    You need the command registered in the plugin.yml

    Heres an example

    Code:
    name: Simple
    main: me.GamerTechzTTG.Simple.Simple
    version: 1.0
    description: >
          Your Own Description
    commands:
     
      sendme:
        description: SendMe Command
     
    
    Now i spotted another error which maybe cause your plugin to not work.

    You did not import Logger from Bukkit , and

    this line

    Code:
        public final Logger logger = Logger.getLogger("Minecraft", null);
    to

    Code:
     public Logger logger = Logger.getLogger("Minecraft");
    Make sure you import Logger from Bukkit !

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

    r0306

    d0de
    GamerTechz
    No, no, no. You should never get the Minecraft logger unless it's for monitoring purposes. Each plugin has it's own logger and you should use that instead.
    Code:
    public static Logger log;
     
    public void onEnable()
    {
      log = this.getLogger();
    }
     
  8. Offline

    GamerTechz

    Ok Thanks man!
     
Thread Status:
Not open for further replies.

Share This Page