Waiting on "spawning" after lock

This commit is contained in:
Norbi Peti 2017-08-08 15:51:38 +02:00
parent 169285a111
commit d94f4b699d
2 changed files with 26 additions and 18 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.NorbiPeti</groupId>
<artifactId>VirtualComputer</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>

View file

@ -81,6 +81,13 @@ public class PluginMain extends JavaPlugin {
machine = vbox.getMachines().get(0);
// machine.launchVMProcess(session, "headless", "").waitForCompletion(10000); - This creates a *process*, we don't want that anymore
machine.lockMachine(session, LockType.Write); // We want the machine inside *our* process
screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if (session.getState() == SessionState.Spawning) // https://www.virtualbox.org/sdkref/_virtual_box_8idl.html#ac82c179a797c0d7c249d1b98a8e3aa8f
return; // "This state also occurs as a short transient state during an IMachine::lockMachine call."
else {
screenupdatetask.cancel();
screenupdatetask = null;
}
machine = session.getMachine(); // This is the Machine object we can work with
session.getConsole().powerUp().waitForCompletion(10000);
session.getConsole().getDisplay().attachFramebuffer(0L,
@ -98,6 +105,7 @@ public class PluginMain extends JavaPlugin {
screenupdatetask = null;
}
}, 100, 100); // Do a full update every 5 seconds
}, 5, 5);
sender.sendMessage("§eComputer started.");
});
}