mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheatReloaded</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.6.0-ALPHA</version>
|
<version>1.6.1-ALPHA</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://rammelkast.com</url>
|
<url>https://rammelkast.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -45,177 +45,238 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|||||||
|
|
||||||
public class AntiCheat extends JavaPlugin {
|
public class AntiCheat extends JavaPlugin {
|
||||||
|
|
||||||
private static AntiCheatManager manager;
|
private static AntiCheatManager manager;
|
||||||
private static AntiCheat plugin;
|
private static AntiCheat plugin;
|
||||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean developer;
|
private static boolean developer;
|
||||||
private static ProtocolManager protocolManager;
|
private static ProtocolManager protocolManager;
|
||||||
private static boolean protocolLib = false;
|
private static boolean protocolLib = false;
|
||||||
private static Long loadTime;
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onEnable() {
|
||||||
verboseLog("Saving user levels...");
|
plugin = this;
|
||||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
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();
|
// Metrics
|
||||||
getServer().getScheduler().cancelTasks(this);
|
try {
|
||||||
cleanup();
|
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() {
|
@Override
|
||||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
public void onDisable() {
|
||||||
protocolLib = true;
|
verboseLog("Saving user levels...");
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||||
verboseLog("Hooked into ProtocolLib");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupEvents() {
|
AntiCheatManager.close();
|
||||||
for (Listener listener : eventList) {
|
getServer().getScheduler().cancelTasks(this);
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
cleanup();
|
||||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupCommands() {
|
private void setupProtocol() {
|
||||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
verboseLog("Registered commands.");
|
protocolLib = true;
|
||||||
}
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
verboseLog("Hooked into ProtocolLib");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupConfig() {
|
private void setupEvents() {
|
||||||
config = manager.getConfiguration();
|
for (Listener listener : eventList) {
|
||||||
verboseLog("Setup the config.");
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
}
|
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupEnterprise() {
|
private void setupCommands() {
|
||||||
if (config.getConfig().enterprise.getValue()) {
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
verboseLog("Registered commands.");
|
||||||
config.getEnterprise().database.cleanEvents();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreLevels() {
|
private void setupConfig() {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
config = manager.getConfiguration();
|
||||||
UUID uuid = player.getUniqueId();
|
verboseLog("Setup the config.");
|
||||||
|
}
|
||||||
|
|
||||||
User user = new User(uuid);
|
private void setupEnterprise() {
|
||||||
user.setIsWaitingOnLevelSync(true);
|
if (config.getConfig().enterprise.getValue()) {
|
||||||
config.getLevels().loadLevelToUser(user);
|
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||||
|
config.getEnterprise().database.cleanEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
manager.getUserManager().addUser(user);
|
private void restoreLevels() {
|
||||||
verboseLog("Data for " + uuid + " loaded");
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
}
|
UUID uuid = player.getUniqueId();
|
||||||
}
|
|
||||||
|
|
||||||
public static AntiCheat getPlugin() {
|
User user = new User(uuid);
|
||||||
return plugin;
|
user.setIsWaitingOnLevelSync(true);
|
||||||
}
|
config.getLevels().loadLevelToUser(user);
|
||||||
|
|
||||||
public static AntiCheatManager getManager() {
|
manager.getUserManager().addUser(user);
|
||||||
return manager;
|
verboseLog("Data for " + uuid + " loaded");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getVersion() {
|
public static AntiCheat getPlugin() {
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
public static AntiCheatManager getManager() {
|
||||||
eventList = null;
|
return manager;
|
||||||
manager = null;
|
}
|
||||||
config = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean developerMode() {
|
public static String getVersion() {
|
||||||
return developer;
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDeveloperMode(boolean b) {
|
private void cleanup() {
|
||||||
developer = b;
|
eventList = null;
|
||||||
}
|
manager = null;
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isUsingProtocolLib() {
|
public static boolean developerMode() {
|
||||||
return protocolLib;
|
return developer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(final String string) {
|
public static void setDeveloperMode(boolean b) {
|
||||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
developer = b;
|
||||||
public void run() {
|
}
|
||||||
if (developer) {
|
|
||||||
manager.debugLog("[DEBUG] " + string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void verboseLog(final String string) {
|
public static boolean isUsingProtocolLib() {
|
||||||
if (verbose) {
|
return protocolLib;
|
||||||
getLogger().info(string);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVerbose(boolean b) {
|
public static void debugLog(final String string) {
|
||||||
verbose = b;
|
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||||
}
|
public void run() {
|
||||||
|
if (developer) {
|
||||||
|
manager.debugLog("[DEBUG] " + string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public Long getLoadTime() {
|
public void verboseLog(final String string) {
|
||||||
return loadTime;
|
if (verbose) {
|
||||||
}
|
getLogger().info(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVerbose(boolean b) {
|
||||||
|
verbose = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLoadTime() {
|
||||||
|
return loadTime;
|
||||||
|
}
|
||||||
|
|
||||||
public static ProtocolManager getProtocolManager() {
|
public static ProtocolManager getProtocolManager() {
|
||||||
return protocolManager;
|
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 {
|
}else {
|
||||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||||
if (VL_COUNT.get(p.getUniqueId()) >= 5) {
|
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());
|
VL_COUNT.remove(p.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class BlinkCheck {
|
|||||||
public void run() {
|
public void run() {
|
||||||
MOVE_COUNT.clear();
|
MOVE_COUNT.clear();
|
||||||
}
|
}
|
||||||
}.runTaskTimer(AntiCheat.getPlugin(), 0, 20);
|
}.runTaskTimer(AntiCheat.getPlugin(), 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listenPackets() {
|
public static void listenPackets() {
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ public class UserManager {
|
|||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("KICK")) {
|
} else if (event.equalsIgnoreCase("KICK")) {
|
||||||
user.getPlayer().kickPlayer(RED + kickReason);
|
user.getPlayer().kickPlayer(RED + kickReason);
|
||||||
|
AntiCheat.getPlugin().onPlayerKicked();
|
||||||
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
||||||
if (!msg.equals("")) {
|
if (!msg.equals("")) {
|
||||||
manager.log(msg);
|
manager.log(msg);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public class NPC_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void damage() {
|
public void damage() {
|
||||||
if (this.npc == null) {
|
if (this.npc == null || this.getOwner() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (new Random().nextBoolean() && this.npc.isInvisible()) {
|
if (new Random().nextBoolean() && this.npc.isInvisible()) {
|
||||||
|
|||||||
Reference in new issue
Block a user