try fix
This commit is contained in:
parent
76ecfb39ab
commit
b0dc368ef7
6 changed files with 99 additions and 23 deletions
|
@ -107,6 +107,8 @@ public final class Server implements IThreadListener {
|
|||
private final Map<String, Position> warps = Maps.<String, Position>newTreeMap();
|
||||
private final CommandEnvironment scriptEnv = new CommandEnvironment(this);
|
||||
private final boolean debug;
|
||||
private final boolean ipcpipe;
|
||||
private final String token;
|
||||
|
||||
private WorldServer space;
|
||||
private ChannelFuture endpoint;
|
||||
|
@ -135,17 +137,24 @@ public final class Server implements IThreadListener {
|
|||
public static void main(String[] args) {
|
||||
Util.checkOs();
|
||||
Registry.setup("Server thread");
|
||||
final Server server = new Server(false);
|
||||
boolean debug = Boolean.parseBoolean(System.getProperty("server.debug", "false"));
|
||||
boolean ipc = debug || Boolean.parseBoolean(System.getProperty("server.pipe", "false"));;
|
||||
String token = System.getProperty("server.token", null);
|
||||
int port = Integer.parseInt(System.getProperty("server.port", "" + Config.PORT));
|
||||
int distance = Integer.parseInt(System.getProperty("server.distance", "" + 0));
|
||||
final Server server = new Server(debug, ipc, token);
|
||||
Registry.addShutdownHook(new Runnable() {
|
||||
public void run() {
|
||||
server.stopServer();
|
||||
}
|
||||
});
|
||||
server.run();
|
||||
server.run(port, distance);
|
||||
}
|
||||
|
||||
private Server(boolean debug) {
|
||||
private Server(boolean debug, boolean ipc, String token) {
|
||||
this.debug = debug;
|
||||
this.ipcpipe = ipc;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public CommandEnvironment getScriptEnvironment() {
|
||||
|
@ -245,12 +254,14 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public void run(int port, int distance) {
|
||||
long time = System.currentTimeMillis();
|
||||
Log.JNI.info("Starte Server Version " + Config.VERSION);
|
||||
if(!this.debug) {
|
||||
this.setMessage("Welt wird erstellt und geladen");
|
||||
FolderInfo info = Region.loadWorldInfo(null);
|
||||
if(distance > 0)
|
||||
Config.set("viewDistance", "" + distance, null);
|
||||
// if(dtime == -1L) // {
|
||||
// dtime = World.START_TIME;
|
||||
//// Config.set("spawnDim", "1", null);
|
||||
|
@ -289,6 +300,8 @@ public final class Server implements IThreadListener {
|
|||
Config.set("weatherChanges", "false", null);
|
||||
Config.set("mobSpawning", "false", null);
|
||||
Config.set("spawnRadius", "0", null);
|
||||
if(distance > 0)
|
||||
Config.set("viewDistance", "" + distance, null);
|
||||
this.worlds.add(this.space = new WorldServer(this, World.START_TIME,
|
||||
Space.INSTANCE, true));
|
||||
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
||||
|
@ -301,7 +314,8 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
WorldServer.loadWarps(dim, this.warps);
|
||||
}
|
||||
// this.openLAN();
|
||||
if(port >= 0)
|
||||
this.bind(port);
|
||||
}
|
||||
Log.JNI.info("Server gestartet in " + String.format("%.1f", (double)(System.currentTimeMillis() - time) / 1000.0) + " Sekunden");
|
||||
while(this.running) {
|
||||
|
@ -1105,21 +1119,21 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void bind(int port) {
|
||||
this.schedule(new Runnable() {
|
||||
public void run() {
|
||||
if(port >= 0) {
|
||||
try {
|
||||
Server.this.setLanEndpoint(port);
|
||||
}
|
||||
catch(IOException e) {
|
||||
Log.JNI.error(e, "**** KONNTE NICHT AN PORT " + port + " ANBINDEN!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Server.this.unsetLanEndpoint();
|
||||
}
|
||||
// this.schedule(new Runnable() {
|
||||
// public void run() {
|
||||
if(port >= 0) {
|
||||
try {
|
||||
Server.this.setLanEndpoint(port);
|
||||
}
|
||||
});
|
||||
catch(IOException e) {
|
||||
Log.JNI.error(e, "**** KONNTE NICHT AN PORT " + port + " ANBINDEN!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Server.this.unsetLanEndpoint();
|
||||
}
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue