Need a lock on the list as we update it between threads

master
sigonasr2 2 years ago
parent e589001985
commit 016fb611af
  1. 118
      sig/App.java

@ -394,67 +394,69 @@ class Server
@Override @Override
public void run() { public void run() {
while (true){ while (true){
for (String command:commandQueue){ synchronized (commandQueue){
switch (command){ commandQueue.forEach((command)->{
case "FOLLOW":{ switch (command){
PressKeyWithModifier(KeyEvent.VK_CONTROL,KeyEvent.VK_7); case "FOLLOW":{
}break; PressKeyWithModifier(KeyEvent.VK_CONTROL,KeyEvent.VK_7);
case "FORWARD":{ }break;
r.keyPress(KeyEvent.VK_W); case "FORWARD":{
r.delay(1000); r.keyPress(KeyEvent.VK_W);
r.keyRelease(KeyEvent.VK_W); r.delay(1000);
}break; r.keyRelease(KeyEvent.VK_W);
case "BACKWARD":{ }break;
r.keyPress(KeyEvent.VK_S); case "BACKWARD":{
r.delay(1000); r.keyPress(KeyEvent.VK_S);
r.keyRelease(KeyEvent.VK_S); r.delay(1000);
}break; r.keyRelease(KeyEvent.VK_S);
case "LEFT":{ }break;
r.keyPress(KeyEvent.VK_Q); case "LEFT":{
r.delay(1000); r.keyPress(KeyEvent.VK_Q);
r.keyRelease(KeyEvent.VK_Q); r.delay(1000);
}break; r.keyRelease(KeyEvent.VK_Q);
case "RIGHT":{ }break;
r.keyPress(KeyEvent.VK_E); case "RIGHT":{
r.delay(1000); r.keyPress(KeyEvent.VK_E);
r.keyRelease(KeyEvent.VK_E); r.delay(1000);
}break; r.keyRelease(KeyEvent.VK_E);
case "FIGHT":{ }break;
fighting=true; case "FIGHT":{
fightingaoe=false; fighting=true;
System.out.println("Fight mode: "+fighting); fightingaoe=false;
}break; System.out.println("Fight mode: "+fighting);
case "FIGHTAOE":{ }break;
fighting=fightingaoe=true; case "FIGHTAOE":{
System.out.println("Fight mode: "+fighting); fighting=fightingaoe=true;
}break; System.out.println("Fight mode: "+fighting);
case "CHILL":{ }break;
fighting=false; case "CHILL":{
System.out.println("Fight mode: "+fighting); fighting=false;
}break; System.out.println("Fight mode: "+fighting);
case "PASS":{ }break;
System.out.println("Mythra's Health: "+GetMythraHealth()+"%"); case "PASS":{
System.out.println("Aya's Health: "+GetAyaHealth()+"%"); System.out.println("Mythra's Health: "+GetMythraHealth()+"%");
System.out.println("Target's Health: "+GetTargetHealth()+"%"); System.out.println("Aya's Health: "+GetAyaHealth()+"%");
}break; System.out.println("Target's Health: "+GetTargetHealth()+"%");
case "SPRINT":{ }break;
if (nextActionTimer==0){ case "SPRINT":{
PressKey(KeyEvent.VK_N); if (nextActionTimer==0){
r.delay(100); PressKey(KeyEvent.VK_N);
PressKey(KeyEvent.VK_N); r.delay(100);
} else { PressKey(KeyEvent.VK_N);
queueUpSprint=true; } else {
queueUpSprint=true;
}
}break;
case "UPDATE":{
}break;
default:{
System.out.println("Unknown command: "+command);
} }
}break;
case "UPDATE":{
}break;
default:{
System.out.println("Unknown command: "+command);
} }
} });
commandQueue.clear();
} }
commandQueue.clear();
if (queueUpSprint&&nextActionTimer==0){ if (queueUpSprint&&nextActionTimer==0){
PressKey(KeyEvent.VK_N); PressKey(KeyEvent.VK_N);

Loading…
Cancel
Save