From 5d6b70529974efb8b7783b5923a6bdac0705be77 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 21 Dec 2017 22:23:23 +0100 Subject: [PATCH] FIXED "Not supported" bug in VirtualBox https://marc.info/?l=vbox-dev&m=142780789819967&w=2 (Must run as sudo currently) Some other fixes related to rendering --- VirtualComputer/dependency-reduced-pom.xml | 11 ----------- VirtualComputer/pom.xml | 12 ++++++------ .../src/sznp/virtualcomputer/DirectRenderer.java | 3 ++- .../src/sznp/virtualcomputer/MCFrameBuffer.java | 2 +- .../src/sznp/virtualcomputer/PluginMain.java | 8 +++++++- .../src/sznp/virtualcomputer/VBoxLib.java | 5 +++++ 6 files changed, 21 insertions(+), 20 deletions(-) create mode 100755 VirtualComputer/src/sznp/virtualcomputer/VBoxLib.java diff --git a/VirtualComputer/dependency-reduced-pom.xml b/VirtualComputer/dependency-reduced-pom.xml index a7e3ca5..3e79d26 100644 --- a/VirtualComputer/dependency-reduced-pom.xml +++ b/VirtualComputer/dependency-reduced-pom.xml @@ -40,11 +40,6 @@ shade - - - org.virtualbox:VirtualBox - - @@ -105,12 +100,6 @@ 1.12.2-R0.1-SNAPSHOT provided - - net.java.dev.jna - jna - 4.4.0 - compile - diff --git a/VirtualComputer/pom.xml b/VirtualComputer/pom.xml index 5e3d3d9..31195d0 100644 --- a/VirtualComputer/pom.xml +++ b/VirtualComputer/pom.xml @@ -41,11 +41,6 @@ shade - - - org.virtualbox:VirtualBox - - @@ -91,6 +86,11 @@ jna 4.4.0 - + + + com.github.jnr + jnr-ffi + 2.1.7 + \ No newline at end of file diff --git a/VirtualComputer/src/sznp/virtualcomputer/DirectRenderer.java b/VirtualComputer/src/sznp/virtualcomputer/DirectRenderer.java index dede21f..3e20f8c 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/DirectRenderer.java +++ b/VirtualComputer/src/sznp/virtualcomputer/DirectRenderer.java @@ -63,7 +63,8 @@ public class DirectRenderer implements IRenderer { wmap.flagDirty(0, 0); wmap.flagDirty(128, 128); // Send the whole image - TODO: Only send changes } catch (Exception e) { - if (ex != null && e.getMessage().equals(ex.getMessage())) + if (ex != null && (e.getMessage() == ex.getMessage() + || (e.getMessage() != null && e.getMessage().equals(ex.getMessage())))) return; (ex = e).printStackTrace(); } diff --git a/VirtualComputer/src/sznp/virtualcomputer/MCFrameBuffer.java b/VirtualComputer/src/sznp/virtualcomputer/MCFrameBuffer.java index 4fb8b85..8924814 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/MCFrameBuffer.java +++ b/VirtualComputer/src/sznp/virtualcomputer/MCFrameBuffer.java @@ -9,7 +9,7 @@ import org.virtualbox_5_2.*; public class MCFrameBuffer implements IFramebuffer { private IDisplay display; - private Holder holder; + private Holder holder = new Holder<>(); public MCFrameBuffer(IDisplay display) { this.display = display; diff --git a/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java b/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java index 7887c9a..6b8c7b9 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java +++ b/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java @@ -11,10 +11,14 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; +import org.mozilla.xpcom.Mozilla; +import org.mozilla.xpcom.internal.XPCOMImpl; import org.virtualbox_5_2.*; import com.google.common.collect.Lists; +import jnr.ffi.LibraryLoader; + public class PluginMain extends JavaPlugin { private IVirtualBox vbox; private ISession session; @@ -49,6 +53,8 @@ public class PluginMain extends JavaPlugin { System.setProperty("java.library.path", vbpath); addLibraryPath(vbpath); final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath()); + VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load(vbpath + "/libvboxjxpcom.so"); + vbl.RTR3InitExe(0, "", 0); vbox = manager.getVBox(); session = manager.getSessionObject(); // TODO: Events ccs.sendMessage("§bLoading Screen..."); @@ -104,7 +110,7 @@ public class PluginMain extends JavaPlugin { sender.sendMessage("B: " + machine.getState().toString()); final IConsole console = session.getConsole(); sender.sendMessage("1: " + console.getState().toString()); - console.powerUp(); + console.powerUp(); // https://marc.info/?l=vbox-dev&m=142780789819967&w=2 sender.sendMessage("2: " + console.getState().toString()); console.getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer(console.getDisplay()))); diff --git a/VirtualComputer/src/sznp/virtualcomputer/VBoxLib.java b/VirtualComputer/src/sznp/virtualcomputer/VBoxLib.java new file mode 100755 index 0000000..3c2b097 --- /dev/null +++ b/VirtualComputer/src/sznp/virtualcomputer/VBoxLib.java @@ -0,0 +1,5 @@ +package sznp.virtualcomputer; + +public interface VBoxLib { + void RTR3InitExe(int argc, String argv, int somethingzero); +}