diff options
author | SHsuperCM <shsupercm@gmail.com> | 2022-03-04 17:52:54 +0200 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2022-03-04 17:52:54 +0200 |
commit | 90bb38ef08f0173ddfa9abb8b4ca2542f10af04a (patch) | |
tree | 980c53f09c73d12b24de40a377bde2d5e1ed372a | |
parent | de66a476d01d606c3815efebc904a5c6d9bce133 (diff) | |
download | CITResewn-90bb38ef08f0173ddfa9abb8b4ca2542f10af04a.tar.gz CITResewn-90bb38ef08f0173ddfa9abb8b4ca2542f10af04a.tar.bz2 CITResewn-90bb38ef08f0173ddfa9abb8b4ca2542f10af04a.zip |
Rewrote escaped unicode parsing in properties
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertiesGroupAdapter.java | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertiesGroupAdapter.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertiesGroupAdapter.java index c0b3da6..7a8d2d4 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertiesGroupAdapter.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertiesGroupAdapter.java @@ -1,11 +1,9 @@ package shcm.shsupercm.fabric.citresewn.pack.format; import net.minecraft.util.Identifier; -import net.minecraft.util.InvalidIdentifierException; import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.Properties; public class PropertiesGroupAdapter extends PropertyGroup { public static final String EXTENSION = ".properties"; @@ -44,6 +42,8 @@ public class PropertiesGroupAdapter extends PropertyGroup { line = line.substring(0, line.length() - 1) + "\\n" + nextLine; } + line = line.stripTrailing(); + StringBuilder builder = new StringBuilder(); String key = null, keyMetadata = null; @@ -59,18 +59,12 @@ public class PropertiesGroupAdapter extends PropertyGroup { case 'f' -> '\f'; case 't' -> '\t'; case 'u' -> { - if (i + 4 >= line.length()) - yield c; - - //todo implement manually - java.util.Properties properties = new Properties(); - properties.load(new StringReader("k=\\u" + line.charAt(i + 1) + line.charAt(i + 2) + line.charAt(i + 3) + line.charAt(i + 4))); - String k = properties.getProperty("k"); - if (k.length() == 1) { + try { i += 4; - yield k.charAt(0); + yield (char) Integer.parseInt(line.substring(i - 3, i + 1), 16); + } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { + throw new IOException("Malformatted escaped unicode character"); } - yield c; } default -> c; |