/** ファイルから設定を読み直す */ public void reload() { dictionary = new HashMap<String, String>(); // Fileを取得 File folder = new File(parent.getProxy().getPluginsFolder(), "BungeeJapanizeMessenger"); if (!folder.exists()) { return; } File file = new File(folder, "dictionary.yml"); if (!file.exists()) { return; } ConfigurationProvider provider = ConfigurationProvider.getProvider(YamlConfiguration.class); try { Configuration config = provider.load(file); for (String key : config.getKeys()) { dictionary.put(key, config.getString(key)); } } catch (IOException e) { e.printStackTrace(); } }
/** ファイルに保存する */ public void save() { Configuration config = new Configuration(); for (String key : dictionary.keySet()) { config.set(key, dictionary.get(key)); } File folder = new File(parent.getProxy().getPluginsFolder(), "BungeeJapanizeMessenger"); ConfigurationProvider provider = ConfigurationProvider.getProvider(YamlConfiguration.class); try { provider.save(config, new File(folder, "dictionary.yml")); } catch (IOException e) { e.printStackTrace(); } }