Switch to hard-coded build number for config-outdated checking to avoid

unnecessary regenerating of configs.
This commit is contained in:
asofold 2012-10-12 02:46:02 +02:00
parent b79a292c34
commit 541430a361
3 changed files with 10 additions and 7 deletions

View File

@ -35,6 +35,7 @@ import fr.neatmonster.nocheatplus.command.INotifyReload;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.config.DefaultConfig;
import fr.neatmonster.nocheatplus.config.INeedConfig;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.metrics.Metrics;
@ -320,7 +321,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
// }
// Is the configuration outdated?
configOutdated = Updates.isConfigOutdated(getDescription().getVersion(), config);
configOutdated = Updates.isConfigOutdated(DefaultConfig.buildNumber, config);
// Debug information about unknown blocks.
// (Probably removed later.)
@ -372,8 +373,8 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
// Send a message to the player if the configuration is outdated.
if (configOutdated && player.hasPermission(Permissions.ADMINISTRATION_NOTIFY))
player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration file is outdated.\n"
+ "Some settings might have changed, you should regenerate it!");
player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration might be outdated.\n"
+ "Some settings could have changed, you should regenerate it!");
String message = "";

View File

@ -20,6 +20,9 @@ import org.bukkit.Material;
* given in the configFactory.yml file.
*/
public class DefaultConfig extends ConfigFile {
/** NCP build needed for this config. */
public static final int buildNumber = 153;
/**
* Instantiates a new default configuration.

View File

@ -12,16 +12,15 @@ public class Updates {
/**
*
* @param versionString Current version string (getDescription().getVersion()).
* @param neededVersion Version needed.
* @param config
* @return
*/
public static boolean isConfigOutdated(String versionString, ConfigFile config){
public static boolean isConfigOutdated(int neededVersion, ConfigFile config){
try {
final int currentVersion = Integer.parseInt(versionString.split("-b")[1]);
final int configurationVersion = Integer.parseInt(
config.options().header().split("-b")[1].split("\\.")[0]);
if (currentVersion > configurationVersion)
if (neededVersion > configurationVersion)
return true;
} catch (final Exception e) {}
return false;