forked from GeyserMC/Geyser
Add Sponge platform bootstrap
This commit is contained in:
parent
1fbbb87689
commit
70fd9867f5
7 changed files with 396 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue