/** * 設定ファイルのバージョンをチェックする * * @param ver */ private void checkver(final double ver) { double configVersion = ver; double nowVersion = 0.1D; String versionString = plugin.getDescription().getVersion(); try { // Support maven and Jenkins build number int index = versionString.indexOf("-"); if (index > 0) { versionString = versionString.substring(0, index); } nowVersion = Double.parseDouble(versionString); } catch (NumberFormatException ex) { log.warning(logPrefix + "Cannot parse version string!"); } // 比較 設定ファイルのバージョンが古ければ config.yml を上書きする if (configVersion < nowVersion) { // 先に古い設定ファイルをリネームする String destName = "oldconfig-v" + configVersion + ".yml"; String srcPath = new File(pluginDir, "config.yml").getPath(); String destPath = new File(pluginDir, destName).getPath(); try { copyTransfer(srcPath, destPath); log.info(logPrefix + "Copied old config.yml to " + destName + "!"); } catch (Exception ex) { log.warning(logPrefix + "Cannot copy old config.yml!"); } // config.ymlを強制コピー extractResource("/config.yml", pluginDir, true, false); log.info(logPrefix + "Deleted existing configuration file and generate a new one!"); } }