mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Add in inventory checks. Fixes Issue 55.
This commit is contained in:
1 parent
80f13d9adc
commit
4186151609
8 files changed
+135
-4
No files matched your search
@@ -83,6 +83,9 @@ public class Backend
|
||||
private Map<String, Long> movingExempt = new HashMap<String, Long>();
|
||||
private Map<String, Long> blockTime = new HashMap<String, Long>();
|
||||
private Map<String, Integer> blocksDropped = new HashMap<String, Integer>();
|
||||
private Map<String, Long> lastInventoryTime = new HashMap<String, Long>();
|
||||
private Map<String, Long> inventoryTime = new HashMap<String, Long>();
|
||||
private Map<String, Integer> inventoryChanges = new HashMap<String, Integer>();
|
||||
|
||||
private Magic magic;
|
||||
private AnticheatManager micromanage = null;
|
||||
@@ -883,6 +886,53 @@ public class Backend
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkInventoryClicks(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
long time = System.currentTimeMillis();
|
||||
if (!inventoryTime.containsKey(name) || !inventoryChanges.containsKey(name))
|
||||
{
|
||||
inventoryTime.put(name, 0l);
|
||||
if(!inventoryChanges.containsKey(name))
|
||||
{
|
||||
inventoryChanges.put(name, 0);
|
||||
}
|
||||
}
|
||||
else if (inventoryChanges.containsKey(name) && inventoryChanges.get(name) > magic.INVENTORY_MAXVIOLATIONS)
|
||||
{
|
||||
long diff = System.currentTimeMillis() - lastInventoryTime.get(name);
|
||||
System.out.println("inventoryTime = " + inventoryTime.get(name));
|
||||
System.out.println("diff = " + diff);
|
||||
if (inventoryTime.get(name) > 0 && diff < magic.INVENTORY_MAXVIOLATIONTIME)
|
||||
{
|
||||
inventoryTime.put(name, diff);
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Inventory hack detected. Please wait 10 seconds before using inventories.");
|
||||
return true;
|
||||
} else if (inventoryTime.get(name) > 0 && diff > magic.INVENTORY_MAXVIOLATIONTIME)
|
||||
{
|
||||
inventoryChanges.put(name, 0);
|
||||
}
|
||||
}
|
||||
else if (inventoryTime.containsKey(name))
|
||||
{
|
||||
long last = lastInventoryTime.get(name);
|
||||
long thisTime = time - last;
|
||||
if (thisTime < magic.INVENTORY_TIMEMAX)
|
||||
{
|
||||
inventoryChanges.put(name, inventoryChanges.get(name) + 1);
|
||||
if(inventoryChanges.get(name) > magic.INVENTORY_MAXVIOLATIONS)
|
||||
{
|
||||
inventoryTime.put(name, thisTime);
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Inventory hack detected. Please wait 10 seconds before using inventories.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
inventoryTime.put(name, thisTime);
|
||||
}
|
||||
lastInventoryTime.put(name, time);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clearChatLevel(Player player)
|
||||
{
|
||||
chatLevel.remove(player.getName());
|
||||
|
||||
Reference in new issue
Block a user