Refactored AntiHack a bit to try and remove CCM
This commit is contained in:
parent
97f57b655b
commit
419f33fcc3
@ -42,8 +42,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class AntiHack extends MiniPlugin
|
||||
{
|
||||
private static Object _antiHackLock = new Object();
|
||||
|
||||
public static AntiHack Instance;
|
||||
|
||||
private boolean _enabled = true;
|
||||
@ -115,11 +113,8 @@ public class AntiHack extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_lastMoveEvent.put(event.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerTeleport(PlayerTeleportEvent event)
|
||||
@ -127,11 +122,8 @@ public class AntiHack extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
setIgnore(event.getPlayer(), 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerVelocity(PlayerVelocityEvent event)
|
||||
@ -139,11 +131,8 @@ public class AntiHack extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_velocityEvent.add(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
@ -151,7 +140,7 @@ public class AntiHack extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
ResetAll(event.getPlayer());
|
||||
resetAll(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -162,8 +151,6 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
if (_velocityEvent.remove(player))
|
||||
{
|
||||
setIgnore(player, 2000);
|
||||
@ -180,7 +167,6 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIgnore(Player player, long time)
|
||||
{
|
||||
@ -188,8 +174,6 @@ public class AntiHack extends MiniPlugin
|
||||
for (Detector detector : _movementDetectors)
|
||||
detector.Reset(player);
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
//Already ignoring for a longer period
|
||||
if (_ignore.containsKey(player) && _ignore.get(player) > System.currentTimeMillis() + time)
|
||||
return;
|
||||
@ -197,7 +181,6 @@ public class AntiHack extends MiniPlugin
|
||||
//Add Ignore
|
||||
_ignore.put(player, System.currentTimeMillis() + time);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid(Player player, boolean groundValid)
|
||||
{
|
||||
@ -246,8 +229,6 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
System.out.println(C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
//Add Offense
|
||||
if (!_offense.containsKey(player))
|
||||
_offense.put(player, new HashMap<String, ArrayList<Long>>());
|
||||
@ -284,7 +265,6 @@ public class AntiHack extends MiniPlugin
|
||||
// Print (Debug)
|
||||
System.out.println("[Offense] #" + total + ": "+ player.getName() + " received suspicion for " + type + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void generateReports(UpdateEvent event)
|
||||
@ -295,19 +275,18 @@ public class AntiHack extends MiniPlugin
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
for (Iterator<Entry<Player, HashMap<String, ArrayList<Long>>>> playerIterator = _offense.entrySet().iterator(); playerIterator.hasNext();)
|
||||
{
|
||||
for (Iterator<Player> playerIterator = _offense.keySet().iterator(); playerIterator.hasNext();)
|
||||
{
|
||||
Player player = playerIterator.next();
|
||||
Entry<Player, HashMap<String, ArrayList<Long>>> entry = playerIterator.next();
|
||||
Player player = entry.getKey();
|
||||
|
||||
String out = "";
|
||||
int total = 0;
|
||||
|
||||
for (String type : _offense.get(player).keySet())
|
||||
for (String type : entry.getValue().keySet())
|
||||
{
|
||||
//Remove Old Offenses
|
||||
Iterator<Long> offenseIterator = _offense.get(player).get(type).iterator();
|
||||
Iterator<Long> offenseIterator = entry.getValue().get(type).iterator();
|
||||
while (offenseIterator.hasNext())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
@ -317,7 +296,7 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
|
||||
//Count
|
||||
int count = _offense.get(player).get(type).size();
|
||||
int count = entry.getValue().get(type).size();
|
||||
total += count;
|
||||
|
||||
out += count + " " + type + ", ";
|
||||
@ -326,17 +305,22 @@ public class AntiHack extends MiniPlugin
|
||||
if (out.length() > 0)
|
||||
out = out.substring(0, out.length() - 2);
|
||||
|
||||
String severity;
|
||||
if (total > (_strict ? 6 : 18)) severity = "Extreme";
|
||||
else if (total > (_strict ? 4 : 12)) severity = "High";
|
||||
else if (total > (_strict ? 2 : 6)) severity = "Medium";
|
||||
else severity = "Low";
|
||||
String severity = "Low";
|
||||
|
||||
if (total > (_strict ? 6 : 18))
|
||||
severity = "Extreme";
|
||||
else if (total > (_strict ? 4 : 12))
|
||||
severity = "High";
|
||||
else if (total > (_strict ? 2 : 6))
|
||||
severity = "Medium";
|
||||
|
||||
//Send Report
|
||||
sendReport(player, out, severity);
|
||||
|
||||
if (severity.equalsIgnoreCase("Extreme"))
|
||||
{
|
||||
playerIterator.remove();
|
||||
resetAll(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,8 +329,6 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
if (severity.equals("Extreme"))
|
||||
{
|
||||
ResetAll(player, false);
|
||||
|
||||
//Staff
|
||||
boolean handled = false;
|
||||
for (Player staff : UtilServer.getPlayers())
|
||||
@ -414,20 +396,18 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
private void reset()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
ResetAll(player);
|
||||
resetAll(player);
|
||||
}
|
||||
|
||||
private void ResetAll(Player player)
|
||||
private void resetAll(Player player)
|
||||
{
|
||||
ResetAll(player, true);
|
||||
resetAll(player, true);
|
||||
}
|
||||
|
||||
private void ResetAll(Player player, boolean removeOffenses)
|
||||
{
|
||||
synchronized (_antiHackLock)
|
||||
private void resetAll(Player player, boolean removeOffenses)
|
||||
{
|
||||
_ignore.remove(player);
|
||||
_velocityEvent.remove(player);
|
||||
@ -442,7 +422,6 @@ public class AntiHack extends MiniPlugin
|
||||
for (Detector detector : _combatDetectors)
|
||||
detector.Reset(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cleanupPlayers(UpdateEvent event)
|
||||
@ -453,8 +432,6 @@ public class AntiHack extends MiniPlugin
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
for (Iterator<Entry<Player, Long>> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext();)
|
||||
{
|
||||
Player player = playerIterator.next().getKey();
|
||||
@ -476,15 +453,14 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnabled(boolean b)
|
||||
public void setEnabled(boolean b)
|
||||
{
|
||||
_enabled = b;
|
||||
System.out.println("MAC Enabled: " + b);
|
||||
}
|
||||
|
||||
public boolean IsEnabled()
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
@ -493,7 +469,7 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
_strict = strict;
|
||||
|
||||
Reset();
|
||||
reset();
|
||||
|
||||
System.out.println("MAC Strict: " + strict);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class Fly extends MiniPlugin implements Detector
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void updateFlyhack(PlayerMoveEvent event)
|
||||
{
|
||||
if (!Host.IsEnabled())
|
||||
if (!Host.isEnabled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
@ -32,7 +32,7 @@ public class Idle extends MiniPlugin implements Detector
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void updateFlyhack(PlayerMoveEvent event)
|
||||
{
|
||||
if (!Host.IsEnabled())
|
||||
if (!Host.isEnabled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
@ -43,7 +43,7 @@ public class Idle extends MiniPlugin implements Detector
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void updateFreeCam(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsEnabled())
|
||||
if (!Host.isEnabled())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
|
@ -38,7 +38,7 @@ public class Reach extends MiniPlugin implements Detector
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void recordMove(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsEnabled())
|
||||
if (!Host.isEnabled())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
|
@ -33,7 +33,7 @@ public class Speed extends MiniPlugin implements Detector
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void updateSpeedhack(PlayerMoveEvent event)
|
||||
{
|
||||
if (!Host.IsEnabled())
|
||||
if (!Host.isEnabled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user