gpt4 book ai didi

java.lang.ArrayIndexOutOfBoundsException : 1

转载 作者:行者123 更新时间:2023-12-02 05:54:18 24 4
gpt4 key购买 nike

这里出了什么问题?

错误:

java.lang.ArrayIndexOutOfBoundsException: 1
at com.rs.game.player.content.SlayerTask.getNewTask(SlayerTask.java:81)

SlayerTask.java第81行:

this.currentTaskAmount = amount[Utils.random(low_tasks.length - 1)];

它反射(reflect)的金额:

this.currentTaskAmount = -2;

总代码(如果需要): 包 com.rs.game.player.content;

import java.io.Serializable;

import com.rs.cache.loaders.NPCDefinitions;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.utils.Utils;
import com.rs.game.npc.*;

public class SlayerTask implements Serializable {
private static final long serialVersionUID = -3885979679549716755L;

private transient static int[] low_tasks = { // 1 - 60
1648, //crawling hand - slay lvl 1 || Slayer Tower
1600, //cave crawler - slay lvl 10 || Fremmy dung
1612, //banshee - - slay lvl 15 || Slayer Tower
1632, //rockslug - - slay lvl 20 || Fremmy dung
1616, //basilisk - - slay lvl 40 || Fremmy dung
1640, 1637, //jelly - slay lvl 52 || Fremmy dung, Slayer Tower
1633 //Pyrefiend || Fremmy dung
};
private transient static int[] mid_tasks = {
1605, //abarrant spectre - slay lvl 60 || Slayer Tower
//dust devil - slay lvl 65 || Fremmy dung
//jungle strykewyrm - slay lvl 73 || Fremmy dung
1610, //gargoyle - slay lvl 75 || Fremmy dung
1627, //turoth || Fremmy dung
1609, //kurask || Fremmy dung
1643, //infernal mage || Fremmy dung
6215 // bloodveld || Slayer Tower
};
private transient static int[] high_tasks = {
//desert strykewyrm - slay lvl 77
1613, //nechryael - slay lvl 80 || Slayer Tower
1615, //abyssal demon - slay lvl 85 || Slayer Tower
//grifolapine - slay lvl 88
2783, //dark beast - slay lvl 90 || Slayer Tower
//ice strykewyrm - slay lvl 93
//ganodermic creatures - slay lvl 95
};

private transient static int[] amount = { 1};

private int currentTask = -1;
private int currentTaskAmount = 0;

private transient Player player;

public void setPlayer(Player player) {
this.player = player;
}

public void resetTask() {
this.currentTask = -1;
this.currentTaskAmount = -2;
}

public String getName() {
return NPCDefinitions.getNPCDefinitions(currentTask).getName();
}

public void getNewTask() {
if (player.getSkills().getLevel(Skills.SLAYER) >= 1 && player.getSkills().getLevel(Skills.SLAYER) <= 59) {
this.currentTask = low_tasks[Utils.random(low_tasks.length - 1)];
this.currentTaskAmount = amount[Utils.random(low_tasks.length - 1)];
player.getPackets().sendGameMessage("59<= Slayer level >= 1");
}
if (player.getSkills().getLevel(Skills.SLAYER) >= 60 && player.getSkills().getLevel(Skills.SLAYER) <= 76) {
this.currentTask = mid_tasks[Utils.random(mid_tasks.length - 1)];
this.currentTaskAmount = amount[Utils.random(mid_tasks.length - 1)];
player.getPackets().sendGameMessage("76<= Slayer level >= 60");
}
if (player.getSkills().getLevel(Skills.SLAYER) >= 77) {
this.currentTask = high_tasks[Utils.random(high_tasks.length - 1)];
this.currentTaskAmount = amount[Utils.random(high_tasks.length - 1)];
player.getPackets().sendGameMessage("Slayer level >= 77");
}
}

public int getCurrentTask() {
return currentTask;
}

public int getTaskAmount() {
return currentTaskAmount;
}

public void decreaseTask() {
this.currentTaskAmount--;
}

public boolean isComplete() {
return currentTaskAmount < 1;
}

public SlayerTask() {

}

}

我在谷歌上找不到任何可以理解的内容。如果有人能帮助我那就太好了。

最佳答案

您已在此处声明了长度为 1 的数组:

private transient static int[] amount = { 1};

但是,根据您的异常消息,您传入的索引为 1,该索引无效。该数组唯一有效的索引是 0

要么将数组修改得更长,要么修改索引计算,使其不会产生 1

关于java.lang.ArrayIndexOutOfBoundsException : 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23252982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com