From 4ad3dfff030c60253e63449a88448f42ee034f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=81=AA=E8=81=AA?= <178666380@qq.com> Date: Sun, 25 Jun 2017 19:16:18 +0800 Subject: [PATCH] config file forge utf-8 --- .../file/FileConfiguration.java.patch | 65 +++++++++++++++++++ .../file/YamlConfiguration.java.patch | 11 ++++ 2 files changed, 76 insertions(+) create mode 100644 patches/org/bukkit/configuration/file/FileConfiguration.java.patch create mode 100644 patches/org/bukkit/configuration/file/YamlConfiguration.java.patch diff --git a/patches/org/bukkit/configuration/file/FileConfiguration.java.patch b/patches/org/bukkit/configuration/file/FileConfiguration.java.patch new file mode 100644 index 0000000..22eb95c --- /dev/null +++ b/patches/org/bukkit/configuration/file/FileConfiguration.java.patch @@ -0,0 +1,65 @@ +--- ../src-base/minecraft/org/bukkit/configuration/file/FileConfiguration.java ++++ ../src-work/minecraft/org/bukkit/configuration/file/FileConfiguration.java +@@ -36,7 +36,7 @@ + * @deprecated temporary compatibility measure + */ + @Deprecated +- public static final boolean UTF8_OVERRIDE; ++ public static final boolean UTF8_OVERRIDE=true; + /** + * This value specifies if the system default encoding is unicode, but + * cannot parse standard ASCII. +@@ -44,24 +44,14 @@ + * @deprecated temporary compatibility measure + */ + @Deprecated +- public static final boolean UTF_BIG; ++ public static final boolean UTF_BIG=false; + /** + * This value specifies if the system supports unicode. + * + * @deprecated temporary compatibility measure + */ + @Deprecated +- public static final boolean SYSTEM_UTF; +- static { +- final byte[] testBytes = Base64Coder.decode("ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ent8fX4NCg=="); +- final String testString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\r\n"; +- final Charset defaultCharset = Charset.defaultCharset(); +- final String resultString = new String(testBytes, defaultCharset); +- final boolean trueUTF = defaultCharset.name().contains("UTF"); +- UTF8_OVERRIDE = !testString.equals(resultString) || defaultCharset.equals(Charset.forName("US-ASCII")); +- SYSTEM_UTF = trueUTF || UTF8_OVERRIDE; +- UTF_BIG = trueUTF && UTF8_OVERRIDE; +- } ++ public static final boolean SYSTEM_UTF=true; + + /** + * Creates an empty {@link FileConfiguration} with no default values. +@@ -102,7 +92,7 @@ + + String data = saveToString(); + +- Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset()); ++ Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); + + try { + writer.write(data); +@@ -166,7 +156,7 @@ + + final FileInputStream stream = new FileInputStream(file); + +- load(new InputStreamReader(stream, UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset())); ++ load(new InputStreamReader(stream, Charsets.UTF_8)); + } + + /** +@@ -191,7 +181,7 @@ + public void load(InputStream stream) throws IOException, InvalidConfigurationException { + Validate.notNull(stream, "Stream cannot be null"); + +- load(new InputStreamReader(stream, UTF8_OVERRIDE ? Charsets.UTF_8 : Charset.defaultCharset())); ++ load(new InputStreamReader(stream, Charsets.UTF_8)); + } + + /** diff --git a/patches/org/bukkit/configuration/file/YamlConfiguration.java.patch b/patches/org/bukkit/configuration/file/YamlConfiguration.java.patch new file mode 100644 index 0000000..d99f43a --- /dev/null +++ b/patches/org/bukkit/configuration/file/YamlConfiguration.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/org/bukkit/configuration/file/YamlConfiguration.java ++++ ../src-work/minecraft/org/bukkit/configuration/file/YamlConfiguration.java +@@ -33,7 +33,7 @@ + public String saveToString() { + yamlOptions.setIndent(options().indent()); + yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); +- yamlOptions.setAllowUnicode(SYSTEM_UTF); ++ yamlOptions.setAllowUnicode(true); + yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + + String header = buildHeader();