-1
我試圖運行遊戲RuneScape的私人服務器。一段時間後,我的一個玩家去了我在服務器pestcontrol
中編程的迷你遊戲。玩家試圖加入它,但爲了能夠啓動它,他需要5個其他玩家才能工作。所以,他退出了。但之後,他的帳戶被清除,導致其他人也無效。我已經設法解決這個問題。但後來他看不見了,我看不到他的角色在遊戲中。 所以後來我工作了通過聲明如下:Java.lang.NullPointerException錯誤
if (player == null)
return;
該做的工作,使他再次可見。 但隨後仍然出現錯誤這一行的異常:
java.lang.NullPointerException
at net.kagani.game.player.controllers.pestcontrol.PestControlLobby.forceClose(PestControlLobby.java:52)
at net.kagani.game.player.ControlerManager.forceStop(ControlerManager.java:317)
at net.kagani.game.player.ControlerManager.login(ControlerManager.java:66)
at net.kagani.game.player.Player.sendInit(Player.java:1396)
at net.kagani.game.player.Player.run(Player.java:1233)
at net.kagani.game.player.Player.start(Player.java:886)
at net.kagani.executor.PlayerHandlerThread.initPlayer(PlayerHandlerThread.java:273)
at net.kagani.executor.PlayerHandlerThread.processLoginSession(PlayerHandlerThread.java:231)
at net.kagani.executor.PlayerHandlerThread.run(PlayerHandlerThread.java:65)
如果有人可以幫助我這個(重定向我給它)因爲我很願意學習了很多東西。 這是類本身:
package net.kagani.game.player.controllers.pestcontrol;
import net.kagani.Settings;
import net.kagani.game.WorldObject;
import net.kagani.game.minigames.pest.Lander;
import net.kagani.game.player.controllers.Controller;
import net.kagani.utils.Utils;
public final class PestControlLobby extends Controller {
private Lander lander;
@Override
public void start() {
this.lander = Lander.getLanders()[(Integer) getArguments()[0]];
}
@Override
public void sendInterfaces() {
if (player == null)
return;
int remainingTime = lander.getTimer().getMinutes();
player.getPackets().sendIComponentText(407, 3,
Utils.fixChatMessage(lander.toString()));
player.getPackets().sendIComponentText(
407,
13,
"Next Departure: " + remainingTime + " minutes "
+ (!(remainingTime % 2 == 0) ? " 30 seconds" : ""));
player.getPackets().sendIComponentText(407, 14,
"Player's Ready: " + lander.getByStanders().size());
player.getPackets().sendIComponentText(407, 16,
"Commendations: " + player.getCommendation());
player.getInterfaceManager().sendMinigameInterface(407);
}
@Override
public void magicTeleported(int teleType) {
player.getControlerManager().forceStop();
}
@Override
public boolean sendDeath() {
player.getControlerManager().forceStop();
return true;
}
@Override
public void forceClose() {
player.getInterfaceManager().removeMinigameInterface();
System.err.println("This is 1 error output that declares it here");
lander.exit(player);
}
@Override
public boolean logout() {
lander.remove(player);
return false;
}
@Override
public boolean canSummonFamiliar() {
player.getPackets()
.sendGameMessage(
"You feel it's best to keep your Familiar away during this game.");
return false;
}
@Override
public boolean processObjectClick1(WorldObject object) {
switch (object.getId()) {
case 14314:
case 25629:
case 25630:
player.getDialogueManager().startDialogue("LanderD");
return true;
}
return true;
}
}
所以詮釋他player.getInterfaceManager()我可以做一個空檢查這樣 – OwnerOfVelorium
的代碼會是這個樣子: 如果(player.getInterfaceManager()!= NULL){ –
的代碼會是這個樣子: if(player.getInterfaceManager()!= null){player.getInterfaceManager()。removeMinigameInterface(); } –