mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-06 15:58:12 +01:00
Add: /ncp remove * [<check type>]
This commit is contained in:
parent
5b1eb3121e
commit
7962962a40
@ -166,6 +166,12 @@ public class ViolationHistory {
|
|||||||
return violationHistories.remove(playerName);
|
return violationHistories.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(final CheckType checkType){
|
||||||
|
for (ViolationHistory hist : violationHistories.values()){
|
||||||
|
hist.remove(checkType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The violation levels for every check. */
|
/** The violation levels for every check. */
|
||||||
private final List<ViolationLevel> violationLevels = new ArrayList<ViolationLevel>();
|
private final List<ViolationLevel> violationLevels = new ArrayList<ViolationLevel>();
|
||||||
|
|
||||||
|
@ -44,4 +44,9 @@ public interface CheckDataFactory {
|
|||||||
*/
|
*/
|
||||||
public ICheckData removeData(final String playerName);
|
public ICheckData removeData(final String playerName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all data for all players.
|
||||||
|
*/
|
||||||
|
public void removeAllData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,11 @@ public class BlockBreakData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return BlockBreakData.removeData(playerName);
|
return BlockBreakData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -66,6 +71,10 @@ public class BlockBreakData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double directionVL;
|
public double directionVL;
|
||||||
public double fastBreakVL;
|
public double fastBreakVL;
|
||||||
|
@ -42,6 +42,11 @@ public class BlockInteractData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return BlockInteractData.removeData(playerName);
|
return BlockInteractData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -64,6 +69,10 @@ public class BlockInteractData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double directionVL;
|
public double directionVL;
|
||||||
public double reachVL;
|
public double reachVL;
|
||||||
|
@ -42,6 +42,11 @@ public class BlockPlaceData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return BlockPlaceData.removeData(playerName);
|
return BlockPlaceData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -64,6 +69,10 @@ public class BlockPlaceData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double directionVL;
|
public double directionVL;
|
||||||
public double fastPlaceVL;
|
public double fastPlaceVL;
|
||||||
|
@ -35,6 +35,11 @@ public class ChatData extends AsyncCheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return ChatData.removeData(playerName);
|
return ChatData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -47,16 +52,20 @@ public class ChatData extends AsyncCheckData {
|
|||||||
* the player
|
* the player
|
||||||
* @return the data
|
* @return the data
|
||||||
*/
|
*/
|
||||||
public synchronized static ChatData getData(final Player player) {
|
public static synchronized ChatData getData(final Player player) {
|
||||||
if (!playersMap.containsKey(player.getName()))
|
if (!playersMap.containsKey(player.getName()))
|
||||||
playersMap.put(player.getName(), new ChatData());
|
playersMap.put(player.getName(), new ChatData());
|
||||||
return playersMap.get(player.getName());
|
return playersMap.get(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static ICheckData removeData(final String playerName) {
|
public static synchronized ICheckData removeData(final String playerName) {
|
||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double captchaVL;
|
public double captchaVL;
|
||||||
public double colorVL;
|
public double colorVL;
|
||||||
|
@ -23,6 +23,11 @@ public class CombinedData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return CombinedData.removeData(playerName);
|
return CombinedData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Map<String, CombinedData> playersMap = new HashMap<String, CombinedData>();
|
private static final Map<String, CombinedData> playersMap = new HashMap<String, CombinedData>();
|
||||||
@ -41,6 +46,10 @@ public class CombinedData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public double improbableVL = 0;
|
public double improbableVL = 0;
|
||||||
public double speedVL = 0;
|
public double speedVL = 0;
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ public class FightData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return FightData.removeData(playerName);
|
return FightData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -60,6 +65,10 @@ public class FightData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double angleVL;
|
public double angleVL;
|
||||||
public double criticalVL;
|
public double criticalVL;
|
||||||
|
@ -36,6 +36,11 @@ public class InventoryData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return InventoryData.removeData(playerName);
|
return InventoryData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -58,6 +63,10 @@ public class InventoryData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double dropVL;
|
public double dropVL;
|
||||||
public double fastClickVL;
|
public double fastClickVL;
|
||||||
|
@ -37,6 +37,11 @@ public class MovingData extends ACheckData {
|
|||||||
public ICheckData removeData(final String playerName) {
|
public ICheckData removeData(final String playerName) {
|
||||||
return MovingData.removeData(playerName);
|
return MovingData.removeData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllData() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The map containing the data per players. */
|
/** The map containing the data per players. */
|
||||||
@ -59,6 +64,10 @@ public class MovingData extends ACheckData {
|
|||||||
return playersMap.remove(playerName);
|
return playersMap.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
playersMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double creativeFlyVL = 0D;
|
public double creativeFlyVL = 0D;
|
||||||
public double morePacketsVL = 0D;
|
public double morePacketsVL = 0D;
|
||||||
|
@ -40,6 +40,12 @@ public class RemovePlayerCommand extends NCPCommand {
|
|||||||
}
|
}
|
||||||
else checkType = CheckType.ALL;
|
else checkType = CheckType.ALL;
|
||||||
|
|
||||||
|
if (playerName.equals("*")){
|
||||||
|
DataManager.clear(checkType);
|
||||||
|
sender.sendMessage(TAG + "Removed all data and history: " + checkType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final Player player = Bukkit.getPlayerExact(playerName);
|
final Player player = Bukkit.getPlayerExact(playerName);
|
||||||
if (player != null) playerName = player.getName();
|
if (player != null) playerName = player.getName();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.players;
|
package fr.neatmonster.nocheatplus.players;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -122,4 +123,22 @@ public class DataManager implements Listener, INotifyReload, INeedConfig{
|
|||||||
}
|
}
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove data and history of all players for the given check type and sub checks.
|
||||||
|
* @param checkType
|
||||||
|
*/
|
||||||
|
public static void clear(final CheckType checkType) {
|
||||||
|
final Set<CheckDataFactory> factories = new HashSet<CheckDataFactory>();
|
||||||
|
for (final CheckType type : APIUtils.getWithChildren(checkType)){
|
||||||
|
final Map<String, ExecutionHistory> map = instance.executionHistories.get(type);
|
||||||
|
if (map != null) map.clear();
|
||||||
|
final CheckDataFactory factory = type.getDataFactory();
|
||||||
|
if (factory != null) factories.add(factory);
|
||||||
|
}
|
||||||
|
for (final CheckDataFactory factory : factories){
|
||||||
|
factory.removeAllData();
|
||||||
|
}
|
||||||
|
ViolationHistory.clear(checkType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user