diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 16d857a..8005f19 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 c04a5ba..46d5b13 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, "-n", 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 85c4a2a..ec4fa8c 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;