/
StandaloneApp.java
48 lines (40 loc) · 1.5 KB
/
StandaloneApp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package net.ME1312.Galaxi.Engine.Runtime;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
import net.ME1312.Galaxi.Galaxi;
import net.ME1312.Galaxi.Library.Try;
import net.ME1312.Galaxi.Log.Logger;
import java.io.File;
import java.text.DecimalFormat;
import java.util.Calendar;
/**
* Galaxi Standalone App
*/
public class StandaloneApp {
/**
* Galaxi Standalone Launch Method
*
* @param args Command Line Arguments
*/
public static void main(String[] args) {
start();
}
private static void start() {
try {
if (!Try.expect(IllegalStateException.class).run(GalaxiEngine::getInstance)) {
Engine engine = new Engine(null);
Logger log = engine.getAppInfo().getLogger();
long begin = Calendar.getInstance().getTime().getTime();
log.info.println("", "Searching for Plugins...");
int loaded = engine.getPluginManager().loadPlugins(new File(engine.getRuntimeDirectory(), "Plugins"));
log.info.println(loaded + " Plugin"+((loaded == 1)?"":"s") + " loaded in " + new DecimalFormat("0.000").format((Calendar.getInstance().getTime().getTime() - begin) / 1000D) + "s");
engine.start(StandaloneApp::stop);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void stop() {
Logger log = Galaxi.getInstance().getAppInfo().getLogger();
log.info.println("Shutting down...");
}
}