Add Sponge platform bootstrap

This commit is contained in:
RednedEpic 2019-12-21 16:18:34 -06:00
parent 1fbbb87689
commit 70fd9867f5
7 changed files with 396 additions and 9 deletions

View file

@ -2,19 +2,24 @@ package org.geysermc.connector.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.geysermc.connector.GeyserConnector;
import java.io.*;
import java.util.function.Function;
public class FileUtils {
public static <T> T loadConfig(File src, Class<T> valueType) throws IOException {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
return objectMapper.readValue(src, valueType);
}
public static File fileOrCopiedFromResource(String name, Function<String, String> s) throws IOException {
File file = new File(name);
return fileOrCopiedFromResource(new File(name), name, s);
}
public static File fileOrCopiedFromResource(File file, String name, Function<String, String> s) throws IOException {
if (!file.exists()) {
FileOutputStream fos = new FileOutputStream(file);
InputStream input = GeyserConnector.class.getResourceAsStream("/" + name); // resources need leading "/" prefix
@ -34,6 +39,4 @@ public class FileUtils {
return file;
}
}