Moved files to packages and Maven structure
This commit is contained in:
parent
4aee453274
commit
0dad9fdb84
17 changed files with 28 additions and 148 deletions
|
@ -5,22 +5,6 @@
|
||||||
<artifactId>VirtualComputer</artifactId>
|
<artifactId>VirtualComputer</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src</directory>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>.</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.dll</include>
|
|
||||||
<include>*.yml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
@ -28,9 +12,9 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<arg>-g</arg>
|
<arg>-g</arg>
|
||||||
</compilerArgs>
|
</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -91,12 +75,6 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
@ -5,22 +5,6 @@
|
||||||
<artifactId>VirtualComputer</artifactId>
|
<artifactId>VirtualComputer</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src</directory>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>.</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.dll</include>
|
|
||||||
<include>*.yml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
|
|
@ -9,6 +9,12 @@ 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.*;
|
||||||
|
import sznp.virtualcomputer.renderer.BukkitRenderer;
|
||||||
|
import sznp.virtualcomputer.renderer.GPURenderer;
|
||||||
|
import sznp.virtualcomputer.renderer.IRenderer;
|
||||||
|
import sznp.virtualcomputer.renderer.MCFrameBuffer;
|
||||||
|
import sznp.virtualcomputer.util.Scancode;
|
||||||
|
import sznp.virtualcomputer.util.VBoxLib;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
|
@ -6,6 +6,7 @@ import com.sun.jna.Pointer;
|
||||||
import jnr.ffi.LibraryLoader;
|
import jnr.ffi.LibraryLoader;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.map.MapPalette;
|
import org.bukkit.map.MapPalette;
|
||||||
|
import sznp.virtualcomputer.util.PXCLib;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.renderer;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.renderer;
|
||||||
|
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import net.minecraft.server.v1_12_R1.WorldMap;
|
import net.minecraft.server.v1_12_R1.WorldMap;
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.renderer;
|
||||||
|
|
||||||
import com.aparapi.Kernel;
|
import com.aparapi.Kernel;
|
||||||
import com.aparapi.Range;
|
import com.aparapi.Range;
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.renderer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.renderer;
|
||||||
|
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Pointer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -8,6 +8,7 @@ import org.mozilla.interfaces.IFramebufferOverlay;
|
||||||
import org.mozilla.interfaces.nsISupports;
|
import org.mozilla.interfaces.nsISupports;
|
||||||
import org.mozilla.xpcom.Mozilla;
|
import org.mozilla.xpcom.Mozilla;
|
||||||
import org.virtualbox_6_0.*;
|
import org.virtualbox_6_0.*;
|
||||||
|
import sznp.virtualcomputer.PluginMain;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.util;
|
||||||
|
|
||||||
import jnr.ffi.Pointer;
|
import jnr.ffi.Pointer;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.util;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The scancode values come from:
|
The scancode values come from:
|
||||||
|
@ -9,7 +9,7 @@ The scancode values come from:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
enum Scancode { // https://handmade.network/forums/t/2011-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names
|
public enum Scancode { // https://handmade.network/forums/t/2011-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names
|
||||||
|
|
||||||
sc_escape(0x01), sc_1(0x02), sc_2(0x03), sc_3(0x04), sc_4(0x05), sc_5(0x06), sc_6(0x07), sc_7(0x08), sc_8(
|
sc_escape(0x01), sc_1(0x02), sc_2(0x03), sc_3(0x04), sc_4(0x05), sc_5(0x06), sc_6(0x07), sc_7(0x08), sc_8(
|
||||||
0x09), sc_9(0x0A), sc_0(0x0B), sc_minus(0x0C), sc_equals(0x0D), sc_backspace(0x0E), sc_tab(0x0F), sc_q(
|
0x09), sc_9(0x0A), sc_0(0x0B), sc_minus(0x0C), sc_equals(0x0D), sc_backspace(0x0E), sc_tab(0x0F), sc_q(
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.util;
|
||||||
|
|
||||||
public interface VBoxLib {
|
public interface VBoxLib {
|
||||||
void RTR3InitExe(int argc, String argv, int somethingzero);
|
void RTR3InitExe(int argc, String argv, int somethingzero);
|
|
@ -1,4 +1,4 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer.util;
|
||||||
|
|
||||||
import com.sun.jna.Library;
|
import com.sun.jna.Library;
|
||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
|
@ -1,90 +0,0 @@
|
||||||
package sznp.virtualcomputer;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
|
|
||||||
public class JarUtils {
|
|
||||||
|
|
||||||
public static boolean extractFromJar(final String fileName,
|
|
||||||
final String dest) throws IOException {
|
|
||||||
if (getRunningJar() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final File file = new File(dest);
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
file.mkdir();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
final JarFile jar = getRunningJar();
|
|
||||||
final Enumeration<JarEntry> e = jar.entries();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
final JarEntry je = e.nextElement();
|
|
||||||
if (!je.getName().contains(fileName)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final InputStream in = new BufferedInputStream(
|
|
||||||
jar.getInputStream(je));
|
|
||||||
final OutputStream out = new BufferedOutputStream(
|
|
||||||
new FileOutputStream(file));
|
|
||||||
copyInputStream(in, out);
|
|
||||||
jar.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
jar.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static void copyInputStream(final InputStream in,
|
|
||||||
final OutputStream out) throws IOException {
|
|
||||||
try {
|
|
||||||
final byte[] buff = new byte[4096];
|
|
||||||
int n;
|
|
||||||
while ((n = in.read(buff)) > 0) {
|
|
||||||
out.write(buff, 0, n);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static URL getJarUrl(final File file) throws IOException {
|
|
||||||
return new URL("jar:" + file.toURI().toURL().toExternalForm() + "!/");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JarFile getRunningJar() throws IOException {
|
|
||||||
if (!RUNNING_FROM_JAR) {
|
|
||||||
return null; // null if not running from jar
|
|
||||||
}
|
|
||||||
String path = new File(JarUtils.class.getProtectionDomain()
|
|
||||||
.getCodeSource().getLocation().getPath()).getAbsolutePath();
|
|
||||||
path = URLDecoder.decode(path, "UTF-8");
|
|
||||||
return new JarFile(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean RUNNING_FROM_JAR = false;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final URL resource = JarUtils.class.getClassLoader().getResource(
|
|
||||||
"plugin.yml");
|
|
||||||
if (resource != null) {
|
|
||||||
RUNNING_FROM_JAR = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue