From e2d83501d635d2e8e90a5ff6f47d3c03e82d0824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Fri, 30 Mar 2018 00:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E8=87=B3?= =?UTF-8?q?=EF=BC=9A3.832?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复:Language2 工具类 [json2] 类型的一些语法错误 --- resources/plugin.yml | 2 +- .../language2/value/Language2Json2.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) 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; }