版本更新至:3.832
修复:Language2 工具类 [json2] 类型的一些语法错误
This commit is contained in:
		@@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
main: me.skymc.taboolib.Main
 | 
					main: me.skymc.taboolib.Main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
version: 3.83
 | 
					version: 3.832
 | 
				
			||||||
 | 
					
 | 
				
			||||||
commands:
 | 
					commands:
 | 
				
			||||||
  taboolib:
 | 
					  taboolib:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,7 @@ public class Language2Json2 implements Language2Line {
 | 
				
			|||||||
		formatOptions(list);
 | 
							formatOptions(list);
 | 
				
			||||||
		// 遍历内容
 | 
							// 遍历内容
 | 
				
			||||||
		int lineNumber = 0;
 | 
							int lineNumber = 0;
 | 
				
			||||||
 | 
							int lineNumberEnd = getLineNumberEnd(list);
 | 
				
			||||||
		for (String line : list) {
 | 
							for (String line : list) {
 | 
				
			||||||
			if (line.startsWith("@option")) {
 | 
								if (line.startsWith("@option")) {
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
@@ -109,13 +110,23 @@ public class Language2Json2 implements Language2Line {
 | 
				
			|||||||
				if (!find) {
 | 
									if (!find) {
 | 
				
			||||||
					json.append(line);
 | 
										json.append(line);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (lineNumber + 1 < list.size()) {
 | 
									if (++lineNumber < lineNumberEnd) {
 | 
				
			||||||
					json.newLine();
 | 
										json.newLine();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						private int getLineNumberEnd(List<String> 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<String> list) {
 | 
						private void formatOptions(List<String> list) {
 | 
				
			||||||
		HashMap<String, List<String>> _options = getOptions(list);
 | 
							HashMap<String, List<String>> _options = getOptions(list);
 | 
				
			||||||
		for (Entry<String, List<String>> entry : _options.entrySet()) {
 | 
							for (Entry<String, List<String>> entry : _options.entrySet()) {
 | 
				
			||||||
@@ -167,29 +178,21 @@ public class Language2Json2 implements Language2Line {
 | 
				
			|||||||
	private HashMap<String, List<String>> getOptions(List<String> list) {
 | 
						private HashMap<String, List<String>> getOptions(List<String> list) {
 | 
				
			||||||
		HashMap<String, List<String>> options_source = new HashMap<>();
 | 
							HashMap<String, List<String>> options_source = new HashMap<>();
 | 
				
			||||||
		List<String> option = new ArrayList<>();
 | 
							List<String> option = new ArrayList<>();
 | 
				
			||||||
		// 遍历
 | 
					 | 
				
			||||||
		String optionName = null;
 | 
							String optionName = null;
 | 
				
			||||||
		boolean start = false;
 | 
							boolean start = false;
 | 
				
			||||||
		// 遍历所有代码
 | 
					 | 
				
			||||||
		for (String line : list) {
 | 
							for (String line : list) {
 | 
				
			||||||
			if (line.startsWith(KEY_OPTION)) {
 | 
								if (line.startsWith(KEY_OPTION)) {
 | 
				
			||||||
				// 如果已经开始检测
 | 
					 | 
				
			||||||
				if (start) {
 | 
									if (start) {
 | 
				
			||||||
					// 返回源码
 | 
					 | 
				
			||||||
					options_source.put(optionName, new ArrayList<>(option));
 | 
										options_source.put(optionName, new ArrayList<>(option));
 | 
				
			||||||
					// 清除源码
 | 
					 | 
				
			||||||
					option.clear();
 | 
										option.clear();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				// 标签
 | 
					 | 
				
			||||||
				start = true;
 | 
									start = true;
 | 
				
			||||||
				// 当前设置名称
 | 
					 | 
				
			||||||
				optionName = line.substring(KEY_OPTION.length());
 | 
									optionName = line.substring(KEY_OPTION.length());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if (start) {
 | 
								else if (start) {
 | 
				
			||||||
				option.add(line);
 | 
									option.add(line);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// 返回最后设置
 | 
					 | 
				
			||||||
		options_source.put(optionName, option);
 | 
							options_source.put(optionName, option);
 | 
				
			||||||
		return options_source;
 | 
							return options_source;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user