Added files

This commit is contained in:
Norbi Peti 2016-07-31 01:59:41 +02:00
commit 1588c7fa0f
5 changed files with 120 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/bin/
/target/

23
.project Normal file
View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MCServerRunner</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

27
pom.xml Normal file
View file

@ -0,0 +1,27 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ButtonDevTeam</groupId>
<artifactId>MCServerRunner</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.xeustechnologies</groupId>
<artifactId>jcl-core</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,7 @@
package buttondevteam.serverrunner;
import org.bukkit.craftbukkit.Main;
public class ServerMain extends Main {
}

View file

@ -0,0 +1,61 @@
package buttondevteam.serverrunner;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.Main;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.xeustechnologies.jcl.ClasspathResources;
import org.xeustechnologies.jcl.Configuration;
import org.xeustechnologies.jcl.JarClassLoader;
import org.xeustechnologies.jcl.JclObjectFactory;
import org.xeustechnologies.jcl.proxy.CglibProxyProvider;
import org.xeustechnologies.jcl.proxy.ProxyProviderFactory;
public class ServerRunner {
private static final String SERVER_VERSION = "1.9.2";
@SuppressWarnings("static-access")
public static void main(String[] args) {
try {
System.out.println("Loading server classes...");
JarClassLoader jcl = new JarClassLoader();
jcl.getSystemLoader().setEnabled(true);
jcl.getCurrentLoader().setEnabled(false);
jcl.getParentLoader().setEnabled(false);
jcl.getOsgiBootLoader().setEnabled(false);
jcl.getThreadLoader().setEnabled(false);
jcl.getLocalLoader().setEnabled(true);
jcl.add("spigot-" + SERVER_VERSION + ".jar");
jcl.add("craftbukkit-" + SERVER_VERSION + ".jar");
System.out.println("Starting server...");
// Set default to cglib (from version 2.2.1)
ProxyProviderFactory.setDefaultProxyProvider(new CglibProxyProvider());
// Create a factory of castable objects/proxies
JclObjectFactory factory = JclObjectFactory.getInstance(true);
// Create and cast object of loaded class
Main serverinstance = (Main) factory.create(jcl, "buttondevteam.serverrunner.ServerMain");
serverinstance.main(new String[0]);
Thread.sleep(5000); // Wait for primaryThread to be set
while (Bukkit.getServer() == null || ((CraftServer) Bukkit.getServer()).getServer() == null
|| ((CraftServer) Bukkit.getServer()).getServer().primaryThread == null)
;
((CraftServer) Bukkit.getServer()).getServer().primaryThread.join();
/*
* for (Thread t : Thread.getAllStackTraces().keySet()) if
* (t.getName().equals("Server Infinisleeper")) t.join();
*/ // TODO: After stopping the server it stops
System.out.println("Unloading classes...");
for (String entry : jcl.getLoadedClasses().keySet())
jcl.unloadClass(entry);
System.out.println("Done!");
} catch (Exception e) {
e.printStackTrace();
}
}
}