remove server ipc and preloading
This commit is contained in:
parent
660199b1d8
commit
e4034898b9
3 changed files with 11 additions and 92 deletions
|
@ -119,7 +119,6 @@ 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 WorldServer space;
|
||||
private ChannelFuture endpoint;
|
||||
|
@ -153,9 +152,8 @@ public final class Server implements IThreadListener {
|
|||
RotationRegistry.register();
|
||||
ReorderRegistry.register();
|
||||
boolean debug = System.getProperty("server.debug", null) != null;
|
||||
boolean ipc = System.getProperty("server.pipe", null) != null;
|
||||
int port = Integer.parseInt(System.getProperty("server.port", "" + Config.PORT));
|
||||
final Server server = new Server(debug, ipc);
|
||||
final Server server = new Server(debug);
|
||||
Registry.addShutdownHook(new Runnable() {
|
||||
public void run() {
|
||||
server.stopServer();
|
||||
|
@ -223,9 +221,8 @@ public final class Server implements IThreadListener {
|
|||
return World.START_TIME;
|
||||
}
|
||||
|
||||
private Server(boolean debug, boolean ipc) {
|
||||
private Server(boolean debug) {
|
||||
this.debug = debug;
|
||||
this.ipcpipe = ipc;
|
||||
Config.setCallback(new Runnable() {
|
||||
public void run() {
|
||||
for(WorldServer world : Server.this.getWorlds()) {
|
||||
|
@ -300,27 +297,14 @@ public final class Server implements IThreadListener {
|
|||
private void saveAllWorlds(boolean message) {
|
||||
if(this.debug)
|
||||
return;
|
||||
if(message) {
|
||||
this.startProgress(true, this.worlds.size());
|
||||
}
|
||||
int done = 0;
|
||||
if(message)
|
||||
Log.JNI.info("Speichere Welt");
|
||||
this.saveWorldInfo();
|
||||
for(WorldServer world : this.worlds) {
|
||||
if(message) {
|
||||
this.setProgress(done);
|
||||
}
|
||||
++done;
|
||||
world.saveAllChunks();
|
||||
}
|
||||
this.setProgress(-1);
|
||||
}
|
||||
|
||||
private void startProgress(boolean save, int amount) {
|
||||
this.setTotal(amount);
|
||||
this.setProgress(0);
|
||||
Log.JNI.info((save ? "Speichere" : "Generiere und lade") + " Welt");
|
||||
}
|
||||
|
||||
public void unloadWorld(WorldServer world) {
|
||||
if(world != this.space)
|
||||
this.unloadWorld(world.dimension);
|
||||
|
@ -425,7 +409,6 @@ public final class Server implements IThreadListener {
|
|||
Log.JNI.info("Starte " + Config.NAME + " Server Version " + Config.VERSION);
|
||||
if(!this.debug) {
|
||||
Converter.convert();
|
||||
this.setMessage("Welt wird erstellt und geladen");
|
||||
long wtime = loadServerConfig();
|
||||
// if(dtime == -1L) // {
|
||||
// dtime = World.START_TIME;
|
||||
|
@ -535,38 +518,26 @@ public final class Server implements IThreadListener {
|
|||
this.lastPoll = this.currentTime;
|
||||
this.ticksDone = 0L;
|
||||
}
|
||||
if(!this.started) {
|
||||
this.started = true;
|
||||
this.sendPipeIPC("running", true);
|
||||
}
|
||||
this.started = true;
|
||||
}
|
||||
try {
|
||||
this.stopServer();
|
||||
this.stopped = true;
|
||||
this.sendPipeIPC("running", false);
|
||||
}
|
||||
catch(Throwable e) {
|
||||
Log.JNI.error(e, "Fehler beim Beenden des Servers");
|
||||
}
|
||||
finally {
|
||||
this.stopped = true;
|
||||
this.sendPipeIPC("running", false);
|
||||
Log.JNI.info("Server wurde beendet");
|
||||
}
|
||||
}
|
||||
|
||||
public void preload(WorldServer world, int bx, int bz, Player callback) {
|
||||
public void preload(WorldServer world, int bx, int bz) {
|
||||
int done = 0;
|
||||
int total = Config.distance * 2 + 1;
|
||||
total *= total;
|
||||
if(callback != null) {
|
||||
callback.displayLoading("Lade Welt ...");
|
||||
callback.sendTask("Landschaft wird generiert", total);
|
||||
}
|
||||
else {
|
||||
this.setMessage("Landschaft wird generiert");
|
||||
this.startProgress(false, total);
|
||||
}
|
||||
Log.JNI.info("Generiere und lade Welt");
|
||||
// WorldServer world = this.getWorld(Config.spawnDim);
|
||||
// world = world == null ? this.space : world;
|
||||
bx = bx >> 4;
|
||||
|
@ -575,26 +546,14 @@ public final class Server implements IThreadListener {
|
|||
for(int x = -Config.distance; x <= Config.distance; x++) {
|
||||
for(int z = -Config.distance; z <= Config.distance; z++) {
|
||||
long time = System.currentTimeMillis();
|
||||
if(time - last >= 10L) {
|
||||
if(callback != null) {
|
||||
callback.sendProgress(done);
|
||||
}
|
||||
else {
|
||||
this.setProgress(done);
|
||||
if(time - last > 1000L) {
|
||||
Log.JNI.info("Bereite Spawnbereich vor" + ": " + (done * 100 / total) + "%");
|
||||
last = time;
|
||||
}
|
||||
}
|
||||
if(time - last > 1000L) {
|
||||
Log.JNI.info("Bereite Spawnbereich vor" + ": " + (done * 100 / total) + "%");
|
||||
last = time;
|
||||
}
|
||||
++done;
|
||||
world.loadChunk(bx + x, bz + z);
|
||||
}
|
||||
}
|
||||
if(callback != null)
|
||||
callback.sendProgress(-1);
|
||||
else
|
||||
this.setProgress(-1);
|
||||
}
|
||||
|
||||
// public void resetProgress() {
|
||||
|
@ -680,7 +639,6 @@ public final class Server implements IThreadListener {
|
|||
if(this.perfTimer == 100) {
|
||||
this.perfTimer = 0;
|
||||
}
|
||||
this.sendPipeIPC("tick", this.getLastTick());
|
||||
}
|
||||
|
||||
public WorldServer getSpace() {
|
||||
|
@ -759,26 +717,6 @@ public final class Server implements IThreadListener {
|
|||
public Player getPlayer(String user) {
|
||||
return this.usermap.get(user);
|
||||
}
|
||||
|
||||
private void setMessage(String message) {
|
||||
this.sendPipeIPC("message", message);
|
||||
}
|
||||
|
||||
private void setProgress(int progress) {
|
||||
this.sendPipeIPC("progress", progress);
|
||||
}
|
||||
|
||||
private void setTotal(int total) {
|
||||
this.sendPipeIPC("total", total);
|
||||
}
|
||||
|
||||
public void setVar(String cv, String value) {
|
||||
this.schedule(new Runnable() {
|
||||
public void run() {
|
||||
Config.set(cv, value, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private <V> ListenableFuture<V> callFromMainThread(Callable<V> callable) {
|
||||
if(!this.isMainThread() && !this.stopped) {
|
||||
|
@ -893,9 +831,6 @@ public final class Server implements IThreadListener {
|
|||
+ player.getId() + " auf Level " + world.dimension.getDimensionId() + ": "
|
||||
+ String.format("%.2f %.2f %.2f", player.posX, player.posY, player.posZ) + " verbunden (" + (tag == null ? "Charakter-Editor" : "'" + player.getCommandName() + "'") + ")");
|
||||
|
||||
if(Config.preload && /* conn.isLocal() && */ this.players.size() == 1)
|
||||
this.preload(world, (int)player.posX, (int)player.posZ, conn);
|
||||
|
||||
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, EntityRegistry.getEntityID(player), tag == null));
|
||||
conn.sendPacket(new SPacketHeldItemChange(player.inventory.currentItem));
|
||||
conn.sendPacket(new SPacketWorld(WorldServer.clampGravity(),
|
||||
|
@ -1276,8 +1211,6 @@ public final class Server implements IThreadListener {
|
|||
|
||||
private void stopServer() {
|
||||
if(!this.stopped) {
|
||||
this.setProgress(-1);
|
||||
this.setMessage("Stoppe server");
|
||||
Log.JNI.info("Beende Server");
|
||||
this.terminateEndpoint(this.endMessage);
|
||||
if(this.started) {
|
||||
|
@ -1338,17 +1271,7 @@ public final class Server implements IThreadListener {
|
|||
"Geladen: " + this.getWorlds().size() + " Welten, " + WorldServer.getLoadedInfo(this);
|
||||
}
|
||||
|
||||
private void sendPipeIPC(String key, Object value) {
|
||||
if(this.ipcpipe) {
|
||||
System.out.println("#" + key + (value == null ? "" : " " + String.valueOf(value)));
|
||||
System.out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void logConsole(String message) {
|
||||
if(this.ipcpipe)
|
||||
this.sendPipeIPC("console", message);
|
||||
else
|
||||
Log.CONSOLE.info(message);
|
||||
Log.CONSOLE.info(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2463,8 +2463,6 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
|
|||
world.dimension.getDimensionId());
|
||||
this.entity.setOrigin(origin);
|
||||
Position pos = this.server.getRandomSpawnPosition(origin);
|
||||
if(Config.preload && /* this.local && */ this.server.getPlayers().size() == 1)
|
||||
this.server.preload(world, (int)pos.x, (int)pos.z, this);
|
||||
this.entity.teleport(pos);
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getFormattedName(false), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel)));
|
||||
// if(this.local)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue