这是一个例外:
java.lang.NullPointerException
at com.rs.net.decoders.handlers.InventoryOptionsHandler$2.run(InventoryOptionsHandler.java:512)
at com.rs.game.player.CoordsEvent.processEvent(CoordsEvent.java:55)
at com.rs.game.player.Player.processEntity(Player.java:357)
at com.rs.cores.WorldProcessor.process(WorldProcessor.java:39)
at com.rs.cores.PriorityProcessor.run(PriorityProcessor.java:10)
以下是代码:
InventoryOptionsHandler:
if (object.getId() == 15621) {
player.getWarriorsGuild().createWarrior(itemId, object);
player.getDialogueManager().startDialogue(
(short) 211,
new String[] {
"The animator hums. Something seems to be working.",
"You stand back..." });
return;
}
现在我在player.java中的getWarriorsGuild()方法
public AnimationGame getWarriorsGuild() {
return warriorsGuild;
}
public AnimationGame warriorsGuild = new AnimationGame(this);
最后但并非最不重要的,我在AnimationGame中的createWarrior方法。
public void createWarrior(int armours, final WorldObject object) {
final WarriorsArmour sets = WarriorsArmour.forId(armours);
if (sets == null || sets.getArmour() == null) return;
if (sets.getArmour()[0] == armours || sets.getArmour()[1] == armours
|| sets.getArmour()[2] == armours) {
if (player.getInventory().containsItem(sets.getArmour()[0], 1)
&& player.getInventory().containsItem(sets.getArmour()[1],
1)
&& player.getInventory().containsItem(sets.getArmour()[2],
1)) {
final boolean running = player.isRunning();
player.getInventory().deleteItem(sets.getArmour()[0], 1);
player.getInventory().deleteItem(sets.getArmour()[1], 1);
player.getInventory().deleteItem(sets.getArmour()[2], 1);
int newX = player.getX();
int newY = player.getY() + 5;
player.setRun(false);
player.setRunHidden(false);
player.addWalkSteps(newX, newY, -1, false);
player.setNextAnimation(new Animation(827));
player.addStopDelay(3L);
player.getDialogueManager().startDialogue("WAnimator",
new Object[0]);
WorldTasksManager.schedule(new WorldTask() {
public void run() {
if (!secondloop) {
secondloop = true;
player.setRunHidden(running);
} else {
stop();
}
}
boolean secondloop;
}, 0, 6);
WorldTasksManager.schedule(new WorldTask() {
@Override
public void run() {
final NPC war = new NPC(sets.getNpcId(), new WorldTile(
object.getX(), object.getY(), 0), -1, true);
war.addWalkSteps(player.getY(), player.getY());
player.setNextFaceEntity(war);
war.setTarget(player);
war.setNextAnimation(new Animation(4166));
war.setNextForceTalk(new ForceTalk("I'M ALIVE!"));
player.getInterfaceManager().closeChatBoxInterface();
player.getInterfaceManager()
.closeReplacedRealChatBoxInterface();
player.getHintIconsManager().addHintIcon(war, 1, -1,
false);
player.sendAreaInterface(player);
WorldTasksManager.schedule(new WorldTask() {
@Override
public void run() {
war.setFinished(true);
war.setForceWalk(new WorldTile(-1, -1, -1));
World.removeNPC(war);
stop();
}
}, 60, 60);
stop();
return;
}
}, 3, 3);
} else {
return;
}
return;
}
}
我想知道,导致该nullpointer的原因是什么,我不明白? 如果你需要了解更多信息,请不要犹豫,谢谢:)
答案 0 :(得分:1)
从InventoryOptionsHandler类中检查object.getId()。我认为你的id为null然后导致NullPointerException。