Public Boolean Is An Error

Discussion in 'Plugin Development' started by MCPlaysMC Productions, Jan 16, 2015.

Thread Status:
Not open for further replies.
  1. This is for my custom heal plugin. But my boolean is coming up as an error:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){

    Here Is The Full Plugin:
    package techinfo.info.org;

    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 Plugin extends JavaPlugin {

    public final Logger logger = Logger.getLogger("Minecraft");
    public static Plugin 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() + " Version " + pdfFile.getVersion()
    + " Has Been Enabled!");


    @SuppressWarnings("deprecation")
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    Player player = (Player) sender;
    if(player.hasPermission("system.heal")){
    if(commandLabel.equalsIgnoreCase("heal")){
    if(args.length == 0){
    player.setHealth(20.0);
    player.setFireTicks(0);
    player.sendMessage(ChatColor.GREEN + "You have been healed!");
    }else if(args.length == 1){
    if(player.getServer().getPlayer(args[0])!=null){
    Player target = player.getServer().getPlayer(args[0]);
    target.setHealth(20.0);
    target.setFireTicks(0);
    player.sendMessage(ChatColor.GREEN + "" + target + " has been healed.");
    target.sendMessage(ChatColor.GREEN + "You have been healed by §6" + player.getName() + "!");
    }else{
    player.sendMessage("§4I'm sorry but you can't heal this player. He is currently offline.");
    }

    return false;
    }
    }
    }
    }
    }}
     
  2. Offline

    Ridan

    First, If you're posting code please use the code tool, it looks way better and its handier to read.
    Second, Not sure what the problem is, Could you post the full error on pastebin or somewhere you like? I'd might solve your problem.

    EDIT: Might be because you're not returning a boolean at the end, Try putting "return true;" at the last line of the method, (not the class!)
     
  3. Offline

    Skionz

    You aren't returning anything. Your return type is boolean yet you don't return a boolean.
    Is there a solution? Yes, stop watching TheBCBroz.
     
  4. Offline

    teej107

    A basic knowledge of Java is required to develop Bukkit plugins. I suggest you learn Java (here is a great tutorial) and stop watching YouTube tutorials as they (especially the one you are using) are terrible. When you have an understanding of Java, the Bukkit's plugin tutorial is one of the best tutorials you can use. http://wiki.bukkit.org/Plugin_Tutorial
     
Thread Status:
Not open for further replies.

Share This Page