Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-09-06 05:00:09 +02:00
Only load mappings file from dir if manually copied
Dieser Commit ist enthalten in:
Ursprung
4bdb566fb5
Commit
3384b6bc17
@ -5,33 +5,25 @@ import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
|
||||
public class MappingDataLoader {
|
||||
|
||||
public static JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
try (InputStream in = getResource(name)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (IOException e) {
|
||||
Via.getPlatform().getLogger().warning("Error loading " + name + " from the config directory!");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!file.exists()) return loadData(name);
|
||||
|
||||
// Load the file from the platform's directory if present
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (JsonSyntaxException | JsonIOException e) {
|
||||
} catch (JsonSyntaxException e) {
|
||||
// Users might mess up the format, so let's catch the syntax error
|
||||
Via.getPlatform().getLogger().warning(name + " is badly formatted!");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException | JsonIOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JsonObject loadData(String name) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren