From 8fbf0445300819047516a60446acdbf0364f7422 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 5 Apr 2019 20:03:05 +0200 Subject: [PATCH] Progress error reporting on start fail --- README.md | 10 ++++--- VirtualComputer/lombok.config | 1 + .../java/sznp/virtualcomputer/Computer.java | 3 ++ .../events/MachineEventHandler.java | 30 +++++++++++++++---- 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 VirtualComputer/lombok.config diff --git a/README.md b/README.md index 5832709..ee362f7 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,17 @@ A working modern computer in Minecraft made using VirtualBox and Java. No client * OS X; Ubuntu 16.04/18.04 * VirtualBox 6.0 -* Spgiot/Bukkit 1.8/1.9/1.12 +* Spgiot/Bukkit 1.12 * Java 8 +*The fast rendering method currently only supports 1.12.2.* + ### Tested on: *The requirements vary greatly depending on what OS you want to run ingame but here are my specs that can run Overwatch in Minecraft.* -* CPU: Intel 3.5 GHz +* CPU: Intel® Pentium(R) CPU G3460 @ 3.50GHz × 2 * RAM: 8 GB -* GPU: NVidia GeForce GTX 650 +* GPU: NVidia GeForce GTX 650 1 GB *Due to VirtualBox Java binding support limitations the plugin does not support Windows currently.* @@ -74,7 +76,7 @@ Due to the way it works, it automatically plays every sound from the virtual mac ### Special thanks: * The creators of VirtualBox for making it open-source and kind of easy to use (though I had minor issues as the documentation doesn't really tell me how to write a new frontend :P and that I needed to learn how machines work - especially keyboards) -* @iiegit for testing and more testing for the non-Windows version +* @iiegit for testing and more testing for the non-Windows version and helping a lot to get it on /r/sequence # Known issues ## Port remains open (cannot bind to port) diff --git a/VirtualComputer/lombok.config b/VirtualComputer/lombok.config new file mode 100644 index 0000000..d959b09 --- /dev/null +++ b/VirtualComputer/lombok.config @@ -0,0 +1 @@ +lombok.var.flagUsage = ALLOW diff --git a/VirtualComputer/src/main/java/sznp/virtualcomputer/Computer.java b/VirtualComputer/src/main/java/sznp/virtualcomputer/Computer.java index a096283..f52f8df 100644 --- a/VirtualComputer/src/main/java/sznp/virtualcomputer/Computer.java +++ b/VirtualComputer/src/main/java/sznp/virtualcomputer/Computer.java @@ -79,6 +79,7 @@ public final class Computer { handler = new MachineEventHandler(Computer.this, sender); listener = handler.registerTo(console.getEventSource()); IProgress progress = console.powerUp(); // https://marc.info/?l=vbox-dev&m=142780789819967&w=2 + handler.setProgress(progress); handler.registerTo(progress.getEventSource()); //TODO: Show progress bar some way? console.getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer(console.getDisplay(), true))); @@ -199,6 +200,8 @@ public final class Computer { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { if (session.getState() == SessionState.Locked) { session.unlockMachine(); //Needs to be outside of the event handler + handler = null; + machine = null; } }); GPURendererInternal.setPixels(new byte[1], 0, 0); //Black screen diff --git a/VirtualComputer/src/main/java/sznp/virtualcomputer/events/MachineEventHandler.java b/VirtualComputer/src/main/java/sznp/virtualcomputer/events/MachineEventHandler.java index f4c2173..7191d53 100644 --- a/VirtualComputer/src/main/java/sznp/virtualcomputer/events/MachineEventHandler.java +++ b/VirtualComputer/src/main/java/sznp/virtualcomputer/events/MachineEventHandler.java @@ -1,21 +1,29 @@ package sznp.virtualcomputer.events; import com.google.common.collect.ImmutableMap; +import lombok.Setter; +import lombok.experimental.var; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; -import org.virtualbox_6_0.IProgressTaskCompletedEvent; +import org.virtualbox_6_0.IProgress; import org.virtualbox_6_0.IStateChangedEvent; import org.virtualbox_6_0.VBoxEventType; import sznp.virtualcomputer.Computer; +import sznp.virtualcomputer.PluginMain; + +import java.util.logging.Logger; public class MachineEventHandler extends EventHandlerBase { - private final Computer computer; + private final Computer computer; private final CommandSender sender; private boolean starting = false; + @Setter + private IProgress progress; public MachineEventHandler(Computer computer, CommandSender sender) { - super(ImmutableMap.of(VBoxEventType.OnStateChanged, IStateChangedEvent.class, - VBoxEventType.OnProgressTaskCompleted, IProgressTaskCompletedEvent.class)); + super(ImmutableMap.of(VBoxEventType.OnStateChanged, IStateChangedEvent.class)); + //VBoxEventType.OnProgressPercentageChanged, IProgressPercentageChangedEvent.class)); - Doesn't fire at all, the complete event only fires on success this.computer = computer; this.sender = sender; } @@ -32,6 +40,18 @@ public class MachineEventHandler extends EventHandlerBase { sender.sendMessage("§cFailed to start computer! See the VM's log for more details."); sender.sendMessage("§cMake sure that 2D and 3D acceleration is disabled."); starting = false; + Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { + progress.waitForCompletion(-1); + if (progress != null && progress.getCompleted() && progress.getResultCode() != 0) { + Logger l = PluginMain.Instance.getLogger(); + l.warning("Result code: " + Integer.toHexString(progress.getResultCode())); + for (var info = progress.getErrorInfo(); info != null; info = info.getNext()) { + l.warning("----------------"); + l.warning("VBox: " + info.getText()); + l.warning("Component: " + info.getComponent()); + } + } + }); } computer.onMachineStop(sender); break; @@ -43,5 +63,5 @@ public class MachineEventHandler extends EventHandlerBase { computer.onMachineStart(sender); break; } - } + } }