From 151292acf283bfacc48e9d5a1d4f0d3748a0c99d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jun 2019 21:22:39 +0200 Subject: [PATCH] More error output --- .../warking/bungeecore/arenasystem/Arena.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/de/warking/bungeecore/arenasystem/Arena.java b/src/de/warking/bungeecore/arenasystem/Arena.java index bce49b01..fa944a5d 100644 --- a/src/de/warking/bungeecore/arenasystem/Arena.java +++ b/src/de/warking/bungeecore/arenasystem/Arena.java @@ -23,20 +23,22 @@ public class Arena implements Runnable{ private Process p; private PrintWriter writer; public ServerInfo server; + private String map; private boolean started = false; private final List cachedPlayers = new ArrayList<>(); private final List players = new ArrayList<>(); - public Arena(ArenaMode modus, int id){ + public Arena(ArenaMode modus, int id, String map){ spielModus = modus; arenenNummer = id; serverName = modus.name() + id; + this.map = map; int port = 2500 + arenenNummer; ProcessBuilder pb = new ProcessBuilder( "/home/minecraft/mc", - "-a", modus.name(), serverName, Integer.toString(port)); + "-a", modus.name(), serverName, Integer.toString(port), "Arena"); try{ p = pb.start(); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this); @@ -78,7 +80,7 @@ public class Arena implements Runnable{ } } - protected void stop(){ + void stop(){ if(p != null && p.isAlive()){ for(ProxiedPlayer player : server.getPlayers()){ player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer)); @@ -95,6 +97,17 @@ public class Arena implements Runnable{ ArenaSystem.arenen.remove(this); } + private void fatalError(){ + for(ProxiedPlayer cached : cachedPlayers){ + cached.sendMessage(BungeeCore.ChatPrefix + "§7Unerwarteter Fehler beim Arenenstart"); + } + for(ProxiedPlayer player : server.getPlayers()){ + player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer)); + player.sendMessage(BungeeCore.ChatPrefix + "§7Unerwarteter Fehler in der Arena"); + } + stop(); + } + public boolean inArena(ProxiedPlayer p){ for(ProxiedPlayer ap : cachedPlayers) if(ap.equals(p)) @@ -113,11 +126,11 @@ public class Arena implements Runnable{ while (!started && (line = reader.readLine()) != null) { started = line.contains(" INFO]: Done ("); //Problematisch - //started = line.contains("INFO]: [AAC] AAC has been enabled."); } if(line == null){ - System.out.println("Fatal error starting arena!"); + BungeeCore.log("Arena "+serverName+" stopped to early!"); + fatalError(); return; } @@ -135,8 +148,10 @@ public class Arena implements Runnable{ p.waitFor(); }catch(IOException e){ e.printStackTrace(); + fatalError(); }catch(InterruptedException e){ BungeeCore.log("Arena "+serverName+" was interrupted!"); + fatalError(); } stop(); }