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:

    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;

    public class Plugin extends JavaPlugin {

    public final Logger logger = Logger.getLogger("Minecraft");
    public static Plugin plugin;

    public void onDisable() {
    PluginDescriptionFile pdfFile = this.getDescription(); + " Has Been Disabled!");

    public void onEnable() {
    PluginDescriptionFile pdfFile = this.getDescription(); + " Version " + pdfFile.getVersion()
    + " Has Been Enabled!");

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

    return false;
  2. Offline


    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


    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


    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.
Thread Status:
Not open for further replies.

Share This Page