1

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;
        buffer = null;
        super.destruct();
 }
4

2 回答 2

2

本节:

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

是这样读的:

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

所以返回之后的任何代码都不会运行。

于 2011-08-20T02:10:31.977 回答
0

你需要改变这个:

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

对此

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

您的 IDE 应该具有格式化或美化代码的功能。它将修复缩进,从而轻松发现您遇到的错误。

于 2011-08-20T02:12:52.157 回答