Delayed query on change, improved code a bit
Removed Movecraft dependency as well
This commit is contained in:
parent
3e1691f4e9
commit
57a6ff818b
6 changed files with 33 additions and 63 deletions
|
@ -74,12 +74,6 @@
|
||||||
<version>1.12-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.countercraft</groupId>
|
|
||||||
<artifactId>Movecraft</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.virtualbox</groupId>
|
<groupId>org.virtualbox</groupId>
|
||||||
<artifactId>VirtualBox</artifactId>
|
<artifactId>VirtualBox</artifactId>
|
||||||
|
|
Binary file not shown.
|
@ -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>net.countercraft</groupId>
|
|
||||||
<artifactId>Movecraft</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<description>POM was created from install:install-file</description>
|
|
||||||
</project>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<metadata>
|
|
||||||
<groupId>net.countercraft</groupId>
|
|
||||||
<artifactId>Movecraft</artifactId>
|
|
||||||
<versioning>
|
|
||||||
<release>3.0.0</release>
|
|
||||||
<versions>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</versions>
|
|
||||||
<lastUpdated>20161228182908</lastUpdated>
|
|
||||||
</versioning>
|
|
||||||
</metadata>
|
|
|
@ -1,10 +1,6 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer;
|
||||||
|
|
||||||
import net.countercraft.movecraft.craft.Craft;
|
|
||||||
import net.countercraft.movecraft.craft.CraftManager;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -20,35 +16,35 @@ public class Commands implements CommandExecutor {
|
||||||
return false;
|
return false;
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "start":
|
case "start":
|
||||||
|
case "poweron":
|
||||||
|
case "on":
|
||||||
|
case "startup":
|
||||||
PluginMain.Instance.Start(sender);
|
PluginMain.Instance.Start(sender);
|
||||||
break;
|
break;
|
||||||
case "stop":
|
case "stop":
|
||||||
|
case "poweroff":
|
||||||
|
case "off":
|
||||||
|
case "shutdown":
|
||||||
|
case "kill":
|
||||||
PluginMain.Instance.Stop(sender);
|
PluginMain.Instance.Stop(sender);
|
||||||
break;
|
break;
|
||||||
case "debug":
|
|
||||||
World w = Bukkit.getWorlds().get(0);
|
|
||||||
Craft[] crafts = CraftManager.getInstance().getCraftsInWorld(w);
|
|
||||||
sender.sendMessage("World: " + w);
|
|
||||||
sender.sendMessage("Crafts: " + crafts);
|
|
||||||
sender.sendMessage("Craft type: " + crafts[0].getType().getCraftName());
|
|
||||||
sender.sendMessage("DX: " + crafts[0].getLastDX());
|
|
||||||
sender.sendMessage("DY: " + crafts[0].getLastDY());
|
|
||||||
sender.sendMessage("DZ: " + crafts[0].getLastDZ());
|
|
||||||
sender.sendMessage("MouseSpeed: " + PluginMain.MouseSpeed);
|
|
||||||
sender.sendMessage("Block: " + Bukkit.getWorlds().get(0)
|
|
||||||
.getBlockAt(crafts[0].getMinX(), crafts[0].getMinY() - 1, crafts[0].getMinZ()).getType()); // Block:
|
|
||||||
// AIR
|
|
||||||
break;
|
|
||||||
case "powerbutton":
|
case "powerbutton":
|
||||||
|
case "pwrbtn":
|
||||||
|
case "powerbtn":
|
||||||
PluginMain.Instance.PowerButton(sender);
|
PluginMain.Instance.PowerButton(sender);
|
||||||
break;
|
break;
|
||||||
case "reset":
|
case "reset":
|
||||||
|
case "restart":
|
||||||
PluginMain.Instance.Reset(sender);
|
PluginMain.Instance.Reset(sender);
|
||||||
break;
|
break;
|
||||||
case "fix":
|
case "fix":
|
||||||
|
case "fixscreen":
|
||||||
PluginMain.Instance.FixScreen(sender);
|
PluginMain.Instance.FixScreen(sender);
|
||||||
break;
|
break;
|
||||||
case "key":
|
case "key":
|
||||||
|
case "press":
|
||||||
|
case "presskey":
|
||||||
|
case "keypress":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage("§cUsage: /computer key <key> [down/up|duration(ticks)]");
|
sender.sendMessage("§cUsage: /computer key <key> [down/up|duration(ticks)]");
|
||||||
return true;
|
return true;
|
||||||
|
@ -69,7 +65,7 @@ public class Commands implements CommandExecutor {
|
||||||
showusage = false;
|
showusage = false;
|
||||||
} else {
|
} else {
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
PluginMain.Instance.UpdateMouse(sender, 0, 0, 0, 0, args[1], (args[2].equals("down")));
|
PluginMain.Instance.UpdateMouse(sender, 0, 0, 0, 0, args[1], args[2].equals("down"));
|
||||||
showusage = false;
|
showusage = false;
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
PluginMain.Instance.UpdateMouse(sender, 0, 0, 0, 0, args[1]);
|
PluginMain.Instance.UpdateMouse(sender, 0, 0, 0, 0, args[1]);
|
||||||
|
@ -82,15 +78,10 @@ public class Commands implements CommandExecutor {
|
||||||
sender.sendMessage("§cOr: /computer mouse <button> [up/down]");
|
sender.sendMessage("§cOr: /computer mouse <button> [up/down]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "mspeed":
|
case "input":
|
||||||
if (args.length < 2) {
|
case "show":
|
||||||
sender.sendMessage("§cUsage: /computer mspeed <speed>");
|
case "showinput":
|
||||||
return true;
|
case "shinput": {
|
||||||
}
|
|
||||||
PluginMain.MouseSpeed = Integer.parseInt(args[1]);
|
|
||||||
sender.sendMessage("Mouse speed set to " + args[1]);
|
|
||||||
break;
|
|
||||||
case "input": {
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("§cError: Only players can use this command.");
|
sender.sendMessage("§cError: Only players can use this command.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -99,7 +90,9 @@ public class Commands implements CommandExecutor {
|
||||||
sender.sendMessage("§cUsage: /computer input <key|mouse>");
|
sender.sendMessage("§cUsage: /computer input <key|mouse>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[1].equalsIgnoreCase("key")) {
|
switch (args[1].toLowerCase()) {
|
||||||
|
case "key":
|
||||||
|
case "keyboard":
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
||||||
+ " [\"\",{\"text\":\" [0]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D0\"}},{\"text\":\" [1]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D1\"}},{\"text\":\" [2]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D2\"}},{\"text\":\" [3]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D3\"}},{\"text\":\" [4]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D4\"}},{\"text\":\" [5]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D5\"}},{\"text\":\" [6]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D6\"}},{\"text\":\" [7]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D7\"}},{\"text\":\" [8]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D8\"}},{\"text\":\" [9]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D9\"}}]");
|
+ " [\"\",{\"text\":\" [0]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D0\"}},{\"text\":\" [1]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D1\"}},{\"text\":\" [2]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D2\"}},{\"text\":\" [3]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D3\"}},{\"text\":\" [4]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D4\"}},{\"text\":\" [5]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D5\"}},{\"text\":\" [6]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D6\"}},{\"text\":\" [7]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D7\"}},{\"text\":\" [8]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D8\"}},{\"text\":\" [9]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D9\"}}]");
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
||||||
|
@ -110,7 +103,7 @@ public class Commands implements CommandExecutor {
|
||||||
+ " [\"\",{\"text\":\" [Z]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Z\"}},{\"text\":\" [X]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key X\"}},{\"text\":\" [C]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key C\"}},{\"text\":\" [V]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key V\"}},{\"text\":\" [B]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key B\"}},{\"text\":\" [N]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key N\"}},{\"text\":\" [M]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key M\"}}]");
|
+ " [\"\",{\"text\":\" [Z]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Z\"}},{\"text\":\" [X]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key X\"}},{\"text\":\" [C]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key C\"}},{\"text\":\" [V]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key V\"}},{\"text\":\" [B]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key B\"}},{\"text\":\" [N]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key N\"}},{\"text\":\" [M]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key M\"}}]");
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName()
|
||||||
+ " [\"\",{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlLeft\"}},{\"text\":\" [Alt]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltLeft\"}},{\"text\":\" [Space]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Space\"}},{\"text\":\" [AltGr]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltRight\"}},{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlRight\"}}]");
|
+ " [\"\",{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlLeft\"}},{\"text\":\" [Alt]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltLeft\"}},{\"text\":\" [Space]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Space\"}},{\"text\":\" [AltGr]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltRight\"}},{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlRight\"}}]");
|
||||||
} else if (args[1].equalsIgnoreCase("mouse")) {
|
case "mouse":
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("§cOnly ingame players can use this command.");
|
sender.sendMessage("§cOnly ingame players can use this command.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -122,7 +115,8 @@ public class Commands implements CommandExecutor {
|
||||||
MouseLockerPlayerListener.LockedPlayers.remove(sender);
|
MouseLockerPlayerListener.LockedPlayers.remove(sender);
|
||||||
sender.sendMessage("§bMouse unlocked.");
|
sender.sendMessage("§bMouse unlocked.");
|
||||||
}
|
}
|
||||||
} else if (args[1].equalsIgnoreCase("mspeed")) {
|
case "mspeed":
|
||||||
|
case "mousespeed":
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
sender.sendMessage("§cUsage: /computer input mspeed <integer>");
|
sender.sendMessage("§cUsage: /computer input mspeed <integer>");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.mozilla.interfaces.IFramebuffer;
|
import org.mozilla.interfaces.IFramebuffer;
|
||||||
import org.mozilla.interfaces.IFramebufferOverlay;
|
import org.mozilla.interfaces.IFramebufferOverlay;
|
||||||
import org.mozilla.interfaces.nsISupports;
|
import org.mozilla.interfaces.nsISupports;
|
||||||
|
@ -78,11 +79,13 @@ public class MCFrameBuffer implements IFramebuffer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height) {
|
public void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> {
|
||||||
display.querySourceBitmap(0L, holder); // TODO: Crashes here
|
display.querySourceBitmap(0L, holder); // TODO: Crashes here
|
||||||
holder.value.getTypedWrapped().queryBitmapInfo(PluginMain.allpixels, new long[] { width },
|
holder.value.getTypedWrapped().queryBitmapInfo(PluginMain.allpixels, new long[] { width },
|
||||||
new long[] { height }, new long[] { getBitsPerPixel() }, new long[] { getBytesPerLine() },
|
new long[] { height }, new long[] { getBitsPerPixel() }, new long[] { getBytesPerLine() },
|
||||||
new long[] { getPixelFormat() }); // These are out params but whatever
|
new long[] { getPixelFormat() }); // These are out params but whatever
|
||||||
System.out.println("Change!");
|
System.out.println("Change!");
|
||||||
|
}, 5); // Wait 1/4th of a second
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue