mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-10 16:41:28 +01:00
fix: do not write to the locale file if nothing changed when updating it
Something in that mess of a code the charset gets lost or something and breaks special characters like `prefix: '&f'` So we just don't save the changes for now if nothing changed ^^ The system where locales are currently fetched for merging with the existing one is abandoned anyway, so I don't think there are any changes that would be merged
This commit is contained in:
parent
dcc71e7ba9
commit
2bcaee34aa
@ -15,10 +15,10 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -204,13 +204,13 @@ public class Locale {
|
||||
return updateFiles(plugin, in, destinationFile, builtin);
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = Files.newOutputStream(destinationFile.toPath())) {
|
||||
copy(in, outputStream);
|
||||
try {
|
||||
Files.copy(in, destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
|
||||
return fileName.split("_").length == 2;
|
||||
} catch (IOException ignore) {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -273,9 +273,6 @@ public class Locale {
|
||||
existingLang.save();
|
||||
}
|
||||
|
||||
existingLang.setRootNodeSpacing(0);
|
||||
existingLang.save();
|
||||
|
||||
return !added.isEmpty();
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error checking config " + existingFile.getName(), ex);
|
||||
@ -481,17 +478,4 @@ public class Locale {
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
private static void copy(InputStream input, OutputStream output) {
|
||||
int n;
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
|
||||
try {
|
||||
while ((n = input.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user