我有这个代码:
File folder = new File(getDataFolder() + "/messages");
String[] fileNames = folder.list();
for (int i = 0; i < fileNames.length; i++) {
configManager.loadConfigFile("messages/" + fileNames[i]);
String lang = fileNames[i].substring(8, fileNames[i].length() - 4);
YamlConfiguration messagesConfig = configManager.getConfig("messages/" + fileNames[i]);
messagesConfigs.put(lang, messagesConfig);
}
private static Map<String, Map<String, String>> messages = new HashMap<String, Map<String, String>>();
public void loadMessages(String lang) {
for (String mes : PluginBase.plugin.messagesConfigs.get(lang).getKeys(false)) {
messages.put(lang, new HashMap<String, String>().put(mes, PluginBase.plugin.messagesConfigs.get(lang).getString(mes)));
}
}
public static String getMessage(String lang, String id) {
return messages.get(lang).get(id);
}
我有语言、呼叫者和消息者(“我们”->“无操作”->“您没有权限!”)。当我打电话时,getMessage(String lang, String caller)
我想收到有关语言lang
和来电者的消息caller
。当前代码在行出现错误messages.put(lang, new HashMap<String, String>().put(mes, PluginBase.plugin.messagesConfigs.get(lang).getString(mes)));
非常感谢。