Moving XPCOM stuff

This commit is contained in:
Norbi Peti 2019-04-22 22:21:48 +02:00
parent 515fb1f4d1
commit 9ba0c3e820
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
29 changed files with 317 additions and 212 deletions

View file

@ -1,9 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.NorbiPeti</groupId>
<artifactId>VirtualComputer-Core</artifactId> <artifactId>VirtualComputer-Core</artifactId>
<version>2.1-SNAPSHOT</version> <version>2.1-SNAPSHOT</version>
<parent>
<groupId>io.github.NorbiPeti</groupId>
<artifactId>VirtualComputer</artifactId>
<version>2.1-SNAPSHOT</version>
</parent>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -34,40 +38,11 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>repo</id>
<url>file://${basedir}/repo</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency> <!-- This has the least additional (platform-dependent) code -->
<groupId>org.spigotmc</groupId> <groupId>org.virtualbox</groupId>
<artifactId>spigot-api</artifactId> <artifactId>VirtualBox-MSCOM</artifactId>
<version>1.12-R0.1-SNAPSHOT</version> <version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> - Not using anything from here directly so we're not that dependent on versions
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> -->
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.jnr/jnr-ffi -->
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.aparapi</groupId> <groupId>com.aparapi</groupId>
@ -75,14 +50,14 @@
<version>1.10.0</version> <version>1.10.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>io.github.NorbiPeti</groupId>
<artifactId>lombok</artifactId> <artifactId>VirtualComputer-XPCOM</artifactId>
<version>1.16.16</version> <version>2.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <!-- javax.annotations.Nullable --> <dependency>
<groupId>com.google.code.findbugs</groupId> <groupId>sznp.virtualcomputer</groupId>
<artifactId>jsr305</artifactId> <artifactId>VirtualComputer-MSCOM</artifactId>
<version>3.0.0</version> <version>2.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<profiles> <profiles>
@ -102,6 +77,7 @@
<artifactSet> <artifactSet>
<excludes> <excludes>
<exclude>org.virtualbox:VirtualBox-MSCOM</exclude> <exclude>org.virtualbox:VirtualBox-MSCOM</exclude>
<exclude>sznp.virtualcomputer.VirtualComputer-MSCOM</exclude>
</excludes> </excludes>
</artifactSet> </artifactSet>
</configuration> </configuration>
@ -127,6 +103,7 @@
<artifactSet> <artifactSet>
<excludes> <excludes>
<exclude>org.virtualbox:VirtualBox</exclude> <exclude>org.virtualbox:VirtualBox</exclude>
<exclude>sznp.virtualcomputer.VirtualComputer-XPCOM</exclude>
</excludes> </excludes>
</artifactSet> </artifactSet>
</configuration> </configuration>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<version>5.1</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<version>5.2</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<versioning>
<release>6.0</release>
<versions>
<version>5.1</version>
<version>5.2</version>
<version>6.0</version>
</versions>
<lastUpdated>20181221211412</lastUpdated>
</versioning>
</metadata>

View file

@ -9,7 +9,6 @@ import org.virtualbox_6_0.*;
import sznp.virtualcomputer.events.MachineEventHandler; import sznp.virtualcomputer.events.MachineEventHandler;
import sznp.virtualcomputer.events.VBoxEventHandler; import sznp.virtualcomputer.events.VBoxEventHandler;
import sznp.virtualcomputer.renderer.GPURenderer; import sznp.virtualcomputer.renderer.GPURenderer;
import sznp.virtualcomputer.renderer.MCFrameBuffer;
import sznp.virtualcomputer.util.Scancode; import sznp.virtualcomputer.util.Scancode;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -61,7 +60,7 @@ public final class Computer {
//TODO: If we have VirtualBox open, it won't close the server's port //TODO: If we have VirtualBox open, it won't close the server's port
//TODO: "The object in question already exists." on second start //TODO: "The object in question already exists." on second start
//machine.launchVMProcess(session, "headless", "").waitForCompletion(10000); //No privileges, start the 'old' way //machine.launchVMProcess(session, "headless", "").waitForCompletion(10000); //No privileges, start the 'old' way
//session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer(session.getConsole().getDisplay(), false))); //session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new COMFrameBuffer(session.getConsole().getDisplay(), false)));
//sendMessage(sender, "§6Computer started with slower screen. Run as root to use a faster method."); //sendMessage(sender, "§6Computer started with slower screen. Run as root to use a faster method.");
} else { } else {
sendMessage(sender, "§cFailed to start computer: " + e.getMessage()); sendMessage(sender, "§cFailed to start computer: " + e.getMessage());
@ -86,7 +85,7 @@ public final class Computer {
handler.setProgress(progress); handler.setProgress(progress);
handler.registerTo(progress.getEventSource()); //TODO: Show progress bar some way? handler.registerTo(progress.getEventSource()); //TODO: Show progress bar some way?
console.getDisplay().attachFramebuffer(0L, console.getDisplay().attachFramebuffer(0L,
new IFramebuffer(new MCFrameBuffer(console.getDisplay(), true))); new IFramebuffer(new COMFrameBuffer(console.getDisplay(), true)));
} }
private void sendMessage(@Nullable CommandSender sender, String message) { private void sendMessage(@Nullable CommandSender sender, String message) {

View file

@ -13,7 +13,7 @@ import sznp.virtualcomputer.events.VBoxEventHandler;
import sznp.virtualcomputer.renderer.BukkitRenderer; import sznp.virtualcomputer.renderer.BukkitRenderer;
import sznp.virtualcomputer.renderer.GPURenderer; import sznp.virtualcomputer.renderer.GPURenderer;
import sznp.virtualcomputer.renderer.IRenderer; import sznp.virtualcomputer.renderer.IRenderer;
import sznp.virtualcomputer.util.Utils; import sznp.virtualcomputer.util.COMUtils;
import sznp.virtualcomputer.util.VBoxLib; import sznp.virtualcomputer.util.VBoxLib;
import java.io.File; import java.io.File;
@ -67,7 +67,7 @@ public class PluginMain extends JavaPlugin {
System.setProperty("sun.boot.library.path", vbpath); System.setProperty("sun.boot.library.path", vbpath);
if (System.getProperty("java.library.path") == null || System.getProperty("java.library.path").isEmpty()) if (System.getProperty("java.library.path") == null || System.getProperty("java.library.path").isEmpty())
System.setProperty("java.library.path", vbpath); System.setProperty("java.library.path", vbpath);
Utils.addLibraryPath(vbpath); COMUtils.addLibraryPath(vbpath);
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath()); final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load("vboxjxpcom"); //TODO: Test for MSCOM VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load("vboxjxpcom"); //TODO: Test for MSCOM
vbl.RTR3InitExe(0, "", 0); vbl.RTR3InitExe(0, "", 0);

View file

@ -2,12 +2,11 @@ package sznp.virtualcomputer.events;
import lombok.val; import lombok.val;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.mozilla.interfaces.IEvent; import org.virtualbox_6_0.IEvent;
import org.mozilla.interfaces.IEventListener;
import org.virtualbox_6_0.IEventSource; import org.virtualbox_6_0.IEventSource;
import org.virtualbox_6_0.VBoxEventType; import org.virtualbox_6_0.VBoxEventType;
import sznp.virtualcomputer.util.COMObjectBase; import sznp.virtualcomputer.util.COMUtils;
import sznp.virtualcomputer.util.Utils; import sznp.virtualcomputer.util.IEventHandler;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -17,7 +16,7 @@ import java.util.Map;
/** /**
* A Bukkit-like event system which calls the appropriate methods on an event. * A Bukkit-like event system which calls the appropriate methods on an event.
*/ */
public abstract class EventHandlerBase extends COMObjectBase implements IEventListener { public abstract class EventHandlerBase implements IEventHandler {
/** /**
* The events to listen for. It will only look for these handlers. * The events to listen for. It will only look for these handlers.
*/ */
@ -25,23 +24,21 @@ public abstract class EventHandlerBase extends COMObjectBase implements IEventLi
private boolean enabled = true; private boolean enabled = true;
protected EventHandlerBase(Map<VBoxEventType, Class<? extends org.virtualbox_6_0.IEvent>> eventMap) { protected EventHandlerBase(Map<VBoxEventType, Class<? extends org.virtualbox_6_0.IEvent>> eventMap) {
//this.eventMap = eventMap.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().value(), Map.Entry::getValue));
this.eventMap = eventMap; this.eventMap = eventMap;
} }
@Override @Override
public final void handleEvent(IEvent iEvent) { public final void handleEvent(IEvent iEvent) {
//val cl=eventMap.get((int)iEvent.getType()); - We can afford to search through the events for this handler
if (!enabled) if (!enabled)
return; return;
val kv = eventMap.entrySet().stream().filter(e -> e.getKey().value() == iEvent.getType()).findAny(); val kv = eventMap.entrySet().stream().filter(e -> e.getKey().value() == iEvent.getType().value()).findAny();
if (!kv.isPresent()) return; //Event not supported if (!kv.isPresent()) return; //Event not supported
val cl = kv.get().getValue(); val cl = kv.get().getValue();
for (Method method : getClass().getMethods()) { for (Method method : getClass().getMethods()) {
if (method.isAnnotationPresent(org.bukkit.event.EventHandler.class) if (method.isAnnotationPresent(org.bukkit.event.EventHandler.class)
&& method.getParameterCount() == 1 && method.getParameterTypes()[0] == cl) { && method.getParameterCount() == 1 && method.getParameterTypes()[0] == cl) {
try { try {
method.invoke(this, Utils.getEvent(iEvent, cl)); method.invoke(this, COMUtils.getEvent(iEvent, cl));
return; return;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
@ -54,7 +51,7 @@ public abstract class EventHandlerBase extends COMObjectBase implements IEventLi
} }
public <T extends EventHandlerBase> org.virtualbox_6_0.IEventListener registerTo(IEventSource source) { public <T extends EventHandlerBase> org.virtualbox_6_0.IEventListener registerTo(IEventSource source) {
return Utils.registerListener(source, this, new ArrayList<>(eventMap.keySet())); return COMUtils.registerListener(source, this, new ArrayList<>(eventMap.keySet()));
} }
public void disable() { public void disable() {

View file

@ -1,93 +1,21 @@
package sznp.virtualcomputer.renderer; package sznp.virtualcomputer.renderer;
import com.sun.jna.Pointer; import com.sun.jna.Pointer;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.mozilla.interfaces.IFramebuffer; import org.virtualbox_6_0.Holder;
import org.mozilla.interfaces.IFramebufferOverlay; import org.virtualbox_6_0.IDisplay;
import org.mozilla.interfaces.nsISupports; import org.virtualbox_6_0.IDisplaySourceBitmap;
import org.mozilla.xpcom.Mozilla; import org.virtualbox_6_0.VBoxException;
import org.virtualbox_6_0.*;
import sznp.virtualcomputer.PluginMain; import sznp.virtualcomputer.PluginMain;
import sznp.virtualcomputer.util.IMCFrameBuffer;
import sznp.virtualcomputer.util.Timing; import sznp.virtualcomputer.util.Timing;
import java.util.Arrays; @RequiredArgsConstructor
public class MCFrameBuffer implements IMCFrameBuffer {
public class MCFrameBuffer implements IFramebuffer { private final IDisplay display;
private IDisplay display;
private Holder<IDisplaySourceBitmap> holder = new Holder<>(); private Holder<IDisplaySourceBitmap> holder = new Holder<>();
public MCFrameBuffer(IDisplay display, boolean VBoxDirect) { //TODO: Implement param
this.display = display;
}
@Override
public nsISupports queryInterface(String id) {
return Mozilla.queryInterface(this, id);
}
@Override
public long getBitsPerPixel() {
return 32;
}
@Override
public long getBytesPerLine() {
return 640L;
}
@Override
public long[] getCapabilities(long[] arg0) {
try {
System.out.println("Capabilities queried");
System.out.println("Capabilities: " + Arrays.toString(arg0));
return new long[]{FramebufferCapabilities.UpdateImage.value()};
}
catch(Exception e) {
e.printStackTrace();
return new long[]{};
}
}
@Override
public long getHeight() {
return 480;
}
@Override
public long getHeightReduction() {
return 0;
}
@Override
public IFramebufferOverlay getOverlay() {
return null;
}
@Override
public long getPixelFormat() {
return BitmapFormat.BGRA.value();
}
@Override
public long getVisibleRegion(byte arg0, long arg1) {
return 0;
}
@Override
public long getWidth() {
return 640;
}
@Override
public long getWinId() {
return 0; // Zero means no win id
}
@Override
public void notify3DEvent(long arg0, byte[] arg1) {
}
private BukkitTask tt; private BukkitTask tt;
private Pointer pointer; private Pointer pointer;
private int width; private int width;
@ -135,20 +63,7 @@ public class MCFrameBuffer implements IFramebuffer {
} }
@Override @Override
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) { public void notifyUpdateImage(long x, long y, long width, long height, byte[] image) {
System.out.println("Update image!"); System.out.println("Update image!");
} }
@Override
public void setVisibleRegion(byte arg0, long arg1) {
}
@Override
public void processVHWACommand(byte b, int i, boolean b1) {
}
@Override
public boolean videoModeSupported(long arg0, long arg1, long arg2) {
return true;
}
} }

View file

@ -1,16 +1,7 @@
package sznp.virtualcomputer.util; package sznp.virtualcomputer.util;
import lombok.val;
import org.mozilla.interfaces.IEventListener;
import org.virtualbox_6_0.IEvent;
import org.virtualbox_6_0.IEventSource;
import org.virtualbox_6_0.VBoxEventType;
import org.virtualbox_6_0.xpcom.IUnknown;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class Utils { public class Utils {
/** /**
@ -38,24 +29,4 @@ public class Utils {
newPaths[newPaths.length - 1] = pathToAdd; newPaths[newPaths.length - 1] = pathToAdd;
usrPathsField.set(null, newPaths); usrPathsField.set(null, newPaths);
} }
//public static void registerListener(IEventSource source, IEventListener listener, VBoxEventType... types) {
public static org.virtualbox_6_0.IEventListener registerListener(IEventSource source, IEventListener listener, List<VBoxEventType> types) {
val ret = new org.virtualbox_6_0.IEventListener(listener);
source.registerListener(ret, types, true);
return ret;
}
@SuppressWarnings("unchecked")
public static <T extends IEvent> T getEvent(org.mozilla.interfaces.IEvent event, Class<T> cl) {
//if (event.getType() != type.value()) return null;
//return (T) T.queryInterface(new IEvent(event)); - Probably won't work
try {
val method = cl.getMethod("queryInterface", IUnknown.class);
return (T) method.invoke(null, new IEvent(event));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}
} }

View file

@ -19,6 +19,8 @@
<groupId>org.virtualbox</groupId> <groupId>org.virtualbox</groupId>
<artifactId>VirtualBox-MSCOM</artifactId> <artifactId>VirtualBox-MSCOM</artifactId>
<version>6.0</version> <version>6.0</version>
<optional>true
</optional> <!-- https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html -->
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -16,6 +16,8 @@
<groupId>org.virtualbox</groupId> <groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId> <artifactId>VirtualBox</artifactId>
<version>6.0</version> <version>6.0</version>
<optional>true
</optional> <!-- https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html -->
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -0,0 +1,111 @@
package sznp.virtualcomputer;
import lombok.RequiredArgsConstructor;
import org.mozilla.interfaces.IFramebuffer;
import org.mozilla.interfaces.IFramebufferOverlay;
import org.mozilla.interfaces.nsISupports;
import org.mozilla.xpcom.Mozilla;
import org.virtualbox_6_0.BitmapFormat;
import org.virtualbox_6_0.FramebufferCapabilities;
import sznp.virtualcomputer.util.IMCFrameBuffer;
import java.util.Arrays;
@RequiredArgsConstructor
public class COMFrameBuffer implements IFramebuffer {
private final IMCFrameBuffer frameBuffer;
@Override
public nsISupports queryInterface(String id) {
return Mozilla.queryInterface(this, id);
}
@Override
public long getBitsPerPixel() {
return 32;
}
@Override
public long getBytesPerLine() {
return 640L;
}
@Override
public long[] getCapabilities(long[] arg0) {
try {
System.out.println("Capabilities queried");
System.out.println("Capabilities: " + Arrays.toString(arg0));
return new long[]{FramebufferCapabilities.UpdateImage.value()};
} catch (Exception e) {
e.printStackTrace();
return new long[]{};
}
}
@Override
public long getHeight() {
return 480;
}
@Override
public long getHeightReduction() {
return 0;
}
@Override
public IFramebufferOverlay getOverlay() {
return null;
}
@Override
public long getPixelFormat() {
return BitmapFormat.BGRA.value();
}
@Override
public long getVisibleRegion(byte arg0, long arg1) {
return 0;
}
@Override
public long getWidth() {
return 640;
}
@Override
public long getWinId() {
return 0; // Zero means no win id
}
@Override
public void notify3DEvent(long arg0, byte[] arg1) {
}
@Override
public void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height) {
frameBuffer.notifyChange(screenId, xOrigin, yOrigin, width, height);
}
@Override
public void notifyUpdate(long x, long y, long width, long height) {
frameBuffer.notifyUpdate(x, y, width, height);
}
@Override
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) {
frameBuffer.notifyUpdateImage(arg0, arg1, arg2, arg3, arg4);
}
@Override
public void setVisibleRegion(byte arg0, long arg1) {
}
@Override
public void processVHWACommand(byte b, int i, boolean b1) {
}
@Override
public boolean videoModeSupported(long arg0, long arg1, long arg2) {
return true;
}
}

View file

@ -0,0 +1,35 @@
package sznp.virtualcomputer;
import org.mozilla.interfaces.IEvent;
import org.mozilla.interfaces.IEventListener;
import sznp.virtualcomputer.util.COMObjectBase;
import java.util.function.Consumer;
/**
* A Bukkit-like event system which calls the appropriate methods on an event.
*/
public final class EventHandler extends COMObjectBase implements IEventListener {
private final Consumer<org.virtualbox_6_0.IEvent> handler;
private boolean enabled = true;
/**
* New XPCOM event handler.
*
* @param handler The handle method that handles what needs to be handled
*/
public EventHandler(Consumer<org.virtualbox_6_0.IEvent> handler) {
this.handler = handler;
}
@Override
public final void handleEvent(IEvent iEvent) {
if (!enabled)
return;
handler.accept(new org.virtualbox_6_0.IEvent(iEvent));
}
public void disable() {
enabled = false;
}
}

View file

@ -0,0 +1,33 @@
package sznp.virtualcomputer.util;
import lombok.val;
import org.virtualbox_6_0.IEvent;
import org.virtualbox_6_0.IEventSource;
import org.virtualbox_6_0.VBoxEventType;
import org.virtualbox_6_0.xpcom.IUnknown;
import sznp.virtualcomputer.EventHandler;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public final class COMUtils {
private COMUtils() {}
//public static void registerListener(IEventSource source, IEventListener listener, VBoxEventType... types) {
public static org.virtualbox_6_0.IEventListener registerListener(IEventSource source, IEventHandler listener, List<VBoxEventType> types) {
val ret = new org.virtualbox_6_0.IEventListener(new EventHandler(listener::handleEvent));
source.registerListener(ret, types, true);
return ret;
}
@SuppressWarnings("unchecked")
public static <T extends IEvent> T getEvent(IEvent event, Class<T> cl) {
try {
val method = cl.getMethod("queryInterface", IUnknown.class);
return (T) method.invoke(null, event);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -0,0 +1,7 @@
package sznp.virtualcomputer.util;
import org.virtualbox_6_0.IEvent;
public interface IEventHandler {
void handleEvent(IEvent iEvent);
}

View file

@ -0,0 +1,9 @@
package sznp.virtualcomputer.util;
public interface IMCFrameBuffer {
void notifyUpdate(long x, long y, long width, long height);
void notifyUpdateImage(long x, long y, long width, long height, byte[] image);
void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height);
}

45
pom.xml
View file

@ -24,6 +24,17 @@
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<repositories>
<repository>
<id>repo</id>
<url>file://${basedir}/repo</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -31,6 +42,40 @@
<version>4.11</version> <version>4.11</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.jnr/jnr-ffi -->
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.1.7</version>
</dependency>
<dependency> <!-- javax.annotations.Nullable -->
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> - Not using anything from here directly so we're not that dependent on versions
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> -->
</dependencies> </dependencies>
<build> <build>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<version>5.1</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<version>5.2</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.virtualbox</groupId>
<artifactId>VirtualBox</artifactId>
<versioning>
<release>6.0</release>
<versions>
<version>5.1</version>
<version>5.2</version>
<version>6.0</version>
</versions>
<lastUpdated>20181221211412</lastUpdated>
</versioning>
</metadata>