2017-01-30 21:22:36 +01:00
package net.ME1312.SubServers.Host ;
2018-10-08 01:25:08 +02:00
import com.dosse.upnp.UPnP ;
2018-09-09 00:06:21 +02:00
import net.ME1312.Galaxi.Engine.GalaxiEngine ;
2018-12-18 00:49:32 +01:00
import net.ME1312.Galaxi.Engine.GalaxiOption ;
import net.ME1312.Galaxi.Event.GalaxiReloadEvent ;
2019-01-06 07:58:13 +01:00
import net.ME1312.Galaxi.Galaxi ;
2018-09-09 00:06:21 +02:00
import net.ME1312.Galaxi.Library.Config.YAMLConfig ;
import net.ME1312.Galaxi.Library.Config.YAMLSection ;
import net.ME1312.Galaxi.Library.Log.Logger ;
import net.ME1312.Galaxi.Library.NamedContainer ;
import net.ME1312.Galaxi.Library.UniversalFile ;
import net.ME1312.Galaxi.Library.Util ;
import net.ME1312.Galaxi.Library.Version.Version ;
import net.ME1312.Galaxi.Library.Version.VersionType ;
import net.ME1312.Galaxi.Plugin.Plugin ;
import net.ME1312.Galaxi.Plugin.PluginInfo ;
2017-04-01 07:37:48 +02:00
import net.ME1312.SubServers.Host.Executable.SubCreator ;
2019-01-17 19:12:32 +01:00
import net.ME1312.SubServers.Host.Executable.SubLogger ;
2017-04-01 07:37:48 +02:00
import net.ME1312.SubServers.Host.Executable.SubServer ;
2018-03-27 06:31:38 +02:00
import net.ME1312.SubServers.Host.Library.* ;
2018-01-05 21:37:23 +01:00
import net.ME1312.SubServers.Host.Network.Cipher ;
2017-01-30 21:22:36 +01:00
import net.ME1312.SubServers.Host.Network.SubDataClient ;
2017-04-01 18:50:09 +02:00
import org.json.JSONObject ;
2017-01-30 21:22:36 +01:00
2017-04-14 04:39:51 +02:00
import java.io.* ;
2018-07-17 09:10:17 +02:00
import java.lang.reflect.Field ;
2017-01-30 21:22:36 +01:00
import java.net.InetAddress ;
import java.net.URL ;
2017-08-18 11:58:06 +02:00
import java.nio.charset.Charset ;
2017-01-30 21:22:36 +01:00
import java.nio.file.Files ;
import java.util.* ;
2017-04-01 18:50:09 +02:00
import java.util.concurrent.TimeUnit ;
2018-09-09 00:06:21 +02:00
import java.util.jar.Manifest ;
2017-01-30 21:22:36 +01:00
/ * *
* SubServers . Host Main Class
* /
2019-04-19 17:14:57 +02:00
@Plugin ( name = " SubServers.Host " , version = " 2.14a " , authors = " ME1312 " , description = " Host SubServers from other Machines " , website = " https://github.com/ME1312/SubServers-2 " )
2017-04-16 19:02:14 +02:00
public final class ExHost {
2018-01-02 23:29:25 +01:00
protected NamedContainer < Long , Map < String , Map < String , String > > > lang = null ;
2017-05-30 21:38:51 +02:00
public HashMap < String , SubCreator . ServerTemplate > templates = new HashMap < String , SubCreator . ServerTemplate > ( ) ;
2017-04-01 07:37:48 +02:00
public HashMap < String , SubServer > servers = new HashMap < String , SubServer > ( ) ;
public SubCreator creator ;
2018-07-23 05:44:20 +02:00
public Logger log ;
2018-09-09 00:06:21 +02:00
public PluginInfo info ;
public GalaxiEngine engine ;
2017-01-30 21:22:36 +01:00
public YAMLConfig config ;
2017-04-01 07:37:48 +02:00
public YAMLSection host = null ;
2017-01-30 21:22:36 +01:00
public SubDataClient subdata = null ;
2018-06-02 21:02:03 +02:00
public final SubAPI api = new SubAPI ( this ) ;
2017-01-30 21:22:36 +01:00
2017-12-06 23:34:47 +01:00
private boolean running = false ;
2017-01-30 21:22:36 +01:00
2017-02-08 01:39:18 +01:00
/ * *
* SubServers . Host Launch
*
* @param args Args
* @throws Exception
* /
2018-09-09 00:06:21 +02:00
static void main ( String [ ] args ) throws Exception {
2018-01-12 22:56:22 +01:00
if ( System . getProperty ( " RM.subservers " , " true " ) . equalsIgnoreCase ( " true " ) ) {
2018-06-09 18:19:25 +02:00
joptsimple . OptionParser parser = new joptsimple . OptionParser ( ) ;
parser . allowsUnrecognizedOptions ( ) ;
parser . accepts ( " v " ) ;
parser . accepts ( " version " ) ;
parser . accepts ( " noconsole " ) ;
joptsimple . OptionSet options = parser . parse ( args ) ;
if ( options . has ( " version " ) | | options . has ( " v " ) ) {
2018-10-18 05:17:23 +02:00
String osarch ;
if ( System . getProperty ( " os.name " ) . toLowerCase ( ) . startsWith ( " windows " ) ) {
String arch = System . getenv ( " PROCESSOR_ARCHITECTURE " ) ;
String wow64Arch = System . getenv ( " PROCESSOR_ARCHITEW6432 " ) ;
osarch = arch ! = null & & arch . endsWith ( " 64 " ) | | wow64Arch ! = null & & wow64Arch . endsWith ( " 64 " ) ? " x64 " : " x86 " ;
} else if ( System . getProperty ( " os.arch " ) . endsWith ( " 86 " ) ) {
osarch = " x86 " ;
} else if ( System . getProperty ( " os.arch " ) . endsWith ( " 64 " ) ) {
osarch = " x64 " ;
} else {
osarch = System . getProperty ( " os.arch " ) ;
}
String javaarch = null ;
switch ( System . getProperty ( " sun.arch.data.model " ) ) {
case " 32 " :
javaarch = " x86 " ;
break ;
case " 64 " :
javaarch = " x64 " ;
break ;
default :
if ( ! System . getProperty ( " sun.arch.data.model " ) . equalsIgnoreCase ( " unknown " ) )
javaarch = System . getProperty ( " sun.arch.data.model " ) ;
}
2018-09-09 00:06:21 +02:00
Version galaxi = Version . fromString ( GalaxiEngine . class . getAnnotation ( Plugin . class ) . version ( ) ) ;
Version subservers = Version . fromString ( ExHost . class . getAnnotation ( Plugin . class ) . version ( ) ) ;
Version galaxibuild = null ;
Version subserversbuild = null ;
2018-07-17 09:10:17 +02:00
try {
2018-09-09 00:06:21 +02:00
Manifest manifest = new Manifest ( GalaxiEngine . class . getResourceAsStream ( " /META-INF/GalaxiEngine.MF " ) ) ;
if ( manifest . getMainAttributes ( ) . getValue ( " Implementation-Version " ) ! = null & & manifest . getMainAttributes ( ) . getValue ( " Implementation-Version " ) . length ( ) > 0 )
galaxibuild = new Version ( manifest . getMainAttributes ( ) . getValue ( " Implementation-Version " ) ) ;
} catch ( Exception e ) { } try {
2019-01-15 00:28:18 +01:00
if ( Util . reflect ( Version . class . getDeclaredField ( " type " ) , subservers ) ! = VersionType . SNAPSHOT & & ExHost . class . getPackage ( ) . getSpecificationTitle ( ) ! = null )
2018-09-09 00:06:21 +02:00
subserversbuild = new Version ( ExHost . class . getPackage ( ) . getSpecificationTitle ( ) ) ;
2018-07-17 09:10:17 +02:00
} catch ( Exception e ) { }
2018-06-09 18:19:25 +02:00
System . out . println ( " " ) ;
2018-10-18 05:17:23 +02:00
System . out . println ( System . getProperty ( " os.name " ) + ( ( ! System . getProperty ( " os.name " ) . toLowerCase ( ) . startsWith ( " windows " ) ) ? ' ' + System . getProperty ( " os.version " ) : " " ) + ( ( osarch ! = null ) ? " [ " + osarch + ']' : " " ) + ',' ) ;
System . out . println ( " Java " + System . getProperty ( " java.version " ) + ( ( javaarch ! = null ) ? " [ " + javaarch + ']' : " " ) + ',' ) ;
2018-09-09 00:06:21 +02:00
System . out . println ( GalaxiEngine . class . getAnnotation ( Plugin . class ) . name ( ) + " v " + galaxi . toExtendedString ( ) + ( ( galaxibuild ! = null ) ? " ( " + galaxibuild + ')' : " " )
+ ( ( GalaxiEngine . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . equals ( ExHost . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) ) ) ? " [Patched] " : " " ) + ',' ) ;
System . out . println ( ExHost . class . getAnnotation ( Plugin . class ) . name ( ) + " v " + subservers . toExtendedString ( ) + ( ( subserversbuild ! = null ) ? " ( " + subserversbuild + ')' : " " ) ) ;
2018-06-09 18:19:25 +02:00
System . out . println ( " " ) ;
} else {
new ExHost ( options ) ;
}
2018-01-12 22:56:22 +01:00
} else {
System . out . println ( " >> SubServers code has been disallowed to work on this machine " ) ;
System . out . println ( " >> Check with your provider for more information " ) ;
System . exit ( 1 ) ;
}
2017-01-30 21:22:36 +01:00
}
2018-01-21 21:45:27 +01:00
2018-06-09 18:19:25 +02:00
private ExHost ( joptsimple . OptionSet options ) {
2017-01-30 21:22:36 +01:00
log = new Logger ( " SubServers " ) ;
2018-09-09 00:06:21 +02:00
2017-01-30 21:22:36 +01:00
try {
2018-09-09 00:06:21 +02:00
info = PluginInfo . getPluginInfo ( this ) ;
info . setLogger ( log ) ;
2018-11-03 00:48:46 +01:00
if ( ExHost . class . getPackage ( ) . getSpecificationTitle ( ) ! = null ) info . setSignature ( new Version ( ExHost . class . getPackage ( ) . getSpecificationTitle ( ) ) ) ;
2018-10-24 07:37:55 +02:00
info . setIcon ( ExHost . class . getResourceAsStream ( " /net/ME1312/SubServers/Host/Library/Files/icon.png " ) ) ;
2018-09-09 00:06:21 +02:00
engine = GalaxiEngine . init ( info ) ;
log . info . println ( " Loading SubServers.Host v " + info . getVersion ( ) . toString ( ) + " Libraries " ) ;
if ( ! ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) . exists ( ) ) ) {
Util . copyFromJar ( ExHost . class . getClassLoader ( ) , " net/ME1312/SubServers/Host/Library/Files/config.yml " , new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) . getPath ( ) ) ;
2017-02-08 01:39:18 +01:00
log . info . println ( " Created ~/config.yml " ) ;
2019-01-17 18:44:47 +01:00
} else if ( ( ( new YAMLConfig ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) ) ) . get ( ) . getSection ( " Settings " ) . getVersion ( " Version " , new Version ( 0 ) ) . compareTo ( new Version ( " 2.11.2a+ " ) ) ) ! = 0 ) {
2018-09-09 00:06:21 +02:00
Files . move ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) . toPath ( ) , new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.old " + Math . round ( Math . random ( ) * 100000 ) + " .yml " ) . toPath ( ) ) ;
2017-01-30 21:22:36 +01:00
2018-09-09 00:06:21 +02:00
Util . copyFromJar ( ExHost . class . getClassLoader ( ) , " net/ME1312/SubServers/Host/Library/Files/config.yml " , new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) . getPath ( ) ) ;
2017-02-08 01:39:18 +01:00
log . info . println ( " Updated ~/config.yml " ) ;
2017-01-30 21:22:36 +01:00
}
2018-09-09 00:06:21 +02:00
config = new YAMLConfig ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " config.yml " ) ) ;
2017-04-01 07:37:48 +02:00
2018-09-09 00:06:21 +02:00
if ( ! ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Templates " ) . exists ( ) ) ) {
new UniversalFile ( engine . getRuntimeDirectory ( ) , " Templates " ) . mkdir ( ) ;
2018-01-21 21:45:27 +01:00
log . info . println ( " Created ~/Templates/ " ) ;
}
2018-09-09 00:06:21 +02:00
if ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted " ) . exists ( ) ) {
int f = new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted " ) . listFiles ( ) . length ;
for ( File file : new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted " ) . listFiles ( ) ) {
2017-04-01 18:50:09 +02:00
try {
if ( file . isDirectory ( ) ) {
2018-09-09 00:06:21 +02:00
if ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted: " + file . getName ( ) + " :info.json " ) . exists ( ) ) {
FileReader reader = new FileReader ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted: " + file . getName ( ) + " :info.json " ) ) ;
2018-03-14 08:01:44 +01:00
JSONObject json = new JSONObject ( Util . readAll ( reader ) ) ;
2018-03-27 06:31:38 +02:00
reader . close ( ) ;
2017-04-01 18:50:09 +02:00
if ( json . keySet ( ) . contains ( " Timestamp " ) ) {
if ( TimeUnit . MILLISECONDS . toDays ( Calendar . getInstance ( ) . getTime ( ) . getTime ( ) - json . getLong ( " Timestamp " ) ) > = 7 ) {
Util . deleteDirectory ( file ) ;
f - - ;
2017-05-30 21:38:51 +02:00
log . info . println ( " Removed ~/Recently Deleted/ " + file . getName ( ) ) ;
2017-04-01 18:50:09 +02:00
}
} else {
Util . deleteDirectory ( file ) ;
f - - ;
2017-05-30 21:38:51 +02:00
log . info . println ( " Removed ~/Recently Deleted/ " + file . getName ( ) ) ;
2017-04-01 18:50:09 +02:00
}
} else {
Util . deleteDirectory ( file ) ;
f - - ;
2017-05-30 21:38:51 +02:00
log . info . println ( " Removed ~/Recently Deleted/ " + file . getName ( ) ) ;
2017-04-01 18:50:09 +02:00
}
} else {
Files . delete ( file . toPath ( ) ) ;
f - - ;
2017-05-30 21:38:51 +02:00
log . info . println ( " Removed ~/Recently Deleted/ " + file . getName ( ) ) ;
2017-04-01 18:50:09 +02:00
}
} catch ( Exception e ) {
2017-04-03 19:52:28 +02:00
log . error . println ( e ) ;
2017-04-01 18:50:09 +02:00
}
}
if ( f < = 0 ) {
2018-09-09 00:06:21 +02:00
Files . delete ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Recently Deleted " ) . toPath ( ) ) ;
2017-04-01 18:50:09 +02:00
}
}
2017-01-30 21:22:36 +01:00
2019-01-17 19:12:32 +01:00
Util . reflect ( SubLogger . class . getDeclaredField ( " logn " ) , null , config . get ( ) . getSection ( " Settings " ) . getBoolean ( " Network-Log " , true ) ) ;
Util . reflect ( SubLogger . class . getDeclaredField ( " logc " ) , null , config . get ( ) . getSection ( " Settings " ) . getBoolean ( " Console-Log " , true ) ) ;
2018-09-09 00:06:21 +02:00
engine . getPluginManager ( ) . loadPlugins ( new UniversalFile ( engine . getRuntimeDirectory ( ) , " Plugins " ) ) ;
2017-01-30 21:22:36 +01:00
2018-03-21 21:45:59 +01:00
running = true ;
Cipher cipher = null ;
if ( ! config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " , " NONE " ) . equalsIgnoreCase ( " NONE " ) ) {
if ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Password " , " " ) . length ( ) = = 0 ) {
log . info . println ( " Cannot encrypt connection without a password " ) ;
} else if ( ! SubDataClient . getCiphers ( ) . keySet ( ) . contains ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) . toUpperCase ( ) . replace ( '-' , '_' ) . replace ( ' ' , '_' ) ) ) {
log . info . println ( " Unknown encryption type: " + config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) ) ;
} else {
cipher = SubDataClient . getCipher ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) ) ;
}
}
subdata = new SubDataClient ( this , config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Name " , " undefined " ) ,
InetAddress . getByName ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Address " , " 127.0.0.1:4391 " ) . split ( " : " ) [ 0 ] ) ,
Integer . parseInt ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Address " , " 127.0.0.1:4391 " ) . split ( " : " ) [ 1 ] ) , cipher ) ;
Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ( ) - > {
if ( running ) {
log . warn . println ( " Received request from system to shutdown " ) ;
2018-09-09 00:06:21 +02:00
engine . stop ( ) ;
2018-03-21 21:45:59 +01:00
}
2019-01-06 07:58:13 +01:00
} , SubAPI . getInstance ( ) . getAppInfo ( ) . getName ( ) + " ::System_Shutdown " ) ) ;
2018-03-21 21:45:59 +01:00
creator = new SubCreator ( this ) ;
2017-02-05 23:03:17 +01:00
loadDefaults ( ) ;
2017-08-18 11:58:06 +02:00
2018-03-27 06:31:38 +02:00
new Metrics ( this ) ;
2018-09-15 03:05:39 +02:00
info . setUpdateChecker ( ( ) - > {
2018-09-09 00:06:21 +02:00
try {
YAMLSection tags = new YAMLSection ( new JSONObject ( " { \" tags \" : " + Util . readAll ( new BufferedReader ( new InputStreamReader ( new URL ( " https://api.github.com/repos/ME1312/SubServers-2/git/refs/tags " ) . openStream ( ) , Charset . forName ( " UTF-8 " ) ) ) ) + '}' ) ) ;
List < Version > versions = new LinkedList < Version > ( ) ;
Version updversion = info . getVersion ( ) ;
int updcount = 0 ;
for ( YAMLSection tag : tags . getSectionList ( " tags " ) ) versions . add ( Version . fromString ( tag . getString ( " ref " ) . substring ( 10 ) ) ) ;
Collections . sort ( versions ) ;
for ( Version version : versions ) {
if ( version . compareTo ( updversion ) > 0 ) {
updversion = version ;
updcount + + ;
2017-08-18 11:58:06 +02:00
}
2018-09-09 00:06:21 +02:00
}
if ( updcount > 0 ) log . info . println ( " SubServers.Host v " + updversion + " is available. You are " + updcount + " version " + ( ( updcount = = 1 ) ? " " : " s " ) + " behind. " ) ;
} catch ( Exception e ) { }
} ) ;
2017-08-18 11:58:06 +02:00
2018-09-09 00:06:21 +02:00
engine . start ( this : : stop ) ;
2018-10-08 01:25:08 +02:00
if ( ! UPnP . isUPnPAvailable ( ) ) {
log . warn . println ( " UPnP is currently unavailable; Ports may not be automatically forwarded on this device " ) ;
}
2017-01-30 21:22:36 +01:00
} catch ( Exception e ) {
2017-02-08 01:39:18 +01:00
log . error . println ( e ) ;
2018-12-02 18:58:56 +01:00
engine . stop ( 1 ) ;
2017-01-30 21:22:36 +01:00
}
}
2017-12-14 01:04:58 +01:00
public void reload ( ) throws IOException {
if ( subdata ! = null )
subdata . destroy ( 0 ) ;
config . reload ( ) ;
2019-01-17 19:12:32 +01:00
try {
Util . reflect ( SubLogger . class . getDeclaredField ( " logn " ) , null , config . get ( ) . getSection ( " Settings " ) . getBoolean ( " Network-Log " , true ) ) ;
Util . reflect ( SubLogger . class . getDeclaredField ( " logc " ) , null , config . get ( ) . getSection ( " Settings " ) . getBoolean ( " Console-Log " , true ) ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
2018-01-05 21:37:23 +01:00
Cipher cipher = null ;
if ( ! config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " , " NONE " ) . equalsIgnoreCase ( " NONE " ) ) {
if ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Password " , " " ) . length ( ) = = 0 ) {
log . info . println ( " Cannot encrypt connection without a password " ) ;
2018-01-12 22:56:22 +01:00
} else if ( ! SubDataClient . getCiphers ( ) . keySet ( ) . contains ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) . toUpperCase ( ) . replace ( '-' , '_' ) . replace ( ' ' , '_' ) ) ) {
2018-01-05 21:37:23 +01:00
log . info . println ( " Unknown encryption type: " + config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) ) ;
} else {
cipher = SubDataClient . getCipher ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getRawString ( " Encryption " ) ) ;
}
2017-12-14 01:04:58 +01:00
}
subdata = new SubDataClient ( this , config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Name " , " undefined " ) ,
InetAddress . getByName ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Address " , " 127.0.0.1:4391 " ) . split ( " : " ) [ 0 ] ) ,
2018-01-05 21:37:23 +01:00
Integer . parseInt ( config . get ( ) . getSection ( " Settings " ) . getSection ( " SubData " ) . getString ( " Address " , " 127.0.0.1:4391 " ) . split ( " : " ) [ 1 ] ) , cipher ) ;
2017-12-14 01:04:58 +01:00
2018-12-18 00:49:32 +01:00
engine . getPluginManager ( ) . executeEvent ( new GalaxiReloadEvent ( engine ) ) ;
2018-06-26 02:51:14 +02:00
}
2017-01-30 21:22:36 +01:00
2017-02-05 23:03:17 +01:00
private void loadDefaults ( ) {
2017-04-01 22:31:57 +02:00
SubCommand . load ( this ) ;
2017-02-05 23:03:17 +01:00
}
2018-09-09 00:06:21 +02:00
private void stop ( ) {
if ( running ) {
2017-12-06 23:34:47 +01:00
log . info . println ( " Shutting down... " ) ;
List < String > subservers = new ArrayList < String > ( ) ;
subservers . addAll ( servers . keySet ( ) ) ;
for ( String server : subservers ) {
servers . get ( server ) . stop ( ) ;
try {
servers . get ( server ) . waitFor ( ) ;
} catch ( Exception e ) {
log . error . println ( e ) ;
}
2018-10-08 01:25:08 +02:00
if ( UPnP . isUPnPAvailable ( ) & & UPnP . isMappedTCP ( servers . get ( server ) . getPort ( ) ) ) UPnP . closePortTCP ( servers . get ( server ) . getPort ( ) ) ;
2017-12-06 23:34:47 +01:00
}
servers . clear ( ) ;
if ( creator ! = null ) {
creator . terminate ( ) ;
try {
creator . waitFor ( ) ;
} catch ( Exception e ) {
log . error . println ( e ) ;
}
}
running = false ;
2017-04-01 07:37:48 +02:00
try {
2017-12-06 23:34:47 +01:00
Thread . sleep ( 500 ) ;
2017-04-01 07:37:48 +02:00
} catch ( Exception e ) {
log . error . println ( e ) ;
}
2017-12-06 23:34:47 +01:00
if ( subdata ! = null ) Util . isException ( ( ) - > subdata . destroy ( 0 ) ) ;
2017-04-01 07:37:48 +02:00
2018-09-09 00:06:21 +02:00
if ( new File ( engine . getRuntimeDirectory ( ) , " Templates " ) . exists ( ) ) Util . deleteDirectory ( new File ( engine . getRuntimeDirectory ( ) , " Templates " ) ) ;
2017-04-01 07:37:48 +02:00
}
2017-01-30 21:22:36 +01:00
}
}