mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 03:02:11 +01:00
Switch to hard-coded build number for config-outdated checking to avoid
unnecessary regenerating of configs.
This commit is contained in:
parent
b79a292c34
commit
541430a361
@ -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 = "";
|
||||
|
||||
|
@ -21,6 +21,9 @@ import org.bukkit.Material;
|
||||
*/
|
||||
public class DefaultConfig extends ConfigFile {
|
||||
|
||||
/** NCP build needed for this config. */
|
||||
public static final int buildNumber = 153;
|
||||
|
||||
/**
|
||||
* Instantiates a new default configuration.
|
||||
*/
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user