mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fixed stuff, added new metrics graphs
This commit is contained in:
1 parent
7f13a0ad4c
commit
09ddbfba8f
6 files changed
+213
-150
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||
<artifactId>AntiCheatReloaded</artifactId>
|
||||
<version>1.6.0-ALPHA</version>
|
||||
<version>1.6.1-ALPHA</version>
|
||||
<name>AntiCheatReloaded</name>
|
||||
<url>https://rammelkast.com</url>
|
||||
<properties>
|
||||
|
||||
@@ -45,177 +45,238 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class AntiCheat extends JavaPlugin {
|
||||
|
||||
private static AntiCheatManager manager;
|
||||
private static AntiCheat plugin;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static boolean developer;
|
||||
private static ProtocolManager protocolManager;
|
||||
private static boolean protocolLib = false;
|
||||
private static Long loadTime;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
loadTime = System.currentTimeMillis();
|
||||
manager = new AntiCheatManager(this, getLogger());
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
eventList.add(new EntityListener());
|
||||
eventList.add(new VehicleListener());
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
||||
setupConfig();
|
||||
setupEvents();
|
||||
setupCommands();
|
||||
setupProtocol();
|
||||
// Enterprise must come before levels
|
||||
setupEnterprise();
|
||||
restoreLevels();
|
||||
// Check if NoCheatPlus is installed
|
||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||
public void run() {
|
||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||
getLogger().severe("You are also running NoCheatPlus!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
||||
}else if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
|
||||
getLogger().severe("You are also running AAC!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable AAC to silence this warning.");
|
||||
}
|
||||
}
|
||||
}, 40L);
|
||||
// End tests
|
||||
verboseLog("Finished loading.");
|
||||
getLogger().info("Running version " + VersionUtil.getVersion() + "...");
|
||||
|
||||
// Enable packetlisteners
|
||||
KillAuraCheck.listenPackets();
|
||||
BlinkCheck.startTimer();
|
||||
BlinkCheck.listenPackets();
|
||||
|
||||
// Metrics
|
||||
try {
|
||||
new Metrics(this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static AntiCheatManager manager;
|
||||
private static AntiCheat plugin;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static boolean developer;
|
||||
private static ProtocolManager protocolManager;
|
||||
private static boolean protocolLib = false;
|
||||
private static Long loadTime;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
verboseLog("Saving user levels...");
|
||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
loadTime = System.currentTimeMillis();
|
||||
manager = new AntiCheatManager(this, getLogger());
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
eventList.add(new EntityListener());
|
||||
eventList.add(new VehicleListener());
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless
|
||||
// needed, especially config
|
||||
setupConfig();
|
||||
setupEvents();
|
||||
setupCommands();
|
||||
setupProtocol();
|
||||
// Enterprise must come before levels
|
||||
setupEnterprise();
|
||||
restoreLevels();
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
|
||||
// Enable packetlisteners
|
||||
KillAuraCheck.listenPackets();
|
||||
BlinkCheck.startTimer();
|
||||
BlinkCheck.listenPackets();
|
||||
}
|
||||
|
||||
// Check if other AC's are installed
|
||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||
public void run() {
|
||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running NoCheatPlus!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running AAC!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable AAC to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("AntiCheat") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running AntiCheat!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable AntiCheat to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
}
|
||||
}, 60L);
|
||||
|
||||
// End tests
|
||||
verboseLog("Finished loading.");
|
||||
getLogger().info("Running NMS version " + VersionUtil.getVersion() + "...");
|
||||
|
||||
AntiCheatManager.close();
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
cleanup();
|
||||
}
|
||||
// Metrics
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return playersKicked;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("killaura_violations") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return killauraViolations;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return glideViolations;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupProtocol() {
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
protocolLib = true;
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
verboseLog("Hooked into ProtocolLib");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
verboseLog("Saving user levels...");
|
||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
AntiCheatManager.close();
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
verboseLog("Registered commands.");
|
||||
}
|
||||
private void setupProtocol() {
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
protocolLib = true;
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
verboseLog("Hooked into ProtocolLib");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
verboseLog("Setup the config.");
|
||||
}
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEnterprise() {
|
||||
if (config.getConfig().enterprise.getValue()) {
|
||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||
config.getEnterprise().database.cleanEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void setupCommands() {
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
verboseLog("Registered commands.");
|
||||
}
|
||||
|
||||
private void restoreLevels() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
verboseLog("Setup the config.");
|
||||
}
|
||||
|
||||
User user = new User(uuid);
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(user);
|
||||
private void setupEnterprise() {
|
||||
if (config.getConfig().enterprise.getValue()) {
|
||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||
config.getEnterprise().database.cleanEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
manager.getUserManager().addUser(user);
|
||||
verboseLog("Data for " + uuid + " loaded");
|
||||
}
|
||||
}
|
||||
private void restoreLevels() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
public static AntiCheat getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
User user = new User(uuid);
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(user);
|
||||
|
||||
public static AntiCheatManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
manager.getUserManager().addUser(user);
|
||||
verboseLog("Data for " + uuid + " loaded");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
public static AntiCheat getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
eventList = null;
|
||||
manager = null;
|
||||
config = null;
|
||||
}
|
||||
public static AntiCheatManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static boolean developerMode() {
|
||||
return developer;
|
||||
}
|
||||
public static String getVersion() {
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
public static void setDeveloperMode(boolean b) {
|
||||
developer = b;
|
||||
}
|
||||
private void cleanup() {
|
||||
eventList = null;
|
||||
manager = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public static boolean isUsingProtocolLib() {
|
||||
return protocolLib;
|
||||
}
|
||||
public static boolean developerMode() {
|
||||
return developer;
|
||||
}
|
||||
|
||||
public static void debugLog(final String string) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||
public void run() {
|
||||
if (developer) {
|
||||
manager.debugLog("[DEBUG] " + string);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void setDeveloperMode(boolean b) {
|
||||
developer = b;
|
||||
}
|
||||
|
||||
public void verboseLog(final String string) {
|
||||
if (verbose) {
|
||||
getLogger().info(string);
|
||||
}
|
||||
}
|
||||
public static boolean isUsingProtocolLib() {
|
||||
return protocolLib;
|
||||
}
|
||||
|
||||
public void setVerbose(boolean b) {
|
||||
verbose = b;
|
||||
}
|
||||
public static void debugLog(final String string) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||
public void run() {
|
||||
if (developer) {
|
||||
manager.debugLog("[DEBUG] " + string);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Long getLoadTime() {
|
||||
return loadTime;
|
||||
}
|
||||
public void verboseLog(final String string) {
|
||||
if (verbose) {
|
||||
getLogger().info(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVerbose(boolean b) {
|
||||
verbose = b;
|
||||
}
|
||||
|
||||
public Long getLoadTime() {
|
||||
return loadTime;
|
||||
}
|
||||
|
||||
public static ProtocolManager getProtocolManager() {
|
||||
return protocolManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of players kicked since start
|
||||
*/
|
||||
private int playersKicked = 0;
|
||||
/**
|
||||
* Amount of killaura violations since start
|
||||
*/
|
||||
private int killauraViolations = 0;
|
||||
/**
|
||||
* Amount of glide violations since start
|
||||
*/
|
||||
private int glideViolations = 0;
|
||||
|
||||
public void onPlayerKicked() {
|
||||
this.playersKicked++;
|
||||
}
|
||||
|
||||
public void onKillAuraViolation() {
|
||||
this.killauraViolations++;
|
||||
}
|
||||
|
||||
public void onGlideViolation() {
|
||||
this.killauraViolations++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +56,8 @@ public class KillAuraCheck {
|
||||
}else {
|
||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(p.getUniqueId()) >= 5) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.BLINK);
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.KILLAURA);
|
||||
AntiCheat.getPlugin().onKillAuraViolation();
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class BlinkCheck {
|
||||
public void run() {
|
||||
MOVE_COUNT.clear();
|
||||
}
|
||||
}.runTaskTimer(AntiCheat.getPlugin(), 0, 20);
|
||||
}.runTaskTimer(AntiCheat.getPlugin(), 20, 20);
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
|
||||
@@ -229,6 +229,7 @@ public class UserManager {
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("KICK")) {
|
||||
user.getPlayer().kickPlayer(RED + kickReason);
|
||||
AntiCheat.getPlugin().onPlayerKicked();
|
||||
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
||||
if (!msg.equals("")) {
|
||||
manager.log(msg);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class NPC_1_11 {
|
||||
}
|
||||
|
||||
public void damage() {
|
||||
if (this.npc == null) {
|
||||
if (this.npc == null || this.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
if (new Random().nextBoolean() && this.npc.isInvisible()) {
|
||||
|
||||
Reference in new issue
Block a user