From fe4542c67bb01c1c33d6ccfcf7df0a5fb54c7ebd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Jul 2021 17:10:24 +0200 Subject: [PATCH] Fix BauSystem for old BauWorld Signed-off-by: yoyosource --- .../src/de/steamwar/bausystem/BauSystem.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 437db7f6..83c5e004 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -108,18 +108,32 @@ public class BauSystem extends JavaPlugin implements Listener { } private void fixBauSystem() { + int number = -1; + try { + String string = new File(world.getWorldFolder(), "sections.yapion").getCanonicalPath(); + if (string.endsWith("/sections3.yml")) number = 3; + if (string.endsWith("/sections4.yml")) number = 4; + } catch (IOException e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + Bukkit.shutdown(); + return; + } + if (number == -1) { + Bukkit.shutdown(); + return; + } if (!new File(world.getWorldFolder(),"prototypes.yapion").exists()) { - createLink("prototypes.yapion"); + createLink("prototypes" + number + ".yapion", "prototypes.yapion"); } if (!new File(world.getWorldFolder(),"regions.yapion").exists()) { - createLink("regions.yapion"); + createLink("regions" + number + ".yapion", "regions.yapion"); } } - private void createLink(String name) { + private void createLink(String source, String destination) { try { - Bukkit.getLogger().log(Level.INFO, "Executing: ln -s /home/minecraft/backbone/server/Bau15/{0} .", new String[]{name}); - ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/backbone/server/Bau15/" + name, "."); + Bukkit.getLogger().log(Level.INFO, "Executing: ln -s /home/minecraft/backbone/server/Bau15/{0} {1}", new String[]{source, destination}); + ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/backbone/server/Bau15/" + source, destination); processBuilder.directory(world.getWorldFolder()); processBuilder.inheritIO();