mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-13 19:11:22 +01:00
Add option to suppress warnings for consistency checks.
Currently only applies to the player-inconsistencies (DataMan). A summary message will be written to console on disabling the plugin if inconsistencies were found.
This commit is contained in:
parent
05ab822615
commit
f6819dc6d6
@ -77,7 +77,13 @@ public abstract class ConfPaths {
|
||||
public static final String DATA_CONSISTENCYCHECKS_CHECK = DATA_CONSISTENCYCHECKS + "active";
|
||||
public static final String DATA_CONSISTENCYCHECKS_INTERVAL = DATA_CONSISTENCYCHECKS + "interval";
|
||||
public static final String DATA_CONSISTENCYCHECKS_MAXTIME = DATA_CONSISTENCYCHECKS + "maxtime";
|
||||
|
||||
/**
|
||||
* This might not might not be used by checks. <br>
|
||||
* Used by: DataMan/Player-instances
|
||||
*
|
||||
*/
|
||||
public static final String DATA_CONSISTENCYCHECKS_SUPPRESSWARNINGS = DATA_CONSISTENCYCHECKS + "suppresswarnings";
|
||||
|
||||
private static final String CHECKS = "checks.";
|
||||
/** Debug flag to debug all checks (!), individual sections debug flags override this, if present. */
|
||||
public static final String CHECKS_DEBUG = CHECKS + SUB_DEBUG;
|
||||
|
@ -85,6 +85,7 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.DATA_CONSISTENCYCHECKS_CHECK, true);
|
||||
set(ConfPaths.DATA_CONSISTENCYCHECKS_INTERVAL, 10);
|
||||
set(ConfPaths.DATA_CONSISTENCYCHECKS_MAXTIME, 2);
|
||||
set(ConfPaths.DATA_CONSISTENCYCHECKS_SUPPRESSWARNINGS, false);
|
||||
|
||||
/*
|
||||
* 888 88b, 888 888 888 88b, 888
|
||||
|
@ -66,6 +66,8 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
|
||||
// Not static.
|
||||
//////////////////
|
||||
|
||||
private int foundInconsistencies = 0;
|
||||
|
||||
/** PlayerData storage. */
|
||||
protected final Map<String, PlayerData> playerData = new LinkedHashMap<String, PlayerData>(100);
|
||||
|
||||
@ -416,14 +418,16 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
|
||||
*/
|
||||
public void onDisable() {
|
||||
clearData(CheckType.ALL);
|
||||
// for (IRemoveData rmd : iRemoveData){
|
||||
// if (!(rmd instanceof IHaveCheckType)) rmd.removeAllData();
|
||||
// }
|
||||
iRemoveData.clear();
|
||||
clearConfigs();
|
||||
lastLogout.clear();
|
||||
executionHistories.clear();
|
||||
onlinePlayers.clear();
|
||||
// Finally alert (summary) if inconsistencies found.
|
||||
if (foundInconsistencies > 0){
|
||||
LogUtil.logWarning("[NoCheatPlus] DataMan found " + foundInconsistencies + " inconsistencies, activate consistencychecks to get more details during runtime, if desired.");
|
||||
foundInconsistencies = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -458,19 +462,22 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
|
||||
|
||||
final int storedSize = this.onlinePlayers.size();
|
||||
if (missing != 0 || changed != 0 || expectedSize != storedSize){
|
||||
final List<String> details = new LinkedList<String>();
|
||||
if (missing != 0){
|
||||
details.add("missing online players (" + missing + ")");
|
||||
foundInconsistencies ++;
|
||||
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.DATA_CONSISTENCYCHECKS_SUPPRESSWARNINGS)){
|
||||
final List<String> details = new LinkedList<String>();
|
||||
if (missing != 0){
|
||||
details.add("missing online players (" + missing + ")");
|
||||
}
|
||||
if (expectedSize != storedSize){
|
||||
// TODO: Consider checking for not online players and remove them.
|
||||
details.add("wrong number of online players (" + storedSize + " instead of " + expectedSize + ")");
|
||||
}
|
||||
if (changed != 0){
|
||||
details.add("changed player instances (" + changed + ")");
|
||||
}
|
||||
|
||||
LogUtil.logWarning("[NoCheatPlus] DataMan inconsistencies: " + StringUtil.join(details, " | "));
|
||||
}
|
||||
if (expectedSize != storedSize){
|
||||
// TODO: Consider checking for not online players and remove them.
|
||||
details.add("wrong number of online players (" + storedSize + " instead of " + expectedSize + ")");
|
||||
}
|
||||
if (changed != 0){
|
||||
details.add("changed player instances (" + changed + ")");
|
||||
}
|
||||
|
||||
LogUtil.logWarning("[NoCheatPlus] DataMan inconsistencies: " + StringUtil.join(details, " | "));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user