Directly using VirtualBox from Java #5

Merged
NorbiPeti merged 60 commits from directvb into master 2019-04-18 23:29:21 +00:00
7 changed files with 39 additions and 37 deletions
Showing only changes of commit ed321a0850 - Show all commits

View file

@ -16,6 +16,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="vboxjws.jar"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View file

@ -1,108 +1,115 @@
package sznp.virtualcomputer; package sznp.virtualcomputer;
import org.virtualbox_5_1.IFramebuffer; import org.mozilla.interfaces.IFramebuffer;
import org.virtualbox_5_1.ObjectRefManager; import org.mozilla.interfaces.IFramebufferOverlay;
import org.virtualbox_5_1.jaxws.VboxPortType; import org.mozilla.interfaces.nsISupports;
public class MCFrameBuffer extends IFramebuffer { public class MCFrameBuffer implements IFramebuffer {
public MCFrameBuffer(String wrapped, ObjectRefManager objMgr, VboxPortType port) { @Override
super(wrapped, objMgr, port);
// TODO Auto-generated constructor stub
}
/*@Override
public nsISupports queryInterface(String arg0) { public nsISupports queryInterface(String arg0) {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public long getBitsPerPixel() { public long getBitsPerPixel() {
return 32; // TODO Auto-generated method stub
return 0;
} }
@Override @Override
public long getBytesPerLine() { public long getBytesPerLine() {
return 640 * 4; // TODO Auto-generated method stub
return 0;
} }
@Override @Override
public long[] getCapabilities(long[] arg0) { public long[] getCapabilities(long[] arg0) {
return new long[] { FramebufferCapabilities.UpdateImage }; // TODO Auto-generated method stub
return null;
} }
@Override @Override
public long getHeight() { public long getHeight() {
return 480; // TODO Auto-generated method stub
return 0;
} }
@Override @Override
public long getHeightReduction() { public long getHeightReduction() {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public IFramebufferOverlay getOverlay() { public IFramebufferOverlay getOverlay() {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public long getPixelFormat() { public long getPixelFormat() {
return BitmapFormat.RGBA; // TODO Auto-generated method stub
return 0;
} }
private byte visibleRegionB;
private long visibleRegionL;
@Override @Override
public long getVisibleRegion(byte arg0, long arg1) { public long getVisibleRegion(byte arg0, long arg1) {
System.out.println("Visible region get."); // TODO Auto-generated method stub
return visibleRegionL; return 0;
} }
@Override @Override
public long getWidth() { public long getWidth() {
return 640; // TODO Auto-generated method stub
return 0;
} }
@Override @Override
public long getWinId() { public long getWinId() {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public void notify3DEvent(long arg0, byte[] arg1) { public void notify3DEvent(long arg0, byte[] arg1) {
// TODO Auto-generated method stub
} }
@Override @Override
public void notifyChange(long arg0, long arg1, long arg2, long arg3, long arg4) { public void notifyChange(long arg0, long arg1, long arg2, long arg3, long arg4) {
// TODO Auto-generated method stub
} }
@Override @Override
public void notifyUpdate(long arg0, long arg1, long arg2, long arg3) { public void notifyUpdate(long arg0, long arg1, long arg2, long arg3) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
System.out.println("UPDATE");
} }
@Override @Override
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) { public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) {
// TODO Auto-generated method stub System.out.println("Update!");
System.out.println("UPDATE IMAGE");
} }
@Override @Override
public void processVHWACommand(byte arg0) { public void processVHWACommand(byte arg0) {
// TODO Auto-generated method stub
} }
@Override @Override
public void setVisibleRegion(byte arg0, long arg1) { public void setVisibleRegion(byte arg0, long arg1) {
visibleRegionB = arg0; // TODO Auto-generated method stub
visibleRegionL = arg1;
System.out.println("Visible region set.");
} }
@Override @Override
public boolean videoModeSupported(long arg0, long arg1, long arg2) { public boolean videoModeSupported(long arg0, long arg1, long arg2) {
return true; // We support EVERYTHING // TODO Auto-generated method stub
}*/ return false;
}
} }

View file

@ -2,7 +2,6 @@ package sznp.virtualcomputer;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt; import java.awt.image.DataBufferInt;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.Craft;
@ -14,8 +13,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.mozilla.interfaces.IFramebufferOverlay;
import org.mozilla.interfaces.nsISupports;
import org.virtualbox_5_1.IFramebuffer; import org.virtualbox_5_1.IFramebuffer;
import org.virtualbox_5_1.ISession; import org.virtualbox_5_1.ISession;
import org.virtualbox_5_1.IVirtualBox; import org.virtualbox_5_1.IVirtualBox;
@ -39,13 +36,12 @@ public class PluginMain extends JavaPlugin {
ConsoleCommandSender ccs = getServer().getConsoleSender(); ConsoleCommandSender ccs = getServer().getConsoleSender();
this.getCommand("computer").setExecutor(new Commands()); this.getCommand("computer").setExecutor(new Commands());
ccs.sendMessage("§bInitializing VirtualBox..."); ccs.sendMessage("§bInitializing VirtualBox...");
// Connect con = new Connect("vbox:///");
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath()); final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
vbox = manager.getVBox(); vbox = manager.getVBox();
session = manager.getSessionObject(); session = manager.getSessionObject();
vbox.getMachines().get(0).launchVMProcess(session, "headless", ""); ccs.sendMessage("§bStarting VM for testing...");
session.getConsole().getDisplay().attachFramebuffer(0L, new MCFrameBuffer()); vbox.getMachines().get(0).launchVMProcess(session, "headless", "").waitForCompletion(2000);
session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer()));
ccs.sendMessage("§bLoading SketchMap..."); ccs.sendMessage("§bLoading SketchMap...");
img = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB); img = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB);
HashMap<Short, RelativeLocation> map = new HashMap<>(); HashMap<Short, RelativeLocation> map = new HashMap<>();

Binary file not shown.

Binary file not shown.

Binary file not shown.