Command Wont work!

Discussion in 'Plugin Development' started by MinecraftMart, Apr 10, 2013.

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

    MinecraftMart

    Hey. I made an command that has no errors and should work fine! But when i tipe /run it doesnt work. Here is the code. Maybe it is the plugin.yml but here.

    Code.
    Code:
    package me.mart.WitchCraft;
     
     
    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;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.*;
     
    public class WitchCraft extends JavaPlugin {
        public final Logger logger = Logger.getLogger("Minecraft");
        public static WitchCraft plugin;
     
        @Override
        public void onDisable() {
            PluginDescriptionFile pdffile = this.getDescription();
            this.logger.info(pdffile.getName() + " Has Been Disabled");
        }
     
     
     
        @Override public void onEnable(){
            this.logger.info("Has Been Enabled");
       
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender;
            if(commandLabel.equalsIgnoreCase("run")) {
                player.sendMessage(ChatColor.RED + "You Can Now Run Fast Forever.");
            PotionEffect speed = PotionEffectType.SPEED.createEffect(999999999, 7);
                    player.addPotionEffect(speed, true);
            }
            return false;
           
        }
    }
    plugin.yml
    Code:
    name: WitchCraft
    main: me.mart.WitchCraft.WitchCraft
    version: 1.0
    commands:
    Plls help
     
  2. Offline

    x0pk1n

    Read this : http://wiki.bukkit.org/Plugin_Tutorial you haven't added the command to the yml and you have not implemented the CommandExecutor, from a quick scan.

    Both off which are mentioned in the wiki.
     
    justcool393 likes this.
  3. Offline

    noraver

    :confused: your plugin.yml is missing the command or did u just forget to past it

    Code:
    commands:
        run:
          description: run boy run
          usage: /<command>
     
  4. Code:
    commands:
      run:
        description: Lets you run fast forever.
        usage: /<command>
     
  5. Offline

    noraver

    Raz we on the same page =P
     
  6. Offline

    MinecraftMart

  7. Offline

    x0pk1n

    Raz MinecraftMart noraver

    If you read my post you'd have seen I said that and also then it will not work when he adds that, as he is still missing something.
     
  8. Offline

    MinecraftMart

    x0pk1n

    He is right doesnt work. What do i miss then?
     
  9. Offline

    noraver

    the problem lays with your duration this should fix that
    [​IMG]

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender;
            if(commandLabel.equalsIgnoreCase("run")) {
                player.sendMessage(ChatColor.RED + "You Can Now Run Fast Forever.");
            PotionEffect speed = PotionEffectType.SPEED.createEffect(98300, 7);
            player.addPotionEffect(speed, true);
            }
            return false;
       
        }
     
  10. Offline

    MinecraftMart

    Solved Thx for everybodys help!
     
  11. Offline

    noraver

  12. I just clarified what he was missing as you simply linked wiki which is quite unclear if you he's a fairly new developer, about the commandexecutor, that's not required.
     
  13. Offline

    x0pk1n

    Raz "you haven't added the command to the yml" Says that in my post, the wiki just talks about it. Why isn't the implements CommandExecutor needed?
     
  14. Offline

    MinecraftMart

    K. So now i have another effect implemented. The plugin.yml is all good. So i did onCommand again but i needed to change it to onCommand1.
    Now nothing works. When i type the command. only /run comes up.
     
  15. Offline

    Compressions

  16. Offline

    SnipsRevival

    Add return true to the parts that actually do stuff.
     
  17. Offline

    Compressions

  18. Offline

    SnipsRevival

    Compressions He does say
    which leads me to believe it is always returning his usage that is stated in plugin.yml. I am curious to know why you disagree because perhaps I am misunderstanding something.
     
  19. Because he's not using CommandExectutor.
     
  20. Offline

    MinecraftMart

    Can you tell me how to use?
     
Thread Status:
Not open for further replies.

Share This Page