Bukkit Not Loading My Plugin!!!

Discussion in 'Plugin Development' started by CastsCogs, Nov 1, 2012.

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

    CastsCogs

    i made a plugin earlier today here is the code
    Code:
    package me.hamship.FireRage;
     
    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;
     
    public class main extends JavaPlugin{
        public final Logger logger = Logger.getLogger("Minecraft");
        public static main plugin;
     
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Has Been Disabled!");
        }
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Version " +pdfFile.getVersion() + " Has Been Enabled!");
            getConfig().options().copyDefaults(true);
            saveConfig();
        }
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
            Player player = (Player) sender;
                    if(commandLabel.equalsIgnoreCase("burn"))
                    {player.setFireTicks(999999999);
                        if(player.getServer().getPlayer(args[0])!= null){
                            player.sendMessage("This player is not online!");
                    }else if(commandLabel.equalsIgnoreCase("heal"))
                    {player.setHealth(20);
                        player.setFireTicks(0);
                        if(player.getServer().getPlayer(args[0])!= null){
                            player.sendMessage("This player is not online!");
                    }else if(commandLabel.equalsIgnoreCase("h"))
                    {player.setHealth(20);
                        player.setFireTicks(0);
                        if(player.getServer().getPlayer(args[0])!= null){
                            player.sendMessage("This player is not online!");
                    }}else if(args.length == 1){
                    if(player.getServer().getPlayer(args[0])!= null){
                        Player targetPlayer = player.getServer().getPlayer(args[0]);
                        targetPlayer.setHealth(20);
                        targetPlayer.setFireTicks(0);
                        player.sendMessage(ChatColor.GREEN + "You have been healed");
                    }else if(commandLabel.equalsIgnoreCase("motd"))
                        player.sendMessage(getConfig().getString("MOTD"));
                    }     
                }
                }
                    return false;
                         
            }
        }
     
    their are no errors but bukkit just doesnt respond to the commands! i am new to making plugins so please excuse me if i did something massively wrong! i have the plugin.yml done and the config.yml as well. i have no idea how to fix this though!!!
     
  2. Offline

    Unscrewed

    Holy crap.
    Erhm, you forgot to put in all the 'return true;'s and..
    if you're working with Eclipse, press CTRL + Shift + F every once in a while. =p
    Also, the onCommands aren't done properly.

    Anyway, I will fix this for you and message you.
     
  3. Offline

    Woobie

    CastsCogs
    Your code has so many mistakes..
    Did you make the plugin.yml file?

    This
    Code:
    if(player.getServer().getPlayer(args[0])!= null){
                            player.sendMessage("This player is not online!");
    Is a total fail
     
  4. Offline

    cman1885

    Especially because he checks after he performs the action.
     
  5. Offline

    Unscrewed

    Don't hurt the kid, at least he's trying.
    We should encourage people that try themselves instead of bug developers.
     
    fireblast709 likes this.
  6. Offline

    müsli1

    Yes, at least he's trying ;)

    I fixed all the errors:

    Code:
    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;
     
    public class main extends JavaPlugin{
     
        //It's your Plugin:
     
        public final Logger logger = Logger.getLogger("Minecraft");
        public static main plugin;
     
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Has Been Disabled!");
        }
     
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Version " +pdfFile.getVersion() + " Has Been Enabled!");
            getConfig().options().copyDefaults(true);
            saveConfig();
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
     
            //first of all:
            if(sender instanceof Player) {
                Player player = (Player) sender; //Getting the Player
                if(commandLabel.equalsIgnoreCase("burn")) {
                    if(args.length == 1) { //Checking the length
                        if(player.getServer().getPlayer(args[0]) == null) { // == null!
                            player.sendMessage("This player is not online!"); //Not online
                            return true;
                        }
                        else if(player.getServer().getPlayer(args[0]) != null) {
                            Player targetplayer = player.getServer().getPlayer(args[0]);
                            targetplayer.setFireTicks(999999999);
                            return true;
                        }
                    }
                    else if(args.length == 0) {
                        player.setFireTicks(999999999);
                        return true;
                    }
                }
                    //Ufff that was the /burn command!
         
                if(commandLabel.equalsIgnoreCase("heal") || commandLabel.equalsIgnoreCase("h")) { //If the commandLabel equals 'heal' OR 'h'
                    if(args.length == 1) { //Checking the length
                        if(player.getServer().getPlayer(args[0]) == null) { // == null!
                            player.sendMessage("This player is not online!"); //Not online
                            return true;
                        }
                        else if(player.getServer().getPlayer(args[0]) != null) {
                            Player targetplayer = player.getServer().getPlayer(args[0]);
                            targetplayer.setFireTicks(0);
                            targetplayer.setHealth(20);
                            //targetplayer.sendMessage(ChatColor.GREEN + "You have been healed"); !That's just a suggestion!
                            return true;
                        }
                    }
                    else if(args.length == 0) {
                        player.setFireTicks(0);
                        player.setHealth(20);
                        player.sendMessage(ChatColor.GREEN + "You have been healed");
                        return true;
                    }
                }
                    //The /heal command!
         
                if(commandLabel.equalsIgnoreCase("motd")) {
                    player.sendMessage(getConfig().getString("MOTD"));
                    return true;
                }
         
                    //The /motd command :/
            }
     
            return false;
     
        }
    } //The end!
    
    Hope that help :)


    EDIT: Oh i forgot the plugin.yml file :(

    Here it is:

    Code:
    name: FireRage
    main: me.hamship.FireRage.main
    version: 1.0
    commands:
      burn:
          description: Description
          usage: /<command> <Player>
          permission: FireRage.burn
          permission-message: You don't have FireRage.burn Permission
      heal:
          description: Description
          usage: /<command> <Player>
          permission: FireRage.heal
          permission-message: You don't have FireRage.heal Permission
      h:
          description: Description
          usage: /<command> <Player>
          permission: FireRage.heal
          permission-message: You don't have FireRage.heal Permission
      motd:
          description: Description
          usage: /<command> <Player>
          permission: FireRage.motd
          permission-message: You don't have FireRage.motd Permission
     
    Unscrewed likes this.
  7. Offline

    CastsCogs

    thanks guys xD

    but can you explain why you put:
    Code:
                        }
                        else if(player.getServer().getPlayer(args[0]) != null) {
                            Player targetplayer = player.getServer().getPlayer(args[0]);
                            targetplayer.setFireTicks(999999999);
                            return true;
                        }
                    }
                    else if(args.length == 0) {
                        player.setFireTicks(999999999);
                        return true;
    
    when you already had
    Code:
    if(player.getServer().getPlayer(args[0]) == null) { // == null!
                            player.sendMessage("This player is not online!"); //Not online
                            return true;
                        }
          
    ???

    will use this to help me update it :)

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

    müsli1

    You're welcome! :)

    Do that! :D
     
  9. Offline

    CastsCogs

    thanks man :) it works fine now xD

    go up i edited it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
Thread Status:
Not open for further replies.

Share This Page