开发者

Compiling error - unreachable statement

I'm getting this error:

src\server\model\players\Client.java:1089: error: unreachable statement
                        PlayerSave.saveGame(this);
                        ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

this is the code:

    public void destruct() {
                PlayerSave.saveGame(this);
                 if(disconnected == true) { 
                    saveCharacter = true;
                 }
        if(disconnected == true){
         getTradeAndDuel().declineTrade();
  }
        if(session == null) 
                Server.panel.removeEntity(playerName);
            return;
            PlayerSave.saveGame(this);
            if (clanId >= 0)
            Server.clanChat.leaveClan(playerId, clanId);
            getPA().removeFromCW(); 
            if (inPits) { 
            Server.fightPits.removePlayerFromPits(playerId);
        }
        Misc.println("[DEREGISTERED]: "+playerName+"");
        PlayerSave.saveGame(this);
                 saveCharacter = true;
        HostList.getHostList().remove(session);
        disconnected = true;
        session.close();
        session = null;
        inStream = null;
        outStream = null;
        isActive = false开发者_如何学C;
        buffer = null;
        super.destruct();
 }


This section:

if(session == null) 
            Server.panel.removeEntity(playerName);
        return;

is read like this:

if(session == null) {
    Server.panel.removeEntity(playerName);
}
return;

so any code after that return is not run.


You need to change this:

if (session == null) 
    Server.panel.removeEntity(playerName);
return;

to this

if (session == null) 
{
    Server.panel.removeEntity(playerName);
    return;
}

Your IDE should have a feature to format or pretty your code. It will fix up the indentations making it easy to spot errors like the one you encountered.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜