I'm not sure exactly if this is called a 'loop' but it's not working for me.
Let me explain what i'm trying to do.
I'm trying to make it do a check if your below your max hp, if it is it will go back to the healing void SleepDream() once there it will re-do the LoopDream() until your hp is maxed, but in the console i get:
Code:
[3/21/11 7:38 PM]: slay no more - actionbutton: 117226
[3/21/11 7:38 PM]: Exception in thread "Thread-1" [3/21/11 7:38 PM]: java.util.C
oncurrentModificationException
[3/21/11 7:38 PM]: at java.util.AbstractList$Itr.checkForComodification(Unk
nown Source)
[3/21/11 7:38 PM]: at java.util.AbstractList$Itr.next(Unknown Source)
[3/21/11 7:38 PM]: at server.event.EventManager.run(EventManager.java:97)
[3/21/11 7:38 PM]: at java.lang.Thread.run(Unknown Source)
There is no errors compiling, someone please help ?
Code:
public void dream() {
if (c.playerLevel[6] < 79) {
c.sendMessage("You need a magic level of 79 to cast this spell.");
return;
}
if (c.playerLevel[3] >= c.getLevelForXP(c.playerXP[c.playerHitpoints])) {
c.sendMessage("You already have full hitpoints!");
return;
}
if(c.playerIndex != 0){
c.sendMessage("You cannot cast this spell in combat.");
return;
}
if (c.getItems().playerHasItem(559, 5)
&& c.getItems().playerHasItem(9075, 2)
&& c.getItems().playerHasItem(564, 1)) {
c.dreamTime = 8;
c.getItems().deleteItem(9075, 2);
c.getItems().deleteItem(564, 1);
c.getItems().deleteItem(559, 5);
c.sendMessage("You begin to fall into a deep sleep.");
c.startAnimation(6295);
SleepDream();
} else {
c.sendMessage("You do not have the required runes to cast this spell.");
}
}
private void SleepDream() {
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer event) {
if (c.sleepTime <= 13) {
c.sleepTime--;
}
if (c.sleepTime == 0) {
c.playerLevel[3] += 10;
c.getPA().refreshSkill(3);
c.handleHitMask(10);
c.startAnimation(6296);
LOOPDream();
return;
}
}
}, 500);
}
public void LOOPDream() {
if (c.playerLevel[3] >= c.getLevelForXP(c.playerXP[c.playerHitpoints])) {
c.sleepTime = 14;
SleepDream();
} else {
c.sleepTime--;
DreamEnd();
c.sendMessage("this shouldn't be seen!");
//event.stop();
}
}
public void DreamEnd() {
c.sleepTime--;
//c.gfx0(1056);
c.dreamTime = 100;
c.startAnimation(6297);
c.sendMessage("You wake up from your dream, feeling more powerful...");
}