format code

Signed-off-by: Sola <dev@sola.love>
This commit is contained in:
Sola
2017-12-15 08:57:51 +08:00
parent 529b36d9e3
commit 0bdcf031b5
69 changed files with 1988 additions and 1988 deletions

View File

@@ -29,31 +29,31 @@ import java.util.regex.Pattern;
*/
public class Cortana {
public static List<Compiled> entries;
public static List<Compiled> entries;
public static void load() {
InputStream in = Lang.class.getClassLoader().getResourceAsStream("cortana.yml");
RawConfig root = new Yaml().loadAs(in, RawConfig.class);
}
public static void load() {
InputStream in = Lang.class.getClassLoader().getResourceAsStream("cortana.yml");
RawConfig root = new Yaml().loadAs(in, RawConfig.class);
}
static class Compiled {
Pattern[] patterns;
String[] replies;
}
static class Compiled {
Pattern[] patterns;
String[] replies;
}
public static class Rule {
String[] regexp;
String[] replies;
public static class Rule {
String[] regexp;
String[] replies;
public Rule() {
}
}
public Rule() {
}
}
public static class RawConfig {
Map<String, Rule> rules;
public static class RawConfig {
Map<String, Rule> rules;
public RawConfig() {
}
}
public RawConfig() {
}
}
}

View File

@@ -29,29 +29,29 @@ import java.util.Map;
*/
public class Lang {
public static Map<String, String> messages;
public static Map<String, MessageFormat> format_cache = new HashMap<>(32);
public static Map<String, String> messages;
public static Map<String, MessageFormat> format_cache = new HashMap<>(32);
static {
InputStream in = Lang.class.getClassLoader().getResourceAsStream("lang.yml");
//noinspection unchecked
messages = new Yaml().loadAs(in, Map.class);
}
static {
InputStream in = Lang.class.getClassLoader().getResourceAsStream("lang.yml");
//noinspection unchecked
messages = new Yaml().loadAs(in, Map.class);
}
public static String lang(String key) {
String value = messages.get(key);
return value == null ? "!!" + key + "!!" : value;
}
public static String lang(String key) {
String value = messages.get(key);
return value == null ? "!!" + key + "!!" : value;
}
public static String format(String key, Object... args) {
MessageFormat cache = format_cache.get(key);
if (cache != null) {
return cache.format(args);
} else {
cache = new MessageFormat(lang(key));
format_cache.put(key, cache);
return cache.format(args);
}
}
public static String format(String key, Object... args) {
MessageFormat cache = format_cache.get(key);
if (cache != null) {
return cache.format(args);
} else {
cache = new MessageFormat(lang(key));
format_cache.put(key, cache);
return cache.format(args);
}
}
}

View File

@@ -31,7 +31,7 @@ public class Settings {
static {
I = TableConfig.getSettings();
}
public String Wechat_AppId;
public String Wechat_Secret;
public String Wechat_Token;