diff --git a/resources/plugin.yml b/resources/plugin.yml index 36af626..5f3fafe 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html main: me.skymc.taboolib.Main -version: 3.83 +version: 3.832 commands: taboolib: diff --git a/src/main/java/me/skymc/taboolib/string/language2/value/Language2Json2.java b/src/main/java/me/skymc/taboolib/string/language2/value/Language2Json2.java index 436cc1d..40b1503 100644 --- a/src/main/java/me/skymc/taboolib/string/language2/value/Language2Json2.java +++ b/src/main/java/me/skymc/taboolib/string/language2/value/Language2Json2.java @@ -62,6 +62,7 @@ public class Language2Json2 implements Language2Line { formatOptions(list); // 遍历内容 int lineNumber = 0; + int lineNumberEnd = getLineNumberEnd(list); for (String line : list) { if (line.startsWith("@option")) { break; @@ -109,13 +110,23 @@ public class Language2Json2 implements Language2Line { if (!find) { json.append(line); } - if (lineNumber + 1 < list.size()) { + if (++lineNumber < lineNumberEnd) { json.newLine(); } } } } + private int getLineNumberEnd(List list) { + int line = list.size(); + for (int i = 0 ; i < list.size(); i++) { + if (list.get(i).startsWith("@option")) { + return i; + } + } + return line; + } + private void formatOptions(List list) { HashMap> _options = getOptions(list); for (Entry> entry : _options.entrySet()) { @@ -167,29 +178,21 @@ public class Language2Json2 implements Language2Line { private HashMap> getOptions(List list) { HashMap> options_source = new HashMap<>(); List option = new ArrayList<>(); - // 遍历 String optionName = null; boolean start = false; - // 遍历所有代码 for (String line : list) { if (line.startsWith(KEY_OPTION)) { - // 如果已经开始检测 if (start) { - // 返回源码 options_source.put(optionName, new ArrayList<>(option)); - // 清除源码 option.clear(); } - // 标签 start = true; - // 当前设置名称 optionName = line.substring(KEY_OPTION.length()); } else if (start) { option.add(line); } } - // 返回最后设置 options_source.put(optionName, option); return options_source; }