2014-04-25 76 views
-3

我對java很陌生,這是我的第一個項目。我已經結束了,但它說「語法錯誤,插入 「}」 來完成ClassBody 這裏是我的代碼:。語法錯誤,插入「}」以完成ClassBody,初學者

package me.IPK.MFP; 

import java.util.logging.Logger; 

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 MFP extends JavaPlugin{ 
    public final Logger logger = Logger.getLogger("Minercraft"); 
    public static MFP 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(commandLabel.equalsIgnoreCase("p")){ 
      if(args.length == 0){ 
       player.setHealth(20); 
       player.kickPlayer(args[0]); 
      } 
     } 
    } 

幫助是極大的讚賞

+1

也許如果您正確縮進代碼,問題會比顯式錯誤消息更加明顯。 –

+1

只需按照_「insert」}「來完成ClassBody」_!正如你所看到的,你沒有用閉括號'}'關閉你的類。並且,請正確地縮進你的代碼。 – Baby

+0

[語法錯誤插入}可能重複以完成classbody](http://stackoverflow.com/questions/4030032/syntax-error-insert-to-complete-classbody?rq=1) –

回答

1

做什麼它說

。在您的文件末尾添加一個}

每個開放的大括號都需要一個匹配的大括號,並且您忘記在第一個大括號中添加一個大括號如果您的代碼格式正確,這些錯誤。

0

編譯器告訴你,你還沒有關閉你開始的代碼塊。代碼塊總是以'{'開頭,並用'}'關閉。所以你總是照顧他們。