Recreating session, fixes
Compiled and added MSCOM library
This commit is contained in:
parent
8fbf044530
commit
dd9b850da8
6 changed files with 73 additions and 28 deletions
|
@ -90,4 +90,26 @@
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<!-- <profiles>
|
||||||
|
<profile>
|
||||||
|
<id>XPCOM</id>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.virtualbox</groupId>
|
||||||
|
<artifactId>VirtualBox</artifactId>
|
||||||
|
<version>6.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>MSCOM</id>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.virtualbox</groupId>
|
||||||
|
<artifactId>VirtualBox-MSCOM</artifactId>
|
||||||
|
<version>6.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
</profiles> -->
|
||||||
</project>
|
</project>
|
Binary file not shown.
|
@ -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-MSCOM</artifactId>
|
||||||
|
<version>6.0</version>
|
||||||
|
<description>POM was created from install:install-file</description>
|
||||||
|
</project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<metadata>
|
||||||
|
<groupId>org.virtualbox</groupId>
|
||||||
|
<artifactId>VirtualBox-MSCOM</artifactId>
|
||||||
|
<versioning>
|
||||||
|
<release>6.0</release>
|
||||||
|
<versions>
|
||||||
|
<version>6.0</version>
|
||||||
|
</versions>
|
||||||
|
<lastUpdated>20190405225845</lastUpdated>
|
||||||
|
</versioning>
|
||||||
|
</metadata>
|
|
@ -25,11 +25,13 @@ public final class Computer {
|
||||||
private IMachine machine;
|
private IMachine machine;
|
||||||
private MachineEventHandler handler;
|
private MachineEventHandler handler;
|
||||||
private IEventListener listener;
|
private IEventListener listener;
|
||||||
|
private VirtualBoxManager manager;
|
||||||
|
|
||||||
@java.beans.ConstructorProperties({"plugin"})
|
@java.beans.ConstructorProperties({"plugin"})
|
||||||
public Computer(PluginMain plugin, ISession session, IVirtualBox vbox) {
|
public Computer(PluginMain plugin, VirtualBoxManager manager, IVirtualBox vbox) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.session = session;
|
this.manager = manager;
|
||||||
|
session = manager.getSessionObject();
|
||||||
this.vbox = vbox;
|
this.vbox = vbox;
|
||||||
if (instance != null) throw new IllegalStateException("A computer already exists!");
|
if (instance != null) throw new IllegalStateException("A computer already exists!");
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -94,14 +96,13 @@ public final class Computer {
|
||||||
public void Stop(CommandSender sender) {
|
public void Stop(CommandSender sender) {
|
||||||
if (checkMachineNotRunning(sender)) {
|
if (checkMachineNotRunning(sender)) {
|
||||||
if (session.getState().equals(SessionState.Locked)) {
|
if (session.getState().equals(SessionState.Locked)) {
|
||||||
session.unlockMachine();
|
onMachineStop(sender); //Needed for session reset
|
||||||
sendMessage(sender, "§eComputer powered off, released it.");
|
sendMessage(sender, "§eComputer was already off, released it.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendMessage(sender, "§eStopping computer...");
|
sendMessage(sender, "§eStopping computer...");
|
||||||
session.getConsole().powerDown().waitForCompletion(2000);
|
session.getConsole().powerDown();
|
||||||
sendMessage(sender, "§eComputer stopped.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PowerButton(CommandSender sender, int index) {
|
public void PowerButton(CommandSender sender, int index) {
|
||||||
|
@ -202,12 +203,13 @@ public final class Computer {
|
||||||
session.unlockMachine(); //Needs to be outside of the event handler
|
session.unlockMachine(); //Needs to be outside of the event handler
|
||||||
handler = null;
|
handler = null;
|
||||||
machine = null;
|
machine = null;
|
||||||
|
session = manager.getSessionObject();
|
||||||
|
sendMessage(sender, "§eComputer powered off."); //This block runs later
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GPURendererInternal.setPixels(new byte[1], 0, 0); //Black screen
|
GPURendererInternal.setPixels(new byte[1], 0, 0); //Black screen
|
||||||
stopEvents();
|
stopEvents();
|
||||||
MouseLockerPlayerListener.computerStop();
|
MouseLockerPlayerListener.computerStop();
|
||||||
sendMessage(sender, "§eComputer powered off.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEvents() {
|
public void stopEvents() {
|
||||||
|
@ -217,4 +219,14 @@ public final class Computer {
|
||||||
handler.disable();
|
handler.disable();
|
||||||
listener = null;
|
listener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pluginDisable(CommandSender ccs) {
|
||||||
|
if (session.getState() == SessionState.Locked) {
|
||||||
|
if (session.getMachine().getState().equals(MachineState.Running)) {
|
||||||
|
ccs.sendMessage("§aSaving machine state...");
|
||||||
|
session.getMachine().saveState().waitForCompletion(10000);
|
||||||
|
}
|
||||||
|
session.unlockMachine();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import org.bukkit.Bukkit;
|
||||||
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.virtualbox_6_0.*;
|
import org.virtualbox_6_0.IEventListener;
|
||||||
|
import org.virtualbox_6_0.IVirtualBox;
|
||||||
|
import org.virtualbox_6_0.VirtualBoxManager;
|
||||||
import sznp.virtualcomputer.events.VBoxEventHandler;
|
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;
|
||||||
|
@ -21,15 +23,10 @@ import java.util.Arrays;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class PluginMain extends JavaPlugin {
|
public class PluginMain extends JavaPlugin {
|
||||||
public static final int MCX = 5;
|
private static final int MCX = 5;
|
||||||
public static final int MCY = 4;
|
private static final int MCY = 4;
|
||||||
private IVirtualBox vbox;
|
|
||||||
private ISession session;
|
|
||||||
private IMachine machine;
|
|
||||||
private BukkitTask screenupdatetask;
|
|
||||||
private BukkitTask mousetask;
|
private BukkitTask mousetask;
|
||||||
private IEventListener listener;
|
private IEventListener listener;
|
||||||
private IEventSource source;
|
|
||||||
|
|
||||||
public static PluginMain Instance;
|
public static PluginMain Instance;
|
||||||
//public static ByteBuffer allpixels = ByteBuffer.allocate(640 * 480 * 4); // It's set on each change
|
//public static ByteBuffer allpixels = ByteBuffer.allocate(640 * 480 * 4); // It's set on each change
|
||||||
|
@ -37,7 +34,7 @@ public class PluginMain extends JavaPlugin {
|
||||||
* Only used if {@link #direct} is false.
|
* Only used if {@link #direct} is false.
|
||||||
*/
|
*/
|
||||||
public static ByteBuffer allpixels; // It's set on each change
|
public static ByteBuffer allpixels; // It's set on each change
|
||||||
public static ArrayList<IRenderer> renderers = new ArrayList<>();
|
private static ArrayList<IRenderer> renderers = new ArrayList<>();
|
||||||
/*
|
/*
|
||||||
* Only used if {@link #direct} is true.
|
* Only used if {@link #direct} is true.
|
||||||
*/
|
*/
|
||||||
|
@ -72,10 +69,9 @@ public class PluginMain extends JavaPlugin {
|
||||||
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
|
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
|
||||||
VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load("vboxjxpcom");
|
VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load("vboxjxpcom");
|
||||||
vbl.RTR3InitExe(0, "", 0);
|
vbl.RTR3InitExe(0, "", 0);
|
||||||
vbox = manager.getVBox();
|
IVirtualBox vbox = manager.getVBox();
|
||||||
listener = new VBoxEventHandler().registerTo(source = vbox.getEventSource());
|
listener = new VBoxEventHandler().registerTo(vbox.getEventSource());
|
||||||
session = manager.getSessionObject();
|
new Computer(this, manager, vbox); //Saves itself
|
||||||
new Computer(this, session, vbox); //Saves itself
|
|
||||||
ccs.sendMessage("§bLoading Screen...");
|
ccs.sendMessage("§bLoading Screen...");
|
||||||
try {
|
try {
|
||||||
//throw new NoClassDefFoundError("Test error pls ignore");
|
//throw new NoClassDefFoundError("Test error pls ignore");
|
||||||
|
@ -121,14 +117,7 @@ public class PluginMain extends JavaPlugin {
|
||||||
}*/
|
}*/
|
||||||
((VBoxEventHandler) listener.getTypedWrapped()).disable(); //The save progress wait locks with the event
|
((VBoxEventHandler) listener.getTypedWrapped()).disable(); //The save progress wait locks with the event
|
||||||
if (Computer.getInstance() != null)
|
if (Computer.getInstance() != null)
|
||||||
Computer.getInstance().stopEvents();
|
Computer.getInstance().pluginDisable(ccs);
|
||||||
if (session.getState() == SessionState.Locked) {
|
|
||||||
if (session.getMachine().getState().equals(MachineState.Running)) {
|
|
||||||
ccs.sendMessage("§aSaving machine state...");
|
|
||||||
session.getMachine().saveState().waitForCompletion(10000);
|
|
||||||
}
|
|
||||||
session.unlockMachine();
|
|
||||||
}
|
|
||||||
ccs.sendMessage("§aHuh.");
|
ccs.sendMessage("§aHuh.");
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue