mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Merge branch 'master' of github.com:h31ix/AntiCheat
This commit is contained in:
commit
d996364dd5
12 files changed
+250
-102
No files matched your search
@@ -51,7 +51,7 @@ public class Anticheat extends JavaPlugin
|
||||
private final List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static boolean update = false;
|
||||
private static final int BYTE_SIZE = 1024;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static Logger logger;
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static String updateFolder;
|
||||
@@ -74,11 +74,16 @@ public class Anticheat extends JavaPlugin
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
logger = getLogger();
|
||||
manager = new AnticheatManager(this);
|
||||
config = manager.getConfiguration();
|
||||
checkConfig();
|
||||
verbose = config.verboseStartup();
|
||||
updateFolder = config.updateFolder();
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Setup the config.");
|
||||
}
|
||||
checkForUpdate();
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
@@ -89,26 +94,30 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
eventList.add(new XRayListener());
|
||||
if (config.alertXRay())
|
||||
{
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||
{
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||
{
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+name+ChatColor.YELLOW+" might be using xray.";
|
||||
alert[1] = ChatColor.YELLOW+"[ALERT] Please check their xray stats using "+ChatColor.WHITE+"/anticheat xray "+name+ChatColor.YELLOW+".";
|
||||
Utilities.alert(alert);
|
||||
xtracker.logAlert(name);
|
||||
}
|
||||
}
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+name+ChatColor.YELLOW+" might be using xray.";
|
||||
alert[1] = ChatColor.YELLOW+"[ALERT] Please check their xray stats using "+ChatColor.WHITE+"/anticheat xray "+name+ChatColor.YELLOW+".";
|
||||
Utilities.alert(alert);
|
||||
xtracker.logAlert(name);
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Scheduled the XRay checker.");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Listener listener : eventList)
|
||||
@@ -122,7 +131,7 @@ public class Anticheat extends JavaPlugin
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Registered commands");
|
||||
logger.log(Level.INFO, "[AC] Registered commands.");
|
||||
logger.log(Level.INFO, "[AC] Finished loading.");
|
||||
}
|
||||
if (update && config.autoUpdate())
|
||||
@@ -170,6 +179,10 @@ public class Anticheat extends JavaPlugin
|
||||
listener.resetCheck(type);
|
||||
}
|
||||
metrics.start();
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Metrics started.");
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -178,7 +191,6 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
String name = player.getName();
|
||||
manager.getPlayerManager().setLevel(player,config.getLevel(name));
|
||||
manager.getBackend().addNSH(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +243,7 @@ public class Anticheat extends JavaPlugin
|
||||
saveDefaultConfig();
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Config file created");
|
||||
logger.log(Level.INFO, "[AC] Config file created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.h31ix.anticheat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.PlayerManager;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BlockListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
@@ -65,11 +65,11 @@ public class BlockListener extends EventListener
|
||||
decrease(player);
|
||||
backend.logBlockPlace(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
@@ -118,5 +118,6 @@ public class BlockListener extends EventListener
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
backend.logBlockBreak(player);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class EntityListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
boolean noHack = true;
|
||||
|
||||
@@ -37,10 +37,7 @@ public class EventListener implements Listener
|
||||
|
||||
public void log(String message,Player player, CheckType type)
|
||||
{
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
Anticheat.getManager().log(player.getName()+" "+message);
|
||||
}
|
||||
Anticheat.getManager().log(player.getName()+" "+message);
|
||||
PLAYER_MANAGER.increaseLevel(player);
|
||||
removeDecrease(player);
|
||||
logCheat(type);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
@@ -113,7 +113,7 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
@@ -130,13 +130,13 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerEnterBed(PlayerBedEnterEvent event)
|
||||
{
|
||||
backend.logEnterExit(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerExitBed(PlayerBedLeaveEvent event)
|
||||
{
|
||||
backend.logEnterExit(event.getPlayer());
|
||||
@@ -153,7 +153,6 @@ public class PlayerListener extends EventListener
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
backend.addNSH(player);
|
||||
String section = "\u00a7";
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||
{
|
||||
@@ -174,7 +173,7 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void checkExploit(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
@@ -199,6 +198,34 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
log("tried to fly.",player,CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkYAxis(player))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
from.setY(from.getY()-1);
|
||||
from.setZ(from.getZ()-1);
|
||||
if(from.getBlock().getTypeId() == 0)
|
||||
{
|
||||
event.setTo(from);
|
||||
}
|
||||
for(int i= 5;i>0;i--)
|
||||
{
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ());
|
||||
Block lower = newLocation.getBlock();
|
||||
if(lower.getTypeId() == 0)
|
||||
{
|
||||
player.teleport(newLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Lets really give this flyer a real pushdown.
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ());
|
||||
Block newBlock = newLocation.getBlock();
|
||||
if(newBlock.getTypeId() != 0)
|
||||
{
|
||||
event.setTo(newLocation);
|
||||
}
|
||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
{
|
||||
if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
||||
@@ -218,7 +245,7 @@ public class PlayerListener extends EventListener
|
||||
log("tried avoid fall damage.",player,CheckType.NOFALL);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void checkDirSpeed(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class VehicleListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleEnter(VehicleEnterEvent event)
|
||||
{
|
||||
if(event.getEntered() instanceof Player)
|
||||
@@ -37,7 +37,7 @@ public class VehicleListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleExit(VehicleExitEvent event)
|
||||
{
|
||||
if(event.getExited() instanceof Player)
|
||||
|
||||
@@ -18,9 +18,14 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
@@ -38,8 +43,10 @@ public class AnticheatManager
|
||||
private PlayerManager PLAYER_MANAGER = null;
|
||||
private CheckManager CHECK_MANAGER = null;
|
||||
private Backend BACKEND = null;
|
||||
private Logger LOGGER = null;
|
||||
|
||||
private static Logger LOGGER = null;
|
||||
private static Logger FILE_LOGGER = null;
|
||||
private static Handler HANDLER;
|
||||
|
||||
public AnticheatManager(Anticheat instance)
|
||||
{
|
||||
plugin = instance;
|
||||
@@ -50,11 +57,32 @@ public class AnticheatManager
|
||||
CHECK_MANAGER = new CheckManager(this);
|
||||
BACKEND = new Backend(this);
|
||||
LOGGER = Logger.getLogger("Minecraft");
|
||||
FILE_LOGGER = Logger.getLogger(AnticheatManager.class.getName());
|
||||
try
|
||||
{
|
||||
File file = new File(plugin.getDataFolder()+"/log");
|
||||
if(!file.exists())
|
||||
{
|
||||
file.mkdir();
|
||||
}
|
||||
HANDLER = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
HANDLER.setFormatter(new SimpleFormatter());
|
||||
FILE_LOGGER.setUseParentHandlers(false);
|
||||
FILE_LOGGER.addHandler(HANDLER);
|
||||
}
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||
if(getConfiguration().logConsole())
|
||||
{
|
||||
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||
}
|
||||
FILE_LOGGER.log(Level.WARNING, message);
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
|
||||
@@ -22,15 +22,12 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
@@ -51,7 +48,7 @@ public class Backend
|
||||
public static final int FASTBREAK_MAXVIOLATIONTIME = 10000;
|
||||
public static final int FASTPLACE_LIMIT = 2;
|
||||
public static final int FASTPLACE_ZEROLIMIT = 3;
|
||||
public static final int FASTPLACE_TIMEMAX = 100;
|
||||
public static final int FASTPLACE_TIMEMAX = 80;
|
||||
public static final int FASTPLACE_MAXVIOLATIONS = 2;
|
||||
public static final int FASTPLACE_MAXVIOLATIONTIME = 10000;
|
||||
|
||||
@@ -60,6 +57,10 @@ public class Backend
|
||||
private static final int CHAT_BAN_LEVEL = 3;
|
||||
|
||||
public static final int FLIGHT_LIMIT = 4;
|
||||
public static final int FLIGHT_MINIMUM = 1;
|
||||
public static final int FLIGHT_TIMELIMIT = 5000;
|
||||
public static final int Y_MAXVIOLATIONS = 1;
|
||||
public static final int Y_MAXVIOTIME = 5000;
|
||||
public static final int NOFALL_LIMIT = 5;
|
||||
|
||||
public static final int SPRINT_FOOD_MIN = 6;
|
||||
@@ -79,6 +80,8 @@ public class Backend
|
||||
public static final double LADDER_Y_MIN = 0.11759;
|
||||
|
||||
public static final double Y_SPEED_MAX = 0.5;
|
||||
public static final double Y_MAXDIFF = 5;
|
||||
public static final double Y_TIME = 1000;
|
||||
public static final double XZ_SPEED_MAX = 0.4;
|
||||
public static final double XZ_SPEED_MAX_SPRINT = 0.65;
|
||||
public static final double XZ_SPEED_MAX_SNEAK = 0.2;
|
||||
@@ -95,6 +98,8 @@ public class Backend
|
||||
private List<String> startEat = new ArrayList<String>();
|
||||
private List<String> healed = new ArrayList<String>();
|
||||
private List<String> sprinted = new ArrayList<String>();
|
||||
private List<String> isInWater = new ArrayList<String>();
|
||||
private List<String> isInWaterCache = new ArrayList<String>();
|
||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
@@ -103,12 +108,17 @@ public class Backend
|
||||
private Map<String,Integer> chatKicks = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> nofallViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> fastBreakViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> YaxisViolations = new HashMap<String,Integer>();
|
||||
private Map<String,Long> YaxisLastVio = new HashMap<String,Long>();
|
||||
private Map<String,Double> lastYcoord = new HashMap<String,Double>();
|
||||
private Map<String,Long> lastYtime = new HashMap<String,Long>();
|
||||
private Map<String,Integer> blocksBroken = new HashMap<String,Integer>();
|
||||
private Map<String,Long> lastBlockBroken = new HashMap<String,Long>();
|
||||
private Map<String,Integer> fastPlaceViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> lastZeroHitPlace = new HashMap<String,Integer>();
|
||||
private Map<String,Long> lastBlockPlaced = new HashMap<String,Long>();
|
||||
private Map<String,Long> lastBlockPlaceTime = new HashMap<String,Long>();
|
||||
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
@@ -225,18 +235,100 @@ public class Backend
|
||||
public boolean checkWaterWalk(Player player, double x, double z)
|
||||
{
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(block.isLiquid() && player.getVehicle() == null)
|
||||
{
|
||||
if(x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER && !Utilities.sprintFly(player) && player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
if(block.isLiquid() && player.getVehicle() == null)
|
||||
{
|
||||
if(isInWater.contains(player.getName()))
|
||||
{
|
||||
return true;
|
||||
if(isInWaterCache.contains(player.getName()))
|
||||
{
|
||||
if(x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER && !Utilities.sprintFly(player) && player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isInWaterCache.add(player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
isInWater.add(player.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
isInWater.remove(player.getName());
|
||||
isInWaterCache.remove(player.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkYAxis(Player player)
|
||||
{
|
||||
if(!player.isFlying())
|
||||
{
|
||||
double y1 = player.getLocation().getY();
|
||||
String name = player.getName();
|
||||
//Fix Y axis spam.
|
||||
if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) || !YaxisViolations.containsKey(name) || !YaxisLastVio.containsKey(name))
|
||||
{
|
||||
lastYcoord.put(name, y1);
|
||||
YaxisViolations.put(name, 0);
|
||||
YaxisLastVio.put(name, 0L);
|
||||
lastYtime.put(name, System.currentTimeMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(y1 > lastYcoord.get(name) && YaxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - YaxisLastVio.get(name)) < Y_MAXVIOTIME)
|
||||
{
|
||||
Location g = player.getLocation();
|
||||
g.setY(lastYcoord.get(name));
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
|
||||
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
||||
YaxisLastVio.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(YaxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - YaxisLastVio.get(name)) > Y_MAXVIOTIME)
|
||||
{
|
||||
YaxisViolations.put(name, 0);
|
||||
YaxisLastVio.put(name, 0L);
|
||||
}
|
||||
}
|
||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
|
||||
{
|
||||
Location g = player.getLocation();
|
||||
g.setY(lastYcoord.get(name));
|
||||
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
||||
YaxisLastVio.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
|
||||
{
|
||||
lastYtime.put(name, System.currentTimeMillis());
|
||||
lastYcoord.put(name, y1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fix Y axis spam
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkFlight(Player player, double y1, double y2)
|
||||
@@ -292,6 +384,14 @@ public class Backend
|
||||
String name = player.getName();
|
||||
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES && player.getGameMode() != GameMode.CREATIVE))
|
||||
{
|
||||
if(blockPunches.get(name) != null)
|
||||
{
|
||||
int i = blockPunches.get(name);
|
||||
if(i < 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!fastBreakViolation.containsKey(name))
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
@@ -383,11 +483,11 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name)+1);
|
||||
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name)+1);
|
||||
}
|
||||
}
|
||||
if(!nocheck && thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX
|
||||
&& lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
||||
if(thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX
|
||||
|| nocheck && lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
||||
{
|
||||
lastBlockPlaceTime.put(name, (time-last));
|
||||
lastBlockPlaced.put(name, time);
|
||||
@@ -495,7 +595,8 @@ public class Backend
|
||||
|
||||
public void logBlockBreak(final Player player)
|
||||
{
|
||||
logEvent(brokenBlock,player,BLOCK_BREAK_MIN);
|
||||
logEvent(brokenBlock,player,BLOCK_BREAK_MIN);
|
||||
resetAnimation(player);
|
||||
}
|
||||
|
||||
public boolean justBroke(Player player)
|
||||
@@ -515,12 +616,14 @@ public class Backend
|
||||
|
||||
public void logAnimation(final Player player)
|
||||
{
|
||||
logEvent(animated,player,ANIMATION_MIN);
|
||||
logEvent(animated,player,ANIMATION_MIN);
|
||||
increment(player,blockPunches);
|
||||
}
|
||||
|
||||
public void resetAnimation(final Player player)
|
||||
{
|
||||
animated.remove(player.getName());
|
||||
animated.remove(player.getName());
|
||||
blockPunches.put(player.getName(), 0);
|
||||
}
|
||||
|
||||
public boolean justAnimated(Player player)
|
||||
@@ -633,13 +736,24 @@ public class Backend
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addNSH(Player player)
|
||||
{
|
||||
EntityPlayer ePlayer = ((CraftPlayer)player).getHandle();
|
||||
NSH nsh = new NSH(((CraftServer)player.getServer()).getHandle().server, ePlayer.netServerHandler.networkManager, ePlayer);
|
||||
((CraftPlayer)player).getHandle().netServerHandler = nsh;
|
||||
((CraftPlayer)player).getHandle().netServerHandler.networkManager.a(nsh);
|
||||
((CraftServer)player.getServer()).getServer().networkListenThread.a(nsh);
|
||||
public void increment(Player player, Map<String,Integer> map)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(map.get(name) == null)
|
||||
{
|
||||
map.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = map.get(name)+1;
|
||||
if(amount < 6)
|
||||
{
|
||||
map.put(name, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.put(name, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.api.AnticheatAPI;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.Packet202Abilities;
|
||||
|
||||
public class NSH extends NetServerHandler
|
||||
{
|
||||
|
||||
public NSH(MinecraftServer server, NetworkManager manager, EntityPlayer player)
|
||||
{
|
||||
super(server, manager, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet202Abilities packet202abilities)
|
||||
{
|
||||
if(this.player.abilities.isFlying)
|
||||
{
|
||||
if(!packet202abilities.b && this.player.abilities.canFly)
|
||||
{
|
||||
AnticheatAPI.getManager().getBackend().logExitFly(player.getBukkitEntity().getPlayer());
|
||||
}
|
||||
}
|
||||
this.player.abilities.isFlying = packet202abilities.b && this.player.abilities.canFly;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user