mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-12 09:41:46 +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.ConfPaths;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
|
import fr.neatmonster.nocheatplus.config.DefaultConfig;
|
||||||
import fr.neatmonster.nocheatplus.config.INeedConfig;
|
import fr.neatmonster.nocheatplus.config.INeedConfig;
|
||||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||||
import fr.neatmonster.nocheatplus.metrics.Metrics;
|
import fr.neatmonster.nocheatplus.metrics.Metrics;
|
||||||
@ -320,7 +321,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Is the configuration outdated?
|
// Is the configuration outdated?
|
||||||
configOutdated = Updates.isConfigOutdated(getDescription().getVersion(), config);
|
configOutdated = Updates.isConfigOutdated(DefaultConfig.buildNumber, config);
|
||||||
|
|
||||||
// Debug information about unknown blocks.
|
// Debug information about unknown blocks.
|
||||||
// (Probably removed later.)
|
// (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.
|
// Send a message to the player if the configuration is outdated.
|
||||||
if (configOutdated && player.hasPermission(Permissions.ADMINISTRATION_NOTIFY))
|
if (configOutdated && player.hasPermission(Permissions.ADMINISTRATION_NOTIFY))
|
||||||
player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration file is outdated.\n"
|
player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration might be outdated.\n"
|
||||||
+ "Some settings might have changed, you should regenerate it!");
|
+ "Some settings could have changed, you should regenerate it!");
|
||||||
|
|
||||||
String message = "";
|
String message = "";
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ import org.bukkit.Material;
|
|||||||
* given in the configFactory.yml file.
|
* given in the configFactory.yml file.
|
||||||
*/
|
*/
|
||||||
public class DefaultConfig extends ConfigFile {
|
public class DefaultConfig extends ConfigFile {
|
||||||
|
|
||||||
|
/** NCP build needed for this config. */
|
||||||
|
public static final int buildNumber = 153;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new default configuration.
|
* 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
|
* @param config
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isConfigOutdated(String versionString, ConfigFile config){
|
public static boolean isConfigOutdated(int neededVersion, ConfigFile config){
|
||||||
try {
|
try {
|
||||||
final int currentVersion = Integer.parseInt(versionString.split("-b")[1]);
|
|
||||||
final int configurationVersion = Integer.parseInt(
|
final int configurationVersion = Integer.parseInt(
|
||||||
config.options().header().split("-b")[1].split("\\.")[0]);
|
config.options().header().split("-b")[1].split("\\.")[0]);
|
||||||
if (currentVersion > configurationVersion)
|
if (neededVersion > configurationVersion)
|
||||||
return true;
|
return true;
|
||||||
} catch (final Exception e) {}
|
} catch (final Exception e) {}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user