SteamWar/BauSystem2.0
Archiviert
12
0

Make BauSystem upgradeable form old BauSystem

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-06-26 11:09:40 +02:00
Ursprung fb9c1fd483
Commit 940006cee0

Datei anzeigen

@ -28,9 +28,11 @@ import de.steamwar.bausystem.region.loader.Updater;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; 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; public static final String PREFIX = ColorConfig.HIGHLIGHT + "BauSystem" + ColorConfig.OTHER + "» " + ColorConfig.BASE;
private World world;
@Override @Override
public void onEnable() { public void onEnable() {
world = Bukkit.getWorlds().get(0);
fixBauSystem();
// LOGGER // LOGGER
fixLogging(); fixLogging();
@ -84,7 +91,7 @@ public class BauSystem extends JavaPlugin implements Listener {
private StringBuilder current = new StringBuilder(); private StringBuilder current = new StringBuilder();
@Override @Override
public void write(int b) throws IOException { public void write(int b) {
if (b == '\n') { if (b == '\n') {
String logging = current.toString(); String logging = current.toString();
if (logging.contains("SLF4J")) { 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();
}
}
} }