mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +00:00
Fix utf-8 decoding problems.
This commit is contained in:
parent
29a190f93a
commit
8a22258945
1 changed files with 9 additions and 7 deletions
|
@ -126,23 +126,25 @@ public class EssentialsConf extends YamlConfiguration
|
||||||
{
|
{
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
data.clear();
|
data.clear();
|
||||||
LOGGER.log(Level.INFO, "File {0} is not utf-8 encoded, trying {1}", new Object[]
|
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + "is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
|
||||||
{
|
|
||||||
configFile.getAbsolutePath().toString(), Charset.defaultCharset().displayName()
|
|
||||||
});
|
|
||||||
decoder = Charset.defaultCharset().newDecoder();
|
decoder = Charset.defaultCharset().newDecoder();
|
||||||
result = decoder.decode(buffer, data, true);
|
result = decoder.decode(buffer, data, true);
|
||||||
if (result.isError())
|
if (result.isError())
|
||||||
{
|
{
|
||||||
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
|
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
decoder.flush(data);
|
decoder.flush(data);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
decoder.flush(data);
|
decoder.flush(data);
|
||||||
}
|
}
|
||||||
|
final int end = data.position();
|
||||||
data.rewind();
|
data.rewind();
|
||||||
super.loadFromString(data.toString());
|
super.loadFromString(data.subSequence(0, end).toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue