Check IHaveCHeckType after CheckType.ALL for data removal.

This ensures that "ncp remove *" really removes chat.logins data, for
instance.
This commit is contained in:
asofold 2013-03-13 05:51:54 +01:00
parent 976cd59b7c
commit 414796b938
2 changed files with 13 additions and 11 deletions

View File

@ -2,7 +2,9 @@ package fr.neatmonster.nocheatplus.components;
/**
* Interface for component registration to allow cleanup for player data.<br>
* NOTE: For CheckType-specific data removal, IHaveCheckType should be implemented, otherwise this data might get ignored until plugin-disable.
* NOTES:
* <li>For CheckType-specific data removal, IHaveCheckType should be implemented, otherwise this data might get ignored until plugin-disable.</li>
* <li>In case of data removal for CheckType.ALL this might get called for either a certain player or all.</li>
* @author mc_dev
*
*/

View File

@ -253,14 +253,14 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
factory.removeAllData();
}
for (final IRemoveData rmd : instance.iRemoveData){
if (rmd instanceof IHaveCheckType){
final CheckType refType = ((IHaveCheckType) rmd).getCheckType();
if (refType == checkType || APIUtils.isParent(checkType, refType)) rmd.removeAllData();
}
else if (checkType == CheckType.ALL){
if (checkType == CheckType.ALL){
// Not sure this is really good, though.
rmd.removeAllData();
}
else if (rmd instanceof IHaveCheckType){
final CheckType refType = ((IHaveCheckType) rmd).getCheckType();
if (refType == checkType || APIUtils.isParent(checkType, refType)) rmd.removeAllData();
}
}
ViolationHistory.clear(checkType);
}
@ -302,16 +302,16 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
public static boolean clearComponentData(final CheckType checkType, final String PlayerName){
boolean removed = false;
for (final IRemoveData rmd : instance.iRemoveData){
if (rmd instanceof IHaveCheckType){
if (checkType == CheckType.ALL){
// Not sure this is really good, though.
if (rmd.removeData(PlayerName) != null) removed = true;
}
else if (rmd instanceof IHaveCheckType){
final CheckType refType = ((IHaveCheckType) rmd).getCheckType();
if (refType == checkType || APIUtils.isParent(checkType, refType)){
if (rmd.removeData(PlayerName) != null) removed = true;
}
}
else if (checkType == CheckType.ALL){
// Not sure this is really good, though.
if (rmd.removeData(PlayerName) != null) removed = true;
}
}
return removed;
}