Directly using VirtualBox from Java #5
7 changed files with 39 additions and 37 deletions
|
@ -16,6 +16,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="vboxjws.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
Binary file not shown.
|
@ -1,108 +1,115 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import org.virtualbox_5_1.IFramebuffer;
|
||||
import org.virtualbox_5_1.ObjectRefManager;
|
||||
import org.virtualbox_5_1.jaxws.VboxPortType;
|
||||
import org.mozilla.interfaces.IFramebuffer;
|
||||
import org.mozilla.interfaces.IFramebufferOverlay;
|
||||
import org.mozilla.interfaces.nsISupports;
|
||||
|
||||
public class MCFrameBuffer extends IFramebuffer {
|
||||
public class MCFrameBuffer implements IFramebuffer {
|
||||
|
||||
public MCFrameBuffer(String wrapped, ObjectRefManager objMgr, VboxPortType port) {
|
||||
super(wrapped, objMgr, port);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public nsISupports queryInterface(String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBitsPerPixel() {
|
||||
return 32;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesPerLine() {
|
||||
return 640 * 4;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getCapabilities(long[] arg0) {
|
||||
return new long[] { FramebufferCapabilities.UpdateImage };
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeight() {
|
||||
return 480;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeightReduction() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFramebufferOverlay getOverlay() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPixelFormat() {
|
||||
return BitmapFormat.RGBA;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
private byte visibleRegionB;
|
||||
private long visibleRegionL;
|
||||
|
||||
@Override
|
||||
public long getVisibleRegion(byte arg0, long arg1) {
|
||||
System.out.println("Visible region get.");
|
||||
return visibleRegionL;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWidth() {
|
||||
return 640;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWinId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify3DEvent(long arg0, byte[] arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChange(long arg0, long arg1, long arg2, long arg3, long arg4) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdate(long arg0, long arg1, long arg2, long arg3) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("UPDATE");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("UPDATE IMAGE");
|
||||
System.out.println("Update!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVHWACommand(byte arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleRegion(byte arg0, long arg1) {
|
||||
visibleRegionB = arg0;
|
||||
visibleRegionL = arg1;
|
||||
System.out.println("Visible region set.");
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean videoModeSupported(long arg0, long arg1, long arg2) {
|
||||
return true; // We support EVERYTHING
|
||||
}*/
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package sznp.virtualcomputer;
|
|||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.countercraft.movecraft.craft.Craft;
|
||||
|
@ -14,8 +13,6 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
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.ISession;
|
||||
import org.virtualbox_5_1.IVirtualBox;
|
||||
|
@ -39,13 +36,12 @@ public class PluginMain extends JavaPlugin {
|
|||
ConsoleCommandSender ccs = getServer().getConsoleSender();
|
||||
this.getCommand("computer").setExecutor(new Commands());
|
||||
ccs.sendMessage("§bInitializing VirtualBox...");
|
||||
// Connect con = new Connect("vbox:///");
|
||||
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
|
||||
vbox = manager.getVBox();
|
||||
session = manager.getSessionObject();
|
||||
vbox.getMachines().get(0).launchVMProcess(session, "headless", "");
|
||||
session.getConsole().getDisplay().attachFramebuffer(0L, new MCFrameBuffer());
|
||||
|
||||
ccs.sendMessage("§bStarting VM for testing...");
|
||||
vbox.getMachines().get(0).launchVMProcess(session, "headless", "").waitForCompletion(2000);
|
||||
session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer()));
|
||||
ccs.sendMessage("§bLoading SketchMap...");
|
||||
img = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB);
|
||||
HashMap<Short, RelativeLocation> map = new HashMap<>();
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue