diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 6e58f6c6..a74b428a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -28,9 +28,11 @@ import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.message.Message; import lombok.Getter; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; @@ -46,8 +48,13 @@ public class BauSystem extends JavaPlugin implements Listener { public static final String PREFIX = ColorConfig.HIGHLIGHT + "BauSystem" + ColorConfig.OTHER + "ยป " + ColorConfig.BASE; + private World world; + @Override public void onEnable() { + world = Bukkit.getWorlds().get(0); + fixBauSystem(); + // LOGGER fixLogging(); @@ -84,7 +91,7 @@ public class BauSystem extends JavaPlugin implements Listener { private StringBuilder current = new StringBuilder(); @Override - public void write(int b) throws IOException { + public void write(int b) { if (b == '\n') { String logging = current.toString(); if (logging.contains("SLF4J")) { @@ -99,4 +106,27 @@ public class BauSystem extends JavaPlugin implements Listener { } })); } + + private void fixBauSystem() { + if (!new File(world.getWorldFolder(),"prototypes.yapion").exists()) { + createLink("prototypes.yapion"); + } + if (!new File(world.getWorldFolder(),"regions.yapion").exists()) { + createLink("regions.yapion"); + } + } + + private void createLink(String name) { + try { + ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/backbone/server/Bau15/" + name, name); + processBuilder.directory(world.getWorldFolder()); + processBuilder.inheritIO(); + + Process process = processBuilder.start(); + process.waitFor(); + } catch (IOException | InterruptedException e) { + Thread.currentThread().interrupt(); + Bukkit.shutdown(); + } + } } \ No newline at end of file