Development Assistance Plugin doesn't work!

Discussion in 'Plugin Help/Development/Requests' started by Ketchup112, Feb 24, 2015.

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

    Ketchup112

    So i just made my first plugin it's very simple but it doesn't work when i ran it, may be you guys can help me.
    Here is where it is located:
    Ketchup.test
    src
    me.ketchup112112.test
    test.java
    JRE System library
    Referenced Libraies
    craftbukkit.jar
    plugin.yml

    Here is the test.java
    Code:
    package me.ketchup112112.test;
    
    import java.util.logging.Logger;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.entity.Player;
    
    public class test extends JavaPlugin{
        public final Logger logger = Logger.getLogger("Minecraft");
        public static test plugin;
      
        @Override
        public void onDisable(){
        PluginDescriptionFile pdfFile = this.getDescription();
        this.logger.info(pdfFile.getName() + "Has Been Diabled!");
        }
      
        @Override
        public void onEnable(){
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + "Version " + pdfFile.getVersion() + "Has Been Enabled!");
        }
      
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args){
        Player player= (Player) sender;
        if(CommandLabel.equalsIgnoreCase("test")){
            player.sendMessage(ChatColor.GOLD + "Plugin is working!");
            player.setFlying(isEnabled());
            player.sendMessage(ChatColor.GOLD + "Also enabled fly!");
        }
        return false;
    }
    
    
    }
    
    And here's the plugin.yml:

    Code:
    name: Test
    main: me.ketchup112112.test.test
    version: 1.0
    description: >
                 Ketchup's plugin!
    commands:
      test:
        description: idk
    
    I hope you can help!
     
  2. Offline

    mc_myster

    Im not a expert but dont write your plugin.yml like that, write this:
    http://pastebin.com/C8nwh0yP

    And also, do you mind sending me the error from your console?
     
  3. Offline

    pie_flavor

    @Ketchup112 Here are plenty of things to think about.
    1. Logger.getLogger("Minecraft") won't always work. There is literally a method available which is just getLogger() inside the main class.
    2. You don't need a PluginDescriptionFile. You can just write the name of you plugin, silly.
    3. You don't need to say when it's disabled or enabled. This is already automatically logged.
    4. You don't need to say this except as an argument. You can just say getDescriptionFile(), or whatever other method you need.
    5. A player will not always be using your command. Don't automatically cast to player without checking if they are actually a player first.
    6. Why do you set flying to isEnabled()? That will always return true, because if it were disabled, your code wouldn't even be running.
    7. Don't return false unless the player has done the command wrong. Even if they don't have permission, or enough money, or something like that, always return true except for a syntax error. The boolean value dictates whether or not command blocks return values to a comparator, and whether or not the sender sees the 'usage' message that you defined in plugin.yml.
     
Thread Status:
Not open for further replies.

Share This Page