just wont work

Discussion in 'Plugin Development' started by Rasmase, Apr 9, 2012.

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

    Rasmase

    When i do the command it says it dont exist. when i look in console there isnt even an error code!
    Main class(The only one)
    Code:
    package com.gmail.rasmase.BukkitTest;
     
    import java.util.logging.Logger;
     
    import org.bukkit.plugin.java.*;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.*;
    import org.bukkit.entity.*;
     
     
    public class BukkitTest extends JavaPlugin {
        Logger log = this.getLogger();
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            if(cmd.getName().equalsIgnoreCase("burnme")) { // If the player typed /killme then do the following...
                if ((sender instanceof Player)) {
                    Player s = (Player)sender;
                    s.setFireTicks(10000);
                } else {
    log.info("*Login please");
                }
                return true;
                } else if (cmd.getName().equalsIgnoreCase("killme")) {
    if ((sender instanceof Player)) {
    Player s = (Player)sender;
    s.setHealth(0);
    } else {
    log.info("Login please");
    }
    return true;             
                }
            return false;
        }
    }
    
    (Plugin.yml)
    Code:
    name: BukkitTest
    main: com.gmail.rasmase.BukkitTest
    version: 1.00
     
    commands:
      killme:
          description: This kills the player.
          usage: /killme
      burnme:
          description: This kills the player.
          usage: /burnme
     
  2. Offline

    acuddlyheadcrab

    Well you do know that you have to have onEnable() and onDisable() in your plugin class right? Also, you should use the @Override tag with all the inherited JavaPlugin classes. Look at that link to see what the inherited class from bukkit looks like.

    Also try doing "usage: /<command>" instead of "usage: /killme". Bukkit automagically replaces <command> with the command the user typed in to get there.
     
  3. Offline

    Sagacious_Zed Bukkit Docs

    Actually, onEnable and onDisable should no longer mandatory, as they are now concrete instead of abstract. You can try overriding with nothing in the body but i dont think that will do anything.
     
  4. Offline

    dillyg10

    that would be the problem.. use
    Code:java
    1.  
    2. public static Logger log = Logger.getLogger("Minecraft");
    3.  


    Also.. I would recommend using this check for the sender...
    Code:java
    1.  
    2. if (!(sender instanceof Player)) {
    3. sender.sendMessage(ChatColor.RED+"You must login to do this!");
    4. return true;
    5. }
    6.  

    it's just a little bit cleaner :).
     
  5. Offline

    Darkman2412

    Rasmase: you only define the package as main, the class name must be there too.
    Code:
    main: com.gmail.rasmase.BukkitTest.BukkitTest
     
Thread Status:
Not open for further replies.

Share This Page