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
dcbcd6e89f
12 files changed
+179
-25
No files matched your search
@@ -257,6 +257,14 @@ public class Anticheat extends JavaPlugin
|
||||
logger.log(Level.INFO, "[AC] Config file created.");
|
||||
}
|
||||
}
|
||||
if (!new File(getDataFolder() + "/lang.yml").exists())
|
||||
{
|
||||
saveResource("lang.yml",false);
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Lang file created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdate()
|
||||
|
||||
@@ -36,8 +36,10 @@ public class Configuration
|
||||
private File configFile = null;
|
||||
private File levelFile = null;
|
||||
private File bukkitFile = null;
|
||||
private File langFile = null;
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration level;
|
||||
private FileConfiguration lang;
|
||||
private boolean logConsole;
|
||||
private boolean logXRay;
|
||||
private boolean alertXRay;
|
||||
@@ -45,6 +47,7 @@ public class Configuration
|
||||
private boolean verboseStartup;
|
||||
private int fileLogLevel = 0;
|
||||
private String updateFolder;
|
||||
private static Language language;
|
||||
private List<String> worlds = new ArrayList<String>();
|
||||
|
||||
public Configuration(AnticheatManager instance)
|
||||
@@ -53,6 +56,7 @@ public class Configuration
|
||||
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
||||
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
||||
bukkitFile = new File("bukkit.yml");
|
||||
langFile = new File(micromanage.getPlugin().getDataFolder()+"/lang.yml");
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -103,6 +107,11 @@ public class Configuration
|
||||
return fileLogLevel;
|
||||
}
|
||||
|
||||
public Language getLang()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
public final void load()
|
||||
{
|
||||
FileConfiguration bukkit;
|
||||
@@ -110,6 +119,8 @@ public class Configuration
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
||||
lang = YamlConfiguration.loadConfiguration(langFile);
|
||||
language = new Language(lang);
|
||||
updateFolder = bukkit.getString("settings.update-folder");
|
||||
if(config.getString("Logging.Log to console") != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class Language
|
||||
{
|
||||
private static String[] medAlert = null;
|
||||
private static String[] highAlert = null;
|
||||
private static String[] warning = null;
|
||||
private static String banReason = null;
|
||||
private static String banBroadcast = null;
|
||||
private static String kickReason = null;
|
||||
private static String kickBroadcast = null;
|
||||
|
||||
public Language(FileConfiguration file)
|
||||
{
|
||||
medAlert = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
||||
highAlert = file.getList("alert.high_alert").toArray(new String[file.getList("alert.high_alert").size()]);
|
||||
warning = file.getList("warning.player_warning").toArray(new String[file.getList("warning.player_warning").size()]);
|
||||
banReason = file.getString("ban.ban_reason");
|
||||
banBroadcast = file.getString("ban.ban_broadcast");
|
||||
kickReason = file.getString("kick.kick_reason");
|
||||
kickBroadcast = file.getString("kick.kick_broadcast");
|
||||
}
|
||||
|
||||
public String [] getMediumAlert()
|
||||
{
|
||||
return medAlert;
|
||||
}
|
||||
|
||||
public String [] getHighAlert()
|
||||
{
|
||||
return highAlert;
|
||||
}
|
||||
|
||||
public String [] getWarning()
|
||||
{
|
||||
return warning;
|
||||
}
|
||||
|
||||
public String getBanReason()
|
||||
{
|
||||
return banReason;
|
||||
}
|
||||
|
||||
public String getBanBroadcast()
|
||||
{
|
||||
return banBroadcast;
|
||||
}
|
||||
|
||||
public String getKickReason()
|
||||
{
|
||||
return kickReason;
|
||||
}
|
||||
|
||||
public String getKickBroadcast()
|
||||
{
|
||||
return kickBroadcast;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@@ -50,6 +51,19 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||
{
|
||||
if(event.getEntity().getShooter() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity().getShooter();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
||||
{
|
||||
backend.logProjectile(player,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ public class AnticheatManager
|
||||
}
|
||||
handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
||||
handler.setFormatter(new FileFormatter());
|
||||
handler.setLevel(Level.INFO);
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
@@ -82,7 +83,7 @@ public class AnticheatManager
|
||||
{
|
||||
if(getConfiguration().logConsole())
|
||||
{
|
||||
LOGGER.warning(ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
LOGGER.info(ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
}
|
||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||
{
|
||||
@@ -92,7 +93,7 @@ public class AnticheatManager
|
||||
|
||||
public void fileLog(String message)
|
||||
{
|
||||
FILE_LOGGER.warning(message);
|
||||
FILE_LOGGER.info(message);
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.event.EventListener;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -45,6 +46,7 @@ public class Backend
|
||||
private static final int DROPPED_ITEM_TIME = 2;
|
||||
private static final int DAMAGE_TIME = 50;
|
||||
private static final int KNOCKBACK_DAMAGE_TIME = 50;
|
||||
private static final int PROJECTILE_TIME = 20;
|
||||
|
||||
private static final int FASTBREAK_LIMIT = 3;
|
||||
private static final int FASTBREAK_TIMEMAX = 500;
|
||||
@@ -59,6 +61,8 @@ public class Backend
|
||||
|
||||
private static final int BLOCK_PUNCH_MIN = 5;
|
||||
|
||||
private static final int PROJECTILE_MAX = 8;
|
||||
|
||||
private static final int CHAT_WARN_LEVEL = 7;
|
||||
private static final int CHAT_KICK_LEVEL = 10;
|
||||
private static final int CHAT_BAN_LEVEL = 3;
|
||||
@@ -114,6 +118,7 @@ public class Backend
|
||||
private List<String> isInWaterCache = new ArrayList<String>();
|
||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||
private List<String> isAscending = new ArrayList<String>();
|
||||
private List<String> trackingProjectiles = new ArrayList<String>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||
@@ -134,6 +139,7 @@ public class Backend
|
||||
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> projectilesShot = new HashMap<String,Integer>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
@@ -725,7 +731,7 @@ public class Backend
|
||||
public void logAnimation(final Player player)
|
||||
{
|
||||
logEvent(animated,player,ANIMATION_MIN);
|
||||
increment(player,blockPunches);
|
||||
increment(player,blockPunches,BLOCK_PUNCH_MIN);
|
||||
}
|
||||
|
||||
public void resetAnimation(final Player player)
|
||||
@@ -739,6 +745,28 @@ public class Backend
|
||||
return animated.contains(player.getName());
|
||||
}
|
||||
|
||||
public void logProjectile(final Player player, final EventListener e)
|
||||
{
|
||||
increment(player,projectilesShot,PROJECTILE_MAX);
|
||||
if(!trackingProjectiles.contains(player.getName()))
|
||||
{
|
||||
trackingProjectiles.add(player.getName());
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
trackingProjectiles.remove(player.getName());
|
||||
if(projectilesShot.get(player.getName()) >= PROJECTILE_MAX)
|
||||
{
|
||||
e.log("tried to fire projectiles too fast",player,CheckType.FAST_PROJECTILE);
|
||||
}
|
||||
projectilesShot.put(player.getName(),0);
|
||||
}
|
||||
}, PROJECTILE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
public void logDamage(final Player player)
|
||||
{
|
||||
int time = DAMAGE_TIME;
|
||||
@@ -867,7 +895,7 @@ public class Backend
|
||||
}
|
||||
}
|
||||
}
|
||||
public void increment(Player player, Map<String,Integer> map)
|
||||
public void increment(Player player, Map<String,Integer> map, int num)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(map.get(name) == null)
|
||||
@@ -877,13 +905,13 @@ public class Backend
|
||||
else
|
||||
{
|
||||
int amount = map.get(name)+1;
|
||||
if(amount < BLOCK_PUNCH_MIN+1)
|
||||
if(amount < num+1)
|
||||
{
|
||||
map.put(name, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.put(name, BLOCK_PUNCH_MIN);
|
||||
map.put(name, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public enum CheckType
|
||||
FORCEFIELD("anticheat.forcefield"),
|
||||
XRAY("anticheat.xray"),
|
||||
LONG_REACH("anticheat.longreach"),
|
||||
FAST_PROJECTILE("anticheat.projectile"),
|
||||
ITEM_SPAM("anticheat.itemspam");
|
||||
|
||||
private final String permission;
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.h31ix.anticheat.manage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.Language;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -36,6 +37,7 @@ public class PlayerManager
|
||||
|
||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
private static Configuration config = null;
|
||||
private static Language lang;
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
private static final int LEVEL_MAX = 60;
|
||||
@@ -43,23 +45,18 @@ public class PlayerManager
|
||||
|
||||
public PlayerManager(AnticheatManager instance) {
|
||||
config = instance.getConfiguration();
|
||||
lang = config.getLang();
|
||||
}
|
||||
|
||||
private static void reactMedium(Player player)
|
||||
{
|
||||
execute("Medium",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
||||
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
||||
Utilities.alert(alert);
|
||||
Utilities.alert(formatArray(lang.getMediumAlert(),player,ChatColor.YELLOW));
|
||||
}
|
||||
private static void reactHigh(Player player)
|
||||
{
|
||||
execute("High",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
||||
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
||||
Utilities.alert(alert);
|
||||
Utilities.alert(formatArray(lang.getHighAlert(),player,ChatColor.RED));
|
||||
}
|
||||
|
||||
public void increaseLevel(Player player)
|
||||
@@ -149,19 +146,34 @@ public class PlayerManager
|
||||
}
|
||||
else if(result.equalsIgnoreCase("KICK"))
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
||||
player.kickPlayer(formatString(lang.getKickReason(),player,ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(),player,ChatColor.RED));
|
||||
}
|
||||
else if(result.equalsIgnoreCase("WARN"))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
||||
String[] message = formatArray(lang.getWarning(),player,ChatColor.RED);
|
||||
for(String string : message)
|
||||
{
|
||||
player.sendMessage(string);
|
||||
}
|
||||
}
|
||||
else if(result.equalsIgnoreCase("BAN"))
|
||||
{
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
||||
player.kickPlayer(formatString(lang.getBanReason(),player,ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(),player,ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
private static String [] formatArray(String [] array, Player player, ChatColor color)
|
||||
{
|
||||
for(int i=0;i<array.length;i++)
|
||||
{
|
||||
array[i] = formatString(array[i],player,color);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
private static String formatString(String string, Player player, ChatColor color)
|
||||
{
|
||||
return color+string.replaceAll("&player", ChatColor.WHITE+player.getName()+color);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -102,7 +101,7 @@ public final class Utilities
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public static boolean isSubmersed(Player player)
|
||||
|
||||
Reference in new issue
Block a user