我收到了这个错误:
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
这是代码:
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();
}
答案 0 :(得分:2)
本节:
if(session == null)
Server.panel.removeEntity(playerName);
return;
读起来像这样:
if(session == null) {
Server.panel.removeEntity(playerName);
}
return;
因此返回后的任何代码都不会运行。
答案 1 :(得分:0)
你需要改变这个:
if (session == null)
Server.panel.removeEntity(playerName);
return;
到这个
if (session == null)
{
Server.panel.removeEntity(playerName);
return;
}
您的IDE应该具有格式化或漂亮代码的功能。它将修复缩进,以便轻松发现您遇到的错误。