From 31862fe31d69d6c3bec2de6b173c8a38c37e95e8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 31 Dec 2019 12:39:40 +0100 Subject: [PATCH] Adding 1.15-Testbauserver support --- src/de/steamwar/bungeecore/BungeeCore.java | 4 +++ .../steamwar/bungeecore/SubserverSystem.java | 33 +++++++++++++++++++ .../bungeecore/commands/BauCommand.java | 3 ++ 3 files changed, 40 insertions(+) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 16d857ae..8005f190 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -39,6 +39,8 @@ public class BungeeCore extends Plugin { public static String WORLD_FOLDER; public static String BAUWELT_PROTOTYP; public static String LOBBY_SERVER; + public static String USERWORLDS15; + public static String BAUWELT15; private static BungeeCore instance; @@ -182,6 +184,8 @@ public class BungeeCore extends Plugin { WORLD_FOLDER = config.getString("worldfolder"); BAUWELT_PROTOTYP = config.getString("bauweltprototyp"); LOBBY_SERVER = config.getString("lobbyserver"); + USERWORLDS15 = config.getString("userworlds15"); + BAUWELT15 = config.getString("bauwelt15"); Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1])); PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers")); Persistent.setChatPrefix(CHAT_PREFIX); diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index c04a5ba4..e85c4ec4 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -92,6 +92,39 @@ public class SubserverSystem { MC_SCRIPT, "-b", owner.toString(), Integer.toString(port)).sendPlayer(p); } + public static void sendToBau15(ProxiedPlayer p, UUID owner){ + for(Subserver subserver : Subserver.getServerList()){ + if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)){ + subserver.sendPlayer(p); + return; + } + } + + SteamwarUser user = SteamwarUser.get(owner); + File w = new File(BungeeCore.USERWORLDS15 + user.getId()); + if (!w.exists() || !w.isDirectory()){ + try { + Process pr; + ProcessBuilder pb = new ProcessBuilder( + "cp", "-r", BungeeCore.BAUWELT15, BungeeCore.USERWORLDS15 + user.getId()); + pr = pb.start(); + pr.waitFor(); + } catch (IOException e) { + BungeeCore.log("Could not create Bauwelt", e); + BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDas Erstellen der Welt ist fehlgeschlagen."); + return; + } catch (InterruptedException e){ + BungeeCore.log("Could not create Bauwelt", e); + BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDas Erstellen der Welt ist fehlgeschlagen."); + Thread.currentThread().interrupt(); + } + } + int port = freePort(4000); + + new Bauserver(user.getUserName() + "s Bau", owner, port, + MC_SCRIPT, "-b", Integer.toString(user.getId()), Integer.toString(port)).sendPlayer(p); + } + private static int freePort(int start){ synchronized (Subserver.getServerList()){ int port = start; diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 85c4a2ab..ec4fa8ca 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -29,6 +29,9 @@ public class BauCommand { } switch(command[1].toLowerCase()){ + case "15": + SubserverSystem.sendToBau15(p, p.getUniqueId()); + break; case "addmember": addmember(p, command); break;