From 63591fcb6fbad11812edbd5cf1183f7d77d85d66 Mon Sep 17 00:00:00 2001 From: Sen Date: Sun, 4 May 2025 01:02:39 +0200 Subject: [PATCH] pre remove ipc --- java/src/game/Game.java | 47 ------------------------ java/src/game/ServerProcess.java | 11 ++---- java/src/game/gui/GuiLoading.java | 43 ---------------------- java/src/game/gui/character/GuiChar.java | 3 +- 4 files changed, 6 insertions(+), 98 deletions(-) diff --git a/java/src/game/Game.java b/java/src/game/Game.java index 986f8f2..efd3175 100755 --- a/java/src/game/Game.java +++ b/java/src/game/Game.java @@ -2353,57 +2353,10 @@ public class Game implements IThreadListener { if(this.getNetHandler() != null) this.getNetHandler().getNetworkManager().closeChannel("Quitting"); this.unloadWorld(); -// if(server != null) -// server.shutdown(); } this.displayGuiScreen(GuiMenu.INSTANCE); } -// public void startServer(File dir) { -// if(this.server != null) -// return; -// server = new ServerProcess(this, dir, 1024, 4096, this.port); -// server.start(); -// this.displayGuiScreen(GuiLoading.makeStartTask(server)); -//// while(server != null && !server.isStarted()) { -//// try { -//// Thread.sleep(10L); -//// } -//// catch(InterruptedException e) { -//// } -//// } -//// if(server != null) { -//// } -// } -// -// public void stopServer(boolean display) { -// if(server != null) { -// server.shutdown(); -// if(display) { -// this.displayGuiScreen(GuiLoading.makeStopTask(server)); -// } -// else { -// while(!server.isStopped()) { -// try { -// Thread.sleep(10L); -// } -// catch(InterruptedException e) { -// } -// } -// } -// server = null; -// } -// } -// -// public boolean isServerRunning() { -// return this.server != null; -// } - - public void waitForServer() { -// if(this.server != null) - this.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ...")); - } - private void startSound(boolean load) { if(load) SoundEvent.loadSounds(); diff --git a/java/src/game/ServerProcess.java b/java/src/game/ServerProcess.java index 445f74e..a418d29 100644 --- a/java/src/game/ServerProcess.java +++ b/java/src/game/ServerProcess.java @@ -10,13 +10,14 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.util.function.Consumer; import game.log.Log; import game.util.Tuple; import game.util.Util; public class ServerProcess { - private final Game monitor; + private final Consumer monitor; private final ProcessBuilder builder; private Process process; @@ -27,7 +28,7 @@ public class ServerProcess { private int progress = -1; private int lastTick; - public ServerProcess(Game monitor, File dir, int minMem, int maxMem, int port) { + public ServerProcess(Consumer monitor, File dir, int minMem, int maxMem, int port) { this.monitor = monitor; File jar = new File("game.jar"); String path; @@ -90,11 +91,7 @@ public class ServerProcess { else if(data.first.equals("tick")) ServerProcess.this.lastTick = Integer.parseInt(data.second); else if(data.first.equals("console")) - ServerProcess.this.monitor.schedule(new Runnable() { - public void run() { - ServerProcess.this.monitor.logConsole(data.second); - } - }); + ServerProcess.this.monitor.accept(data.second); Log.SYSTEM.trace("server cmd %s -- %s", data.first, data.second); continue; } diff --git a/java/src/game/gui/GuiLoading.java b/java/src/game/gui/GuiLoading.java index 352b91f..60120f9 100644 --- a/java/src/game/gui/GuiLoading.java +++ b/java/src/game/gui/GuiLoading.java @@ -1,7 +1,6 @@ package game.gui; import game.Game; -import game.ServerProcess; import game.gui.element.Bar; import game.gui.element.Label; @@ -18,48 +17,6 @@ public class GuiLoading extends Gui { private Bar progressBar1; private Bar progressBar2; - public static GuiLoading makeStartTask(final ServerProcess server) { - return new GuiLoading("Starte Server ...", new Callback() { - boolean started = false; - - public void poll(Game gm, GuiLoading gui) { - if(!this.started && server.isStarted()) { - this.started = true; - gm.displayGuiScreen(GuiMenu.INSTANCE); - } - int progress = server.getProgress(); - if(progress < 0) { - gui.resetBar(); - } - else { - gui.setBar(null, "Chunks", Math.max(1, server.getTotal())); - gui.setProgress(progress); - } - gui.setTask(server.getMessage()); - } - }); - } - - public static GuiLoading makeStopTask(final ServerProcess server) { - return new GuiLoading("Beende Server ...", new Callback() { - public void poll(Game gm, GuiLoading gui) { - if(server.isStopped()) { - gm.displayGuiScreen(GuiMenu.INSTANCE); - return; - } - int progress = server.getProgress(); - if(progress < 0) { - gui.resetBar(); - } - else { - gui.setBar(null, "Dimensionen", Math.max(1, server.getTotal())); - gui.setProgress(progress); - } - gui.setTask(server.getMessage()); - } - }); - } - public static GuiLoading makeServerTask(String message) { return new GuiLoading(message, new Callback() { public void poll(Game gm, GuiLoading gui) { diff --git a/java/src/game/gui/character/GuiChar.java b/java/src/game/gui/character/GuiChar.java index af9d078..b2d9b5a 100755 --- a/java/src/game/gui/character/GuiChar.java +++ b/java/src/game/gui/character/GuiChar.java @@ -24,6 +24,7 @@ import game.entity.npc.EntityHuman; import game.entity.npc.EntityNPC; import game.entity.npc.SpeciesInfo; import game.entity.types.EntityLiving; +import game.gui.GuiLoading; import game.gui.element.ActButton; import game.gui.element.ActButton.Mode; import game.gui.element.Element; @@ -366,7 +367,7 @@ public class GuiChar extends GuiList this.add(new ActButton(width - 198, height - 28, 194, 24, new ActButton.Callback() { public void use(ActButton elem, Mode action) { if(GuiChar.this.gm.thePlayer != null) { - GuiChar.this.gm.waitForServer(); + GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ...")); Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension); GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText())); GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));