diff --git a/pom.xml b/pom.xml
index 2e0bb4e..6e22e09 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.rammelkast.anticheatreloaded
AntiCheatReloaded
- 1.9.5
+ alpha-2-b1
AntiCheatReloaded
https://www.spigotmc.org/resources/anticheatreloaded.23799/
@@ -70,12 +70,6 @@
ProtocolLib
4.6.0-SNAPSHOT
-
- org.spigotmc
- spigot
- 1.8.8-R0.1-SNAPSHOT
- provided
-
org.spigotmc
spigot
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java
deleted file mode 100644
index 1c58bcc..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded;
-
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Listener;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import com.comphenix.protocol.ProtocolLibrary;
-import com.comphenix.protocol.ProtocolManager;
-import com.rammelkast.anticheatreloaded.command.CommandHandler;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.event.BlockListener;
-import com.rammelkast.anticheatreloaded.event.EntityListener;
-import com.rammelkast.anticheatreloaded.event.InventoryListener;
-import com.rammelkast.anticheatreloaded.event.PlayerListener;
-import com.rammelkast.anticheatreloaded.event.VehicleListener;
-import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
-import com.rammelkast.anticheatreloaded.metrics.Metrics;
-import com.rammelkast.anticheatreloaded.util.PacketListener;
-import com.rammelkast.anticheatreloaded.util.UpdateManager;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class AntiCheatReloaded extends JavaPlugin {
-
- public static final List MUTE_ENABLED_MODS = new ArrayList();
-
- private static AntiCheatManager manager;
- private static AntiCheatReloaded plugin;
- private static List eventList = new ArrayList();
- private static Configuration config;
- private static boolean verbose;
- private static ProtocolManager protocolManager;
- private static SecureRandom random;
- private static Long loadTime;
- private static UpdateManager updateManager;
-
- private double tps = -1;
- private String symbiosisMetric = "None";
-
- @Override
- public void onEnable() {
- plugin = this;
- random = new SecureRandom();
- 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
- this.setupConfig();
- this.setupEvents();
- this.setupCommands();
- // Enterprise must come before levels
- this.setupEnterprise();
- this.restoreLevels();
-
- if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
- this.setupProtocol();
- } else {
- Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.RED
- + "Could not find ProtocolLib. Shutting down!");
- Bukkit.getPluginManager().disablePlugin(this);
- return;
- }
-
- Bukkit.getConsoleSender()
- .sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY
- + "Running Minecraft version " + VersionUtil.getVersion() + " "
- + (VersionUtil.isSupported() ? (ChatColor.GREEN + "(supported)")
- : (ChatColor.RED + "(NOT SUPPORTED!)")));
-
- getLogger().info("Enabling packet listeners");
- PacketListener.listenMovementPackets();
- PacketListener.listenKeepAlivePackets();
- PacketListener.listenUseItemPackets();
-
- updateManager = new UpdateManager();
-
- // End tests
- verboseLog("Finished loading.");
-
- // Metrics
- getServer().getScheduler().runTaskLater(this, new Runnable() {
- @Override
- public void run() {
- checkForSymbiosis();
- try {
- Metrics metrics = new Metrics(AntiCheatReloaded.this, 202);
- metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable() {
- @Override
- public Integer call() throws Exception {
- int kicked = playersKicked;
- // Reset so we don't keep sending the same value
- playersKicked = 0;
- return kicked;
- }
- }));
- metrics.addCustomChart(new Metrics.SimplePie("protocollib_version", new Callable() {
- @Override
- public String call() throws Exception {
- return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
- }
- }));
- metrics.addCustomChart(new Metrics.SimplePie("nms_version", new Callable() {
- @Override
- public String call() throws Exception {
- return VersionUtil.getVersion();
- }
- }));
- metrics.addCustomChart(new Metrics.SimplePie("symbiosis", new Callable() {
- @Override
- public String call() throws Exception {
- return symbiosisMetric;
- }
- }));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, 90L);
-
- // Launch TPS check
- new BukkitRunnable() {
- long sec;
- long currentSec;
- int ticks;
-
- public void run() {
- sec = (System.currentTimeMillis() / 1000L);
- if (currentSec == sec) {
- ticks += 1;
- } else {
- currentSec = sec;
- tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
- ticks = 1;
- }
-
- // Check for updates every 12 hours
- if (ticks % 864000 == 0)
- updateManager.update();
- }
- }.runTaskTimer(this, 40L, 1L);
- }
-
- @Override
- public void onDisable() {
- verboseLog("Saving user levels...");
- config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
-
- AntiCheatManager.close();
- getServer().getScheduler().cancelTasks(this);
- cleanup();
- }
-
- private void setupProtocol() {
- protocolManager = ProtocolLibrary.getProtocolManager();
- verboseLog("Hooked into ProtocolLib");
- }
-
- 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 setupCommands() {
- getCommand("anticheat").setExecutor(new CommandHandler());
- verboseLog("Registered commands.");
- }
-
- private void setupConfig() {
- config = manager.getConfiguration();
- verboseLog("Setup the config.");
- }
-
- private void setupEnterprise() {
- if (config.getConfig().enterprise.getValue()) {
- if (config.getEnterprise().loggingEnabled.getValue()) {
- config.getEnterprise().database.cleanEvents();
- }
- }
- }
-
- private void restoreLevels() {
- for (Player player : getServer().getOnlinePlayers()) {
- UUID uuid = player.getUniqueId();
-
- User user = new User(uuid);
- user.setIsWaitingOnLevelSync(true);
- config.getLevels().loadLevelToUser(user);
-
- manager.getUserManager().addUser(user);
- verboseLog("Data for " + uuid + " loaded");
- }
- }
-
- public static AntiCheatReloaded getPlugin() {
- return plugin;
- }
-
- public static AntiCheatManager getManager() {
- return manager;
- }
-
- public static SecureRandom getRandom() {
- return random;
- }
-
- public static String getVersion() {
- return manager.getPlugin().getDescription().getVersion();
- }
-
- private void cleanup() {
- eventList = null;
- manager = null;
- config = null;
- }
-
- public static void debugLog(final String string) {
- Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
- public void run() {
- if (getManager().getConfiguration().getConfig().debugMode.getValue()) {
- manager.debugLog("[DEBUG] " + string);
- }
- }
- });
- }
-
- 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;
-
- public void onPlayerKicked() {
- this.playersKicked++;
- }
-
- /**
- * Creates metric that checks for anti-cheat symbiosis
- * I use this to see if AntiCheatReloaded is actively being used
- * together with other anti-cheats, so I can account for that.
- */
- protected void checkForSymbiosis() {
- if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
- if (this.symbiosisMetric.equals("None")) {
- this.symbiosisMetric = "NoCheatPlus";
- } else {
- this.symbiosisMetric += ", NoCheatPlus";
- }
- }
- if (Bukkit.getPluginManager().getPlugin("Matrix") != null) {
- if (this.symbiosisMetric.equals("None")) {
- this.symbiosisMetric = "Matrix";
- } else {
- this.symbiosisMetric += ", Matrix";
- }
- }
- if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
- if (this.symbiosisMetric.equals("None")) {
- this.symbiosisMetric = "AAC";
- } else {
- this.symbiosisMetric += ", AAC";
- }
- }
- if (Bukkit.getPluginManager().getPlugin("Spartan") != null) {
- if (this.symbiosisMetric.equals("None")) {
- this.symbiosisMetric = "Spartan";
- } else {
- this.symbiosisMetric += ", Spartan";
- }
- }
- if (Bukkit.getPluginManager().getPlugin("Negativity") != null) {
- if (this.symbiosisMetric.equals("None")) {
- this.symbiosisMetric = "Negativity";
- } else {
- this.symbiosisMetric += ", Negativity";
- }
- }
- }
-
- public static void sendToMainThread(Runnable runnable) {
- Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
- }
-
- public void sendToStaff(String message) {
- Bukkit.getOnlinePlayers().forEach(player -> {
- if (player.hasPermission("anticheat.system.alert")) {
- if (!MUTE_ENABLED_MODS.contains(player.getUniqueId())) {
- player.sendMessage(message);
- }
- }
- });
- }
-
- public static UpdateManager getUpdateManager() {
- return updateManager;
- }
-
- public double getTPS() {
- if (this.tps < 0 || this.tps > 20) {
- return 20;
- }
- return this.tps;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/api/AntiCheatAPI.java b/src/main/java/com/rammelkast/anticheatreloaded/api/AntiCheatAPI.java
deleted file mode 100644
index 0cb26b1..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/api/AntiCheatAPI.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.api;
-
-import java.util.List;
-
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
-import com.rammelkast.anticheatreloaded.manage.CheckManager;
-import com.rammelkast.anticheatreloaded.manage.UserManager;
-import com.rammelkast.anticheatreloaded.util.Group;
-
-/**
- * Developer's interface for all things AntiCheat.
- */
-
-public class AntiCheatAPI {
- private static CheckManager chk = AntiCheatReloaded.getManager().getCheckManager();
- private static UserManager umr = AntiCheatReloaded.getManager().getUserManager();
-
- // CheckManager API
-
- /**
- * Start running a certain check
- *
- * @param type Check to start watching for
- */
- public static void activateCheck(CheckType type, Class> caller) {
- chk.activateCheck(type, caller.getName());
- }
-
- /**
- * Stop running a certain check
- *
- * @param type Check to stop watching for
- */
- public static void deactivateCheck(CheckType type, Class> caller) {
- chk.deactivateCheck(type, caller.getName());
- }
-
- /**
- * Find out if a check is currently being watched for
- *
- * @param type Type to check
- * @return true if plugin is watching for this check
- */
- public static boolean isActive(CheckType type) {
- return chk.isActive(type);
- }
-
- /**
- * Allow a player to skip a certain check
- *
- * @param player Player to stop watching
- * @param type Check to stop watching for
- */
- public static void exemptPlayer(Player player, CheckType type, Class> caller) {
- chk.exemptPlayer(player, type, caller.getName());
- }
-
- /**
- * Stop allowing a player to skip a certain check
- *
- * @param player Player to start watching
- * @param type Check to start watching for
- */
- public static void unexemptPlayer(Player player, CheckType type, Class> caller) {
- chk.unexemptPlayer(player, type, caller.getName());
- }
-
- /**
- * Find out if a player is currently exempt from a certain check
- *
- * @param player Player to check
- * @param type Type to check
- * @return true if plugin is ignoring this check on this player
- */
- public static boolean isExempt(Player player, CheckType type) {
- return chk.isExempt(player, type);
- }
-
- /**
- * Find out if a check will occur for a player. This checks if they are being tracked, the check is active, the player isn't exempt from the check, and the player doesn't have override permission.
- *
- * @param player Player to check
- * @param type Type to check
- * @return true if plugin will check this player, and that all things allow it to happen.
- */
- public boolean willCheck(Player player, CheckType type) {
- return chk.willCheck(player, type);
- }
-
- // PlayerManager API
-
- /**
- * Reset a player's hack level to 0
- *
- * @param player Player to reset
- */
- public static void resetPlayer(Player player) {
- umr.getUser(player.getUniqueId()).resetLevel();
- }
-
- /**
- * Get a user's {@link com.rammelkast.anticheatreloaded.util.Group}
- *
- * @param player Player whose group to find
- * @return The player's group
- */
- public static Group getGroup(Player player) {
- return umr.getUser(player.getUniqueId()).getGroup();
- }
-
- /**
- * Get all configured Groups
- *
- * @return List of all groups
- * @see com.rammelkast.anticheatreloaded.util.Group
- */
- public static List getGroups() {
- return getManager().getConfiguration().getGroups().getGroups();
- }
-
- // Advanced Users Only API.
-
- /**
- * Get access to all the other managers, advanced users ONLY
- *
- * @return the AntiCheat Manager
- */
- public static AntiCheatManager getManager() {
- return AntiCheatReloaded.getManager();
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java b/src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java
deleted file mode 100644
index 242ba64..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.api;
-
-import org.bukkit.event.Event;
-import org.bukkit.event.HandlerList;
-
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.util.User;
-
-/**
- * Fired when a player fails an AntiCheat check
- */
-
-public class CheckFailEvent extends Event {
-
- private static final HandlerList handlers = new HandlerList();
-
- private final User user;
- private final CheckType type;
-
- public CheckFailEvent(User user, CheckType type) {
- this.user = user;
- this.type = type;
- }
-
- /**
- * Get the {@link com.rammelkast.anticheatreloaded.util.User} who failed the check
- *
- * @return a {@link com.rammelkast.anticheatreloaded.util.User}
- */
- public User getUser() {
- return user;
- }
-
- /**
- * Get the {@link com.rammelkast.anticheatreloaded.check.CheckType} failed
- *
- * @return a {@link com.rammelkast.anticheatreloaded.check.CheckType}
- */
- public CheckType getCheck() {
- return type;
- }
-
- public HandlerList getHandlers() {
- return handlers;
- }
-
- public static HandlerList getHandlerList() {
- return handlers;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java
deleted file mode 100644
index 7ac195c..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.UUID;
-
-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.entity.Player;
-import org.bukkit.event.player.PlayerToggleSprintEvent;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
-import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
-import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
-import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
-import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
-import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
-import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.config.providers.Lang;
-import com.rammelkast.anticheatreloaded.config.providers.Magic;
-import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class Backend {
- public Map velocitized = new HashMap();
- private Map levitatingEnd = new HashMap();
- private Map chatLevel = new HashMap();
- private Map commandLevel = new HashMap();
- private Map nofallViolation = new HashMap();
- private Map blockBreakHolder = new HashMap();
- private Map fastPlaceViolation = new HashMap();
- private Map lastBlockPlaced = new HashMap();
- private Map lastBlockPlaceTime = new HashMap();
- private Map blockPunches = new HashMap();
- private Map projectilesShot = new HashMap();
- private Map velocitytrack = new HashMap();
- private Map startEat = new HashMap();
- private Map lastHeal = new HashMap();
- private Map projectileTime = new HashMap();
- private Map bowWindUp = new HashMap();
- private Map sprinted = new HashMap();
- private Map brokenBlock = new HashMap();
- public Map placedBlock = new HashMap();
- private Map blockTime = new HashMap();
- private Map blocksDropped = new HashMap();
- private Map lastInventoryTime = new HashMap();
- private Map inventoryTime = new HashMap();
- private Map inventoryClicks = new HashMap();
- private HashSet transparent = new HashSet();
- private Map lastFallPacket = new HashMap();
- private Map fastSneakViolations = new HashMap();
- private Map lastSneak = new HashMap();
-
- private Magic magic;
- private Checks checksConfig;
- private AntiCheatManager manager = null;
- private Lang lang = null;
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public Backend(AntiCheatManager instance) {
- magic = instance.getConfiguration().getMagic();
- checksConfig = instance.getConfiguration().getChecks();
- manager = instance;
- lang = manager.getConfiguration().getLang();
- transparent.add((byte) -1);
- }
-
- public Magic getMagic() {
- return magic;
- }
-
- public void updateConfig(Configuration config) {
- magic = config.getMagic();
- lang = config.getLang();
- }
-
- public void resetChatLevel(User user) {
- chatLevel.put(user.getUUID(), 0);
- }
-
- public void garbageClean(Player player) {
- UUID uuid = player.getUniqueId();
-
- blocksDropped.remove(uuid);
- blockTime.remove(uuid);
- brokenBlock.remove(uuid);
- placedBlock.remove(uuid);
- bowWindUp.remove(uuid);
- startEat.remove(uuid);
- lastHeal.remove(uuid);
- sprinted.remove(uuid);
- nofallViolation.remove(uuid);
- blockBreakHolder.remove(uuid);
- fastPlaceViolation.remove(uuid);
- lastBlockPlaced.remove(uuid);
- lastBlockPlaceTime.remove(uuid);
- blockPunches.remove(uuid);
- projectilesShot.remove(uuid);
- velocitized.remove(uuid);
- velocitytrack.remove(uuid);
- startEat.remove(uuid);
- lastHeal.remove(uuid);
- projectileTime.remove(uuid);
- bowWindUp.remove(uuid);
- sprinted.remove(uuid);
- brokenBlock.remove(uuid);
- placedBlock.remove(uuid);
- blockTime.remove(uuid);
- blocksDropped.remove(uuid);
- lastInventoryTime.remove(uuid);
- inventoryTime.remove(uuid);
- inventoryClicks.remove(uuid);
- lastFallPacket.remove(uuid);
- fastSneakViolations.remove(uuid);
- lastSneak.remove(uuid);
- levitatingEnd.remove(uuid);
- AimbotCheck.LAST_DELTA_YAW.remove(uuid);
- VelocityCheck.VIOLATIONS.remove(uuid);
- MorePacketsCheck.LAST_PACKET_TIME.remove(uuid);
- MorePacketsCheck.PACKET_BALANCE.remove(uuid);
- MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
- ElytraCheck.JUMP_Y_VALUE.remove(uuid);
- KillAuraCheck.ANGLE_FLAGS.remove(uuid);
- KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
- FlightCheck.MOVING_EXEMPT.remove(uuid);
- NoSlowCheck.LAST_RELEASE.remove(uuid);
- NoSlowCheck.VIOLATIONS.remove(uuid);
- }
-
- public CheckResult checkFastBow(Player player, float force) {
- // Ignore magic numbers here, they are minecrafty vanilla stuff.
- if (!bowWindUp.containsKey(player.getUniqueId())) {
- return PASS;
- }
- int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3);
- bowWindUp.remove(player.getUniqueId());
- float f = (float) ticks / 20.0F;
- f = (f * f + f * 2.0F) / 3.0F;
- f = f > 1.0F ? 1.0F : f;
- double bowError = checksConfig.getDouble(CheckType.FAST_BOW, "bowError");
- if (Math.abs(force - f) > bowError) {
- return new CheckResult(CheckResult.Result.FAILED,
- "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
- } else {
- return PASS;
- }
- }
-
- public CheckResult checkProjectile(Player player) {
- incrementOld(player, projectilesShot, 10);
- int projectilesToWait = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "projectilesToWait");
- if (!projectileTime.containsKey(player.getUniqueId())) {
- projectileTime.put(player.getUniqueId(), System.currentTimeMillis());
- return new CheckResult(CheckResult.Result.PASSED);
- } else if (projectilesShot.get(player.getUniqueId()) == projectilesToWait) {
- long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId());
- int minimumTime = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "minimumTime");
- projectileTime.remove(player.getUniqueId());
- projectilesShot.remove(player.getUniqueId());
- if (time < minimumTime) {
- return new CheckResult(CheckResult.Result.FAILED,
- "wound up a bow too fast (actual time=" + time + ", min time=" + minimumTime + ")");
- }
- }
- return PASS;
- }
-
- public CheckResult checkFastDrop(Player player) {
- incrementOld(player, blocksDropped, 10);
- int dropsToWait = checksConfig.getInteger(CheckType.ITEM_SPAM, "dropsToWait");
- if (!blockTime.containsKey(player.getUniqueId())) {
- blockTime.put(player.getUniqueId(), System.currentTimeMillis());
- return new CheckResult(CheckResult.Result.PASSED);
- } else if (blocksDropped.get(player.getUniqueId()) == dropsToWait) {
- long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId());
- int minimumTime = checksConfig.getInteger(CheckType.ITEM_SPAM, "minimumTime");
- blockTime.remove(player.getUniqueId());
- blocksDropped.remove(player.getUniqueId());
- if (time < minimumTime) {
- return new CheckResult(CheckResult.Result.FAILED,
- "dropped an item too fast (actual time=" + time + ", min time=" + minimumTime + ")");
- }
- }
- return PASS;
- }
-
- public CheckResult checkSpider(Player player, double y) {
- if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock())
- && !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
- && !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
- && !Utilities.isNearClimbable(player)) {
- return new CheckResult(CheckResult.Result.FAILED,
- "tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")");
- } else {
- return PASS;
- }
- }
-
- public CheckResult checkNoFall(Player player, double y) {
- UUID uuid = player.getUniqueId();
- if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
- && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
- && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
- && !VersionUtil.isSlowFalling(player) && !Utilities
- .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) && !Utilities.isNearClimbable(player)) {
- if (player.getFallDistance() == 0) {
- if (nofallViolation.get(uuid) == null) {
- nofallViolation.put(uuid, 1);
- } else {
- nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1);
- }
-
- int i = nofallViolation.get(uuid);
- int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
- if (i >= vlBeforeFlag) {
- nofallViolation.put(player.getUniqueId(), 1);
- return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 "
- + i + " times in a row, max=" + vlBeforeFlag + ")");
- } else {
- return PASS;
- }
- } else {
- nofallViolation.put(uuid, 0);
- return PASS;
- }
- }
- return PASS;
- }
-
- public CheckResult checkSneakToggle(Player player) {
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- final long lastSneak = this.lastSneak.getOrDefault(player.getUniqueId(), (long) 0);
- this.lastSneak.put(player.getUniqueId(), System.currentTimeMillis());
- if (System.currentTimeMillis() - lastSneak < checksConfig.getInteger(CheckType.SNEAK, "minToggleTime")
- && (AntiCheatReloaded.getPlugin().getTPS() > checksConfig.getInteger(CheckType.SNEAK, "minimumTps"))) {
- if (user.isLagging() && checksConfig.getBoolean(CheckType.SNEAK, "disableForLagging"))
- return PASS;
-
- if (!this.silentMode())
- player.teleport(user.getGoodLocation(player.getLocation()));
-
- return new CheckResult(Result.FAILED,
- "toggled sneak too fast (time=" + (System.currentTimeMillis() - lastSneak) + ")");
- }
- return PASS;
- }
-
- public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
- Player player = event.getPlayer();
- int sprintFoodMin = checksConfig.getInteger(CheckType.SPRINT, "sprintFoodMin");
- if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE
- && player.getFoodLevel() <= sprintFoodMin) {
- return new CheckResult(CheckResult.Result.FAILED,
- "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + sprintFoodMin + ")");
- } else {
- return PASS;
- }
- }
-
- public CheckResult checkVClip(Player player, Distance distance) {
- double from = Math.round(distance.fromY());
- double to = Math.round(distance.toY());
-
- if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) {
- return PASS;
- }
-
- for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) {
- Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i,
- player.getLocation().getZ()).getBlock();
- if (block.getType() != Material.AIR && block.getType().isSolid()) {
- return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block",
- (int) from + 3);
- }
- }
-
- return PASS;
- }
-
- public CheckResult checkFastPlace(Player player) {
- int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival");
- int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative");
- int blockPlacementTime = checksConfig.getInteger(CheckType.FAST_PLACE, "blockPlacementTime");
- int violations = player.getGameMode() == GameMode.CREATIVE ? vlBeforeFlagCreative : vlBeforeFlagSurvival;
- long time = System.currentTimeMillis();
- UUID uuid = player.getUniqueId();
- if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
- lastBlockPlaceTime.put(uuid, 0L);
- if (!fastPlaceViolation.containsKey(uuid)) {
- fastPlaceViolation.put(uuid, 0);
- }
- } else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
- Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
- if (lastBlockPlaced.get(uuid) > 0 && math < blockPlacementTime) {
- lastBlockPlaced.put(uuid, time);
- return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
- + fastPlaceViolation.get(uuid) + " times in a row (max=" + violations + ")");
- } else if (lastBlockPlaced.get(uuid) > 0 && math > blockPlacementTime) {
- fastPlaceViolation.put(uuid, 0);
- }
- } else if (lastBlockPlaced.containsKey(uuid)) {
- long last = lastBlockPlaced.get(uuid);
- long lastTime = lastBlockPlaceTime.get(uuid);
- long thisTime = time - last;
- int minimumTime = checksConfig.getInteger(CheckType.FAST_PLACE, "minimumTime");
-
- if (lastTime != 0 && thisTime < minimumTime) {
- lastBlockPlaceTime.put(uuid, (time - last));
- lastBlockPlaced.put(uuid, time);
- fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
- return new CheckResult(CheckResult.Result.FAILED,
- "tried to place a block " + thisTime + " ms after the last one (min=" + minimumTime + " ms)");
- }
- lastBlockPlaceTime.put(uuid, (time - last));
- }
- lastBlockPlaced.put(uuid, time);
- return PASS;
- }
-
- public void logBowWindUp(Player player) {
- bowWindUp.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public void logEatingStart(Player player) {
- startEat.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public boolean isEating(Player player) {
- return startEat.containsKey(player.getUniqueId())
- && startEat.get(player.getUniqueId()) < checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin");
- }
-
- public void logHeal(Player player) {
- lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public CheckResult checkChatSpam(Player player, String msg) {
- UUID uuid = player.getUniqueId();
- User user = manager.getUserManager().getUser(uuid);
- if (user.getLastMessageTime() != -1) {
- for (int i = 0; i < 2; i++) {
- String m = user.getMessage(i);
- if (m == null) {
- break;
- }
- Long l = user.getMessageTime(i);
-
- int repeatIgnore = checksConfig.getInteger(CheckType.CHAT_SPAM, "repeatIgnore");
- if (System.currentTimeMillis() - l > repeatIgnore) {
- user.clearMessages();
- break;
- } else {
- int timeMin = checksConfig.getInteger(CheckType.CHAT_SPAM, "timeMin");
- if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue()
- && m.equalsIgnoreCase(msg) && i == 1) {
- manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
- return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
- } else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue()
- && System.currentTimeMillis() - user.getLastCommandTime() < timeMin) {
- manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
- return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
- }
- }
- }
- }
- user.addMessage(msg);
- return PASS;
- }
-
- public CheckResult checkChatUnicode(Player player, String msg) {
- UUID uuid = player.getUniqueId();
- User user = manager.getUserManager().getUser(uuid);
- for (char ch : msg.toCharArray()) {
- if (Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.BASIC_LATIN
- && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_1_SUPPLEMENT
- && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_EXTENDED_A
- && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.GENERAL_PUNCTUATION
- && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.CYRILLIC
- && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.CYRILLIC_EXTENDED_A) {
- return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
- }
- }
- user.addMessage(msg);
- return PASS;
- }
-
- public CheckResult checkCommandSpam(Player player, String cmd) {
- UUID uuid = player.getUniqueId();
- User user = manager.getUserManager().getUser(uuid);
- if (user.getLastCommandTime() != -1) {
- for (int i = 0; i < 2; i++) {
- String m = user.getCommand(i);
- if (m == null) {
- break;
- }
- Long l = user.getCommandTime(i);
-
- int repeatIgnore = checksConfig.getInteger(CheckType.COMMAND_SPAM, "repeatIgnore");
- if (System.currentTimeMillis() - l > repeatIgnore) {
- user.clearCommands();
- break;
- } else {
- int timeMin = checksConfig.getInteger(CheckType.COMMAND_SPAM, "timeMin");
- if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue()
- && m.equalsIgnoreCase(cmd) && i == 1) {
- return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
- } else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue()
- && System.currentTimeMillis() - user.getLastCommandTime() < timeMin) {
- return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
- }
- }
- }
- }
- user.addCommand(cmd);
- return PASS;
- }
-
- public CheckResult checkInventoryClicks(Player player) {
- if (player.getGameMode() == GameMode.CREATIVE) {
- return PASS;
- }
- UUID uuid = player.getUniqueId();
- int clicks = 1;
- if (inventoryClicks.containsKey(uuid)) {
- clicks = inventoryClicks.get(uuid) + 1;
- }
- inventoryClicks.put(uuid, clicks);
- int clicksToWait = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait");
- if (clicks == 1) {
- inventoryTime.put(uuid, System.currentTimeMillis());
- } else if (clicks == clicksToWait) {
- int minimumTime = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait");
- long time = System.currentTimeMillis() - inventoryTime.get(uuid);
- inventoryClicks.put(uuid, 0);
- if (time < minimumTime) {
- return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in "
- + time + " ms (max=" + clicksToWait + " in " + minimumTime + " ms)");
- }
- }
- return PASS;
- }
-
- public CheckResult checkFastHeal(Player player) {
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
- {
- double tps = AntiCheatReloaded.getPlugin().getTPS();
- if (tps < checksConfig.getDouble(CheckType.FAST_HEAL, "minimumTps")
- || (user.isLagging() && checksConfig.getBoolean(CheckType.FAST_HEAL, "disableForLagging"))) {
- return PASS;
- }
- long minHealTime = checksConfig.getInteger(CheckType.FAST_HEAL, "minHealTime");
- long lastHealTime = lastHeal.get(player.getUniqueId());
- int ping = user.getPing();
- double pingCompensation = checksConfig.getInteger(CheckType.FAST_HEAL, "pingCompensation");
- long allowedHealTime = (long) (minHealTime - (ping * pingCompensation));
- lastHeal.remove(player.getUniqueId());
- if ((System.currentTimeMillis() - lastHealTime) < allowedHealTime) {
- return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time="
- + (System.currentTimeMillis() - lastHealTime) + " ms, min=" + allowedHealTime + " ms)");
- }
- }
- return PASS;
- }
-
- public CheckResult checkFastEat(Player player) {
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
- {
- if (AntiCheatReloaded.getPlugin().getTPS() < 17.5 || user.isLagging()) {
- return PASS;
- }
- long l = startEat.get(player.getUniqueId());
- startEat.remove(player.getUniqueId());
- int eatTimeMin = checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin");
- if ((System.currentTimeMillis() - l) < eatTimeMin) {
- return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time="
- + (System.currentTimeMillis() - l) + " ms, min=" + eatTimeMin + " ms)");
- }
- }
- return PASS;
- }
-
- public void logSprint(final Player player) {
- sprinted.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public void logBlockBreak(final Player player) {
- brokenBlock.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public boolean justBroke(Player player) {
- // TODO config??
- return isDoing(player, brokenBlock, 0.1);
- }
-
- public void logVelocity(final Player player) {
- velocitized.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public void logLevitating(final Player player, final int duration) {
- levitatingEnd.put(player.getUniqueId(), System.currentTimeMillis() + (duration * 1000L));
- }
-
- public boolean justVelocity(Player player) {
- return (velocitized.containsKey(player.getUniqueId())
- ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_TIME()
- : false);
- }
-
- public boolean justLevitated(Player player) {
- return (levitatingEnd.containsKey(player.getUniqueId())
- ? (System.currentTimeMillis() - levitatingEnd.get(player.getUniqueId())) < magic.VELOCITY_TIME()
- : false);
- }
-
- public boolean extendVelocityTime(final Player player) {
- if (velocitytrack.containsKey(player.getUniqueId())) {
- velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
- if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
- velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
- manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(),
- new Runnable() {
- @Override
- public void run() {
- velocitytrack.put(player.getUniqueId(), 0);
- }
- }, magic.VELOCITY_EXTENSION() * 20L);
- return true;
- }
- } else {
- velocitytrack.put(player.getUniqueId(), 0);
- }
-
- return false;
- }
-
- public void logBlockPlace(final Player player) {
- placedBlock.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- public boolean justPlaced(Player player) {
- // TODO config??
- return isDoing(player, placedBlock, 0.1);
- }
-
- public void logDamage(final Player player, int type) {
- long time;
- switch (type) {
- case 1:
- time = magic.DAMAGE_TIME();
- break;
- case 2:
- time = magic.KNOCKBACK_DAMAGE_TIME();
- break;
- case 3:
- time = magic.EXPLOSION_DAMAGE_TIME();
- break;
- default:
- time = magic.DAMAGE_TIME();
- break;
-
- }
- FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time);
- // Only map in which termination time is calculated beforehand.
- }
-
- public void logEnterExit(final Player player) {
- FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
- }
-
- public void logTeleport(final Player player) {
- manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System
- .currentTimeMillis();
- /* Data for fly/speed should be reset */
- nofallViolation.remove(player.getUniqueId());
- ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
- }
-
- public void logBoatCollision(final Player player) {
- // TODO config??
- FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
- }
-
- public void logJoin(final Player player) {
- FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
- MorePacketsCheck.EXEMPT_TIMINGS.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
- }
-
- public boolean isMovingExempt(Player player) {
- return isDoing(player, FlightCheck.MOVING_EXEMPT, -1);
- }
-
- public boolean isDoing(Player player, Map map, double max) {
- if (map.containsKey(player.getUniqueId())) {
- if (max != -1) {
- if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
- map.remove(player.getUniqueId());
- return false;
- } else {
- return true;
- }
- } else {
- // Termination time has already been calculated
- if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
- map.remove(player.getUniqueId());
- return false;
- } else {
- return true;
- }
- }
- } else {
- return false;
- }
- }
-
- public boolean hasJumpPotion(Player player) {
- return player.hasPotionEffect(PotionEffectType.JUMP);
- }
-
- public boolean hasSpeedPotion(Player player) {
- return player.hasPotionEffect(PotionEffectType.SPEED);
- }
-
- public void processChatSpammer(Player player) {
- User user = manager.getUserManager().getUser(player.getUniqueId());
- int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
- int levelActionOne = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionOne");
- int levelActionTwo = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionTwo");
- if (player != null && player.isOnline() && level >= levelActionOne) {
- String event = level >= levelActionTwo ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue()
- : manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
- manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
- Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(),
- Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
- }
- chatLevel.put(user.getUUID(), level + 1);
- }
-
- public void processCommandSpammer(Player player) {
- User user = manager.getUserManager().getUser(player.getUniqueId());
- int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
- int levelActionOne = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionOne");
- int levelActionTwo = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionTwo");
- if (player != null && player.isOnline() && level >= levelActionOne) {
- String event = level >= levelActionTwo
- ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue()
- : manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
- manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
- Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(),
- Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
- }
- commandLevel.put(user.getUUID(), level + 1);
- }
-
- public int increment(Player player, Map map, int num) {
- UUID name = player.getUniqueId();
- if (map.get(name) == null) {
- map.put(name, 1);
- return 1;
- } else {
- int amount = map.get(name) + 1;
- if (amount < num + 1) {
- map.put(name, amount);
- return amount;
- } else {
- map.put(name, num);
- return num;
- }
- }
- }
-
- public int incrementOld(Player player, Map map, int num) {
- UUID uuid = player.getUniqueId();
- if (map.get(uuid) == null) {
- map.put(uuid, 1);
- return 1;
- } else {
- int amount = map.get(uuid) + 1;
- if (amount < num + 1) {
- map.put(uuid, amount);
- return amount;
- } else {
- map.put(uuid, num);
- return num;
- }
- }
- }
-
- public boolean silentMode() {
- return manager.getConfiguration().getConfig().silentMode.getValue();
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckResult.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckResult.java
deleted file mode 100644
index 7c8366a..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckResult.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.check;
-
-public class CheckResult {
-
- public enum Result {
- PASSED, FAILED
- }
-
- private Result result;
- private String subCheck;
- private String message;
- private int data;
-
- public CheckResult(Result result, String message, int data) {
- this(result, message);
- this.data = data;
- }
-
- public CheckResult(Result result, String subcheck, String message) {
- this(result);
- this.subCheck = subcheck;
- this.message = message;
- }
-
- public CheckResult(Result result, String message) {
- this(result);
- this.message = message;
- }
-
- public CheckResult(Result result) {
- this.result = result;
- }
-
- public boolean failed() {
- return result == Result.FAILED;
- }
-
- public String getSubCheck() {
- return subCheck;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Result getResult() {
- return result;
- }
-
- public int getData() {
- return data;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java
deleted file mode 100644
index 96fe8a0..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.check;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
-import com.rammelkast.anticheatreloaded.util.Permission;
-import com.rammelkast.anticheatreloaded.util.User;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- *
- * All the types of checks and their corresponding permission nodes.
- */
-
-public enum CheckType {
- FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
- ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"),
- WATER_WALK(Permission.CHECK_WATERWALK, "WaterWalk"),
- FAST_PLACE(Permission.CHECK_FASTPLACE, "FastPlace"),
- CHAT_SPAM(Permission.CHECK_CHATSPAM, "ChatSpam"),
- COMMAND_SPAM(Permission.CHECK_COMMANDSPAM, "CommandSpam"),
- SPRINT(Permission.CHECK_SPRINT, "Sprint"),
- SNEAK(Permission.CHECK_SNEAK, "Sneak"),
- SPEED(Permission.CHECK_SPEED, "Speed"),
- VCLIP(Permission.CHECK_VCLIP, "vClip"),
- SPIDER(Permission.CHECK_SPIDER, "Spider"),
- NOFALL(Permission.CHECK_NOFALL, "NoFall"),
- FAST_BOW(Permission.CHECK_FASTBOW, "FastBow"),
- FAST_EAT(Permission.CHECK_FASTEAT, "FastEat"),
- FAST_HEAL(Permission.CHECK_FASTHEAL, "FastHeal"),
- KILLAURA(Permission.CHECK_KILLAURA, "KillAura"),
- FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE, "FastProjectile"),
- ITEM_SPAM(Permission.CHECK_ITEMSPAM, "ItemSpam"),
- FAST_INVENTORY(Permission.CHECK_FASTINVENTORY, "FastInventory"),
- MOREPACKETS(Permission.CHECK_MOREPACKETS, "MorePackets"),
- BADPACKETS(Permission.CHECK_BADPACKETS, "BadPackets"),
- VELOCITY(Permission.CHECK_VELOCITY, "Velocity"),
- CRITICALS(Permission.CHECK_CRITICALS, "Criticals"),
- CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"),
- ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
- FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"),
- AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"),
- STRAFE(Permission.CHECK_STRAFE, "Strafe"),
- NOSLOW(Permission.CHECK_NOSLOW, "NoSlow"),
- BOATFLY(Permission.CHECK_BOATFLY, "BoatFly");
-
- private final Permission permission;
- private final String displayName;
- private final Map level = new HashMap();
-
- /**
- * Initialize a CheckType
- *
- * @param permission Permission that applies to this check
- * @peram displayName The chat display name
- */
- private CheckType(Permission permission, String displayName) {
- this.permission = permission;
- this.displayName = displayName;
- }
-
- /**
- * Determine whether a player has permission to bypass this check
- *
- * @param player Player to check
- * @return true if the player can bypass
- */
- public boolean checkPermission(Player player) {
- return permission.get(player);
- }
-
- /**
- * Log the failure of this check
- *
- * @param user User who failed the check
- */
- public void logUse(User user) {
- int amount = level.get(user.getUUID()) == null ? 1 : level.get(user.getUUID()) + 1;
- level.put(user.getUUID(), amount);
- Bukkit.getServer().getPluginManager().callEvent(new CheckFailEvent(user, this));
- }
-
- /**
- * Clear failure history of this check for a user
- *
- * @param UUID User's UUID to clear
- */
- public void clearUse(UUID uuid) {
- level.put(uuid, 0);
- }
-
- /**
- * Get how many times a user has failed this check
- *
- * @param UUID User's UUID
- * @return number of times failed
- */
- public int getUses(UUID uuid) {
- return level.get(uuid) != null ? level.get(uuid) : 0;
- }
-
- /**
- * Get the reference name of a check
- *
- * @return reference name
- */
- public String getName() {
- return this.displayName;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java
deleted file mode 100644
index e46ebc8..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.combat;
-
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.event.EventListener;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-
-public class CriticalsCheck {
-
- public static void doDamageEvent(EntityDamageByEntityEvent event, Player damager) {
- if (!(event.getDamager() instanceof Player) || event.getCause() != DamageCause.ENTITY_ATTACK)
- return;
- Player player = (Player) event.getDamager();
- if (isCritical(player)) {
- if ((player.getLocation().getY() % 1.0 == 0 || player.getLocation().getY() % 0.5 == 0)
- && player.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
- event.setCancelled(true);
- EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
- .getMessage(),
- player, CheckType.CRITICALS, null);
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- private static boolean isCritical(Player player) {
- return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle()
- && !player.hasPotionEffect(PotionEffectType.BLINDNESS)
- && !Utilities.isHoveringOverWater(player.getLocation())
- && player.getEyeLocation().getBlock().getType() != Material.LADDER;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java
deleted file mode 100644
index fb151e7..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.combat;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.util.Vector;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-
-public class KillAuraCheck {
-
- // Angle check
- public static final Map ANGLE_FLAGS = new HashMap();
- // PacketOrder check
- public static final Map PACKETORDER_FLAGS = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult checkReach(Player player, Entity target) {
- if (!(target instanceof LivingEntity))
- return PASS;
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
-
- // Check if enabled
- if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "reach"))
- return PASS;
-
- double allowedReach = target.getVelocity().length() < 0.08
- ? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
- : checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
- if (player.getGameMode() == GameMode.CREATIVE)
- allowedReach += 1.5D;
- // Lag compensation
- double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
- double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
- "lagCompensation.pingCompensation");
- allowedReach += user.getPing() * pingCompensation;
- if (user.isLagging())
- allowedReach += lagExtraReach;
- if (target instanceof Player) {
- User targetUser = AntiCheatReloaded.getManager().getUserManager().getUser(target.getUniqueId());
- allowedReach += targetUser.getPing() * pingCompensation;
- if (targetUser.isLagging())
- allowedReach += lagExtraReach;
- }
- // Velocity compensation
- double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier");
- allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier;
- double reachedDistance = ((LivingEntity) target).getLocation().toVector()
- .distance(player.getLocation().toVector());
- if (reachedDistance > allowedReach)
- return new CheckResult(CheckResult.Result.FAILED, "Reach",
- "reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
- return PASS;
- }
-
- public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
- UUID uuid = player.getUniqueId();
- Entity entity = event.getEntity();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
-
- // Check if enabled
- if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "angle"))
- return PASS;
-
- if (entity instanceof LivingEntity) {
- LivingEntity living = (LivingEntity) entity;
- Location eyeLocation = player.getEyeLocation();
-
- double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
- double playerYaw = player.getEyeLocation().getYaw();
-
- double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
- int maxDifference = checksConfig.getInteger(CheckType.KILLAURA, "angle", "maxDifference");
- if (Math.round(angleDifference) > maxDifference) {
- if (!ANGLE_FLAGS.containsKey(uuid)) {
- ANGLE_FLAGS.put(uuid, 1);
- return PASS;
- }
-
- int flags = ANGLE_FLAGS.get(uuid);
- int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
- if (flags >= vlBeforeFlag) {
- ANGLE_FLAGS.remove(uuid);
- return new CheckResult(CheckResult.Result.FAILED, "Angle",
- "tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
- }
-
- ANGLE_FLAGS.put(uuid, flags + 1);
- }
- }
-
- return PASS;
- }
-
- public static CheckResult checkPacketOrder(Player player, Entity entity) {
- UUID uuid = player.getUniqueId();
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
- MovementManager movementManager = user.getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
-
- // Check if enabled
- if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder"))
- return PASS;
-
- if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100
- || AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps"))
- return PASS;
-
- long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
- if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
- if (!PACKETORDER_FLAGS.containsKey(uuid)) {
- PACKETORDER_FLAGS.put(uuid, 1);
- return PASS;
- }
-
- int flags = PACKETORDER_FLAGS.get(uuid);
- int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
- if (flags >= vlBeforeFlag) {
- PACKETORDER_FLAGS.remove(uuid);
- return new CheckResult(Result.FAILED, "PacketOrder", "suspicious packet order (elapsed=" + elapsed + ")");
- }
-
- PACKETORDER_FLAGS.put(uuid, flags + 1);
- }
- return PASS;
- }
-
- public static double calculateYawDifference(Location from, Location to) {
- Location clonedFrom = from.clone();
- Vector startVector = clonedFrom.toVector();
- Vector targetVector = to.toVector();
- clonedFrom.setDirection(targetVector.subtract(startVector));
- return clonedFrom.getYaw();
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/VelocityCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/VelocityCheck.java
deleted file mode 100644
index 9ebcdef..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/VelocityCheck.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.combat;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-
-public class VelocityCheck {
-
- public static final Map VIOLATIONS = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, Distance distance) {
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- MovementManager movementManager = user.getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- final int minimumPercentage = checksConfig.getInteger(CheckType.VELOCITY, "minimumPercentage");
- final int vlBeforeFlag = checksConfig.getInteger(CheckType.VELOCITY, "vlBeforeFlag");
-
- if (movementManager.velocityExpectedMotionY > 0 && !movementManager.onGround) {
- double percentage = (movementManager.motionY / movementManager.velocityExpectedMotionY) * 100;
- if (percentage < 0)
- percentage = 0;
- // Reset expected Y motion
- movementManager.velocityExpectedMotionY = 0;
- if (percentage < minimumPercentage) {
- int vl = VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
- VIOLATIONS.put(player.getUniqueId(), vl);
- if (vl >= vlBeforeFlag)
- return new CheckResult(Result.FAILED, "ignored server velocity (pct=" + Utilities.roundDouble(percentage, 2) + ")");
- } else {
- VIOLATIONS.remove(player.getUniqueId());
- }
- } else if (movementManager.airTicks > 5 && movementManager.velocityExpectedMotionY > 0)
- movementManager.velocityExpectedMotionY = 0;
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java
deleted file mode 100644
index e9392cf..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerMoveEvent;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-
-public class AimbotCheck {
-
- public static final Map LAST_DELTA_YAW = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, PlayerMoveEvent event) {
- Backend backend = AntiCheatReloaded.getManager().getBackend();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- if (backend.isMovingExempt(player)) {
- return PASS;
- }
-
- UUID uuid = player.getUniqueId();
- float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw());
- float dPitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
- // Not interesting
- if (dYaw < 0.05 && dPitch < 0.05) {
- return PASS;
- }
-
- final float lastDeltaYaw = LAST_DELTA_YAW.getOrDefault(uuid, -1F);
- if (lastDeltaYaw == -1F) {
- LAST_DELTA_YAW.put(uuid, dYaw);
- return PASS;
- }
- LAST_DELTA_YAW.put(uuid, dYaw);
-
- float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
- int minYaw = checksConfig.getInteger(CheckType.AIMBOT, "minYaw");
- int maxYaw = checksConfig.getInteger(CheckType.AIMBOT, "maxYaw");
- if (absoluteYawDifference < 1E-8 && minYaw > 30 && dYaw < maxYaw)
- return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java
deleted file mode 100644
index bd62e02..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class BoatFlyCheck {
-
- public static final Map VIOLATIONS = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, MovementManager movementManager, Location to) {
- if (movementManager.distanceXZ <= 0 || movementManager.motionY <= 1E-3
- || (System.currentTimeMillis() - movementManager.lastTeleport <= 50) || VersionUtil.isFlying(player)
- || !player.isInsideVehicle())
- return PASS;
-
- UUID uuid = player.getUniqueId();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- if (player.getVehicle().getType() == EntityType.BOAT) {
- Block bottom = player.getWorld().getBlockAt(to.getBlockX(), to.getBlockY() - 1, to.getBlockZ());
- if (!Utilities.cantStandAt(bottom))
- return PASS;
- int violations = VIOLATIONS.getOrDefault(uuid, 1);
- if (violations++ >= checksConfig.getInteger(CheckType.BOATFLY, "vlBeforeFlag")) {
- violations = 0;
- return new CheckResult(Result.FAILED, "tried to fly in a boat (mY=" + movementManager.motionY
- + ", bottom=" + bottom.getType().name().toLowerCase() + ")");
- }
- VIOLATIONS.put(uuid, violations);
- }
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/ElytraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/ElytraCheck.java
deleted file mode 100644
index 92a0da4..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/ElytraCheck.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.UUID;
-
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class ElytraCheck {
-
- public static final HashMap JUMP_Y_VALUE = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, Distance distance) {
- // No elytra in server version or not relevant
- if (VersionUtil.isBountifulUpdate() || Utilities.isNearWater(player))
- return PASS;
-
- UUID uuid = player.getUniqueId();
- if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
- // This was a teleport, so skip check.
- JUMP_Y_VALUE.remove(uuid);
- return PASS;
- }
-
- if (player.isFlying() || player.hasPotionEffect(PotionEffectType.LEVITATION) || !player.isGliding()) {
- JUMP_Y_VALUE.remove(uuid);
- return PASS;
- }
-
- double changeY = distance.toY() - distance.fromY();
- boolean upwardMovement = changeY > 0;
- if (player.getInventory().getItemInMainHand().getType() == Material.TRIDENT) {
- if (upwardMovement) {
- // TODO continue check here
- JUMP_Y_VALUE.remove(uuid);
- return PASS;
- }
- }
-
- if (changeY == 0.0D) {
- // Seen no false positives here yet
- return new CheckResult(CheckResult.Result.FAILED, "had no Y-axis dropoff when gliding with Elytra");
- }
-
- if (!JUMP_Y_VALUE.containsKey(uuid)) {
- JUMP_Y_VALUE.put(uuid, distance.toY());
- return PASS;
- }
- double lastY = JUMP_Y_VALUE.get(uuid);
- if (lastY < distance.toY()) {
- double diff = distance.toY() - lastY;
- if (diff > 0.7675) {
- if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
- Location to = player.getLocation();
- to.setY(to.getY() - diff);
- player.teleport(to);
- }
- return new CheckResult(CheckResult.Result.FAILED, "tried to glide above jump level");
- }
- }
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java
deleted file mode 100644
index f88cddc..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-
-public class FastLadderCheck {
-
- public static final Map VIOLATIONS = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, double y) {
- // Only check if fully on ladder
- // Liquids are climbable blocks, so we have to add a seperate check
- if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
- || !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
- || player.getLocation().getBlock().isLiquid()) {
- return PASS;
- }
-
- int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- int vlBeforeFlag = checksConfig.getInteger(CheckType.FASTLADDER, "vlBeforeFlag");
- if (y > 0) {
- // Check moving up
- double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedUpMax");
- // Check if going faster than max Y climbing speed
- if (y - max > 0) {
- if (vlCount++ > vlBeforeFlag) {
- vlCount = 0;
- return new CheckResult(Result.FAILED,
- "tried to climb up too fast (speed=" + y + ", max=" + max + ")");
- }
- } else {
- if (vlCount > 0)
- vlCount--;
- }
- } else if (y < 0) {
- // Check moving down
- double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedDownMax");
- if (Math.abs(y) > max + 6E-9) {
- if (vlCount++ > vlBeforeFlag) {
- vlCount = 0;
- return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
- + ", max=" + max + ")");
- }
- } else {
- if (vlCount > 0)
- vlCount--;
- }
- } else {
- if (vlCount > 0)
- vlCount--;
- }
-
- VIOLATIONS.put(player.getUniqueId(), vlCount);
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java
deleted file mode 100644
index 5d84db4..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.block.BlockFace;
-import org.bukkit.entity.Player;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-/**
- * @author Rammelkast
- */
-public class FlightCheck {
-
- public static final Map MOVING_EXEMPT = new HashMap();
- public static final Map GRAVITY_VIOLATIONS = new HashMap();
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
- private static final double GRAVITY_FRICTION = 0.9800000190734863D;
-
- public static CheckResult runCheck(Player player, Distance distance) {
- if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
- || VersionUtil.isFlying(player) || player.getVehicle() != null
- || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
- // This was a teleport or user is flying/using elytra/in a vehicle, so we don't
- // care
- // about it.
- return PASS;
- }
-
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- MovementManager movementManager = user.getMovementManager();
- Backend backend = AntiCheatReloaded.getManager().getBackend();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
-
- if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player))
- return PASS;
-
- int minAirTicks = 13;
- if (player.hasPotionEffect(PotionEffectType.JUMP))
- minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3;
-
- if (movementManager.halfMovementHistoryCounter > 25)
- minAirTicks += 5;
-
- // Start AirFlight
- if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
- && !backend.justVelocity(player) && movementManager.elytraEffectTicks <= 25) {
- // Config default base is 1200ms
- // Ping clamped to max. 1000 to prevent spoofing for an advantage
- int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
- "accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
- // Config default account is 250ms
- if (AntiCheatReloaded.getPlugin().getTPS() < 18.0)
- blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
- "accountForTpsDrops");
- long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
- .containsKey(player.getUniqueId())
- ? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
- : (blockPlaceAccountingTime + 1);
- double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
- // Fixes snow false positive
- if (movementManager.motionY < 0.004 && Utilities
- .isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
- maxMotionY = 0.004D;
- if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
- && !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0)))
- return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
- "tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
-
- if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01
- && !Utilities.couldBeOnBoat(player)
- && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
- .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
- && !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player)
- && movementManager.elytraEffectTicks <= 25)
- return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
- + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
- }
- // End AirFlight
-
- // Start AirClimb
- // TODO three hardcoded values here shouldn't be there, temp against false
- // positive
- if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
- && movementManager.motionY > 0 && movementManager.airTicks == 2
- && Math.round(movementManager.lastMotionY * 1000) != 420
- && Math.round(movementManager.motionY * 1000) != 248
- && !(Math.round(movementManager.motionY * 1000) == 333
- && Math.round(movementManager.lastMotionY * 1000) != 333)
- && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
- && !player.hasPotionEffect(PotionEffectType.JUMP)
- && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
- .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
- && (!Utilities.isNearBed(distance.getTo())
- || (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))
- && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
- return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
- "tried to climb air (mY=" + movementManager.motionY + ")");
-
- // TODO hardcoded value against false again..
- if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
- && movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
- && !player.hasPotionEffect(PotionEffectType.JUMP)
- && !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
- && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
- .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
- && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
- return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
- "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
- }
- // End AirClimb
-
- // Start GroundFlight
- if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
- && Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
- && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
- && Utilities.cantStandAt(distance.getTo().getBlock())) {
- return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
- "faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
- }
- // End GroundFlight
-
- // Start Gravity
- if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
- && movementManager.motionY < 0 && !backend.justVelocity(player)
- && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
- .getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
- && !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
- && !VersionUtil.isSlowFalling(player)) {
- double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
- double offset = Math.abs(gravitatedY - movementManager.motionY);
- double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
- if (offset > maxOffset && movementManager.airTicks > 2) {
- int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
- GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
- int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
- if (vl >= vlBeforeFlag)
- return new CheckResult(CheckResult.Result.FAILED, "Gravity",
- "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
- } else {
- GRAVITY_VIOLATIONS.remove(player.getUniqueId());
- }
- }
- // End Gravity
-
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java
deleted file mode 100644
index a9fe51a..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.entity.Player;
-
-import com.comphenix.protocol.events.PacketEvent;
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.event.EventListener;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class NoSlowCheck {
-
- public static final Map LAST_RELEASE = new HashMap();
- public static final Map VIOLATIONS = new HashMap();
-
- public static void runCheck(Player player, PacketEvent event) {
- if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.NOSLOW))
- return;
- UUID uuid = player.getUniqueId();
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
- MovementManager movementManager = user.getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- final long time = System.currentTimeMillis();
- final long lastRelease = LAST_RELEASE.getOrDefault(uuid, 0L);
- LAST_RELEASE.put(uuid, time);
- if (lastRelease == 0L)
- return;
-
- long difference = time - lastRelease;
- long minimumDifference = checksConfig.getInteger(CheckType.NOSLOW, "minimumDifference");
- if (difference < minimumDifference
- && movementManager.distanceXZ >= checksConfig.getDouble(CheckType.NOSLOW, "minimumDistXZ")) {
- int violations = VIOLATIONS.getOrDefault(uuid, 1);
- if (violations++ >= checksConfig.getInteger(CheckType.NOSLOW, "vlBeforeFlag")) {
- violations = 0;
- flag(player, event,
- "toggled use item too fast (diff=" + difference + ", min=" + minimumDifference + ")");
- }
- VIOLATIONS.put(uuid, violations);
- }
- }
-
- private static void flag(Player player, PacketEvent event, String message) {
- event.setCancelled(true);
- // We are currently not in the main server thread, so switch
- AntiCheatReloaded.sendToMainThread(new Runnable() {
- @Override
- public void run() {
- EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
- CheckType.NOSLOW, null);
- player.teleport(player.getLocation());
- }
- });
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
deleted file mode 100644
index 1970c63..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import org.bukkit.Location;
-import org.bukkit.block.BlockFace;
-import org.bukkit.entity.Player;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-/**
- * @author Rammelkast TODO soulsand speed
- */
-public class SpeedCheck {
-
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static boolean isSpeedExempt(Player player, Backend backend) {
- return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
- }
-
- public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
- Backend backend = AntiCheatReloaded.getManager().getBackend();
- if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player))
- return PASS;
-
- MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
- .getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double distanceXZ = movementManager.distanceXZ;
- boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
-
- // AirSpeed
- if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1
- && movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
- double multiplier = 0.985D;
- double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
- double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
- // Adjust for ice
- if (movementManager.iceInfluenceTicks > 0) {
- double iceIncrement = 0.025 * Math.pow(1.038, movementManager.iceInfluenceTicks);
- // Clamp to max value
- if (iceIncrement > 0.18D)
- iceIncrement = 0.18D;
- if (boxedIn)
- iceIncrement += 0.45D;
- if (!Utilities.couldBeOnIce(movingTowards))
- iceIncrement *= 2.5D;
- predict += iceIncrement;
- }
- // Leniency when boxed in
- if (boxedIn && movementManager.airTicks < 3)
- predict *= 1.2D;
- // Adjust for slime
- if (movementManager.slimeInfluenceTicks > 0) {
- double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
- // Clamp to max value
- if (slimeIncrement > 0.12D)
- slimeIncrement = 0.12D;
- predict += slimeIncrement;
- }
- // Adjust for speed effects
- if (movementManager.hasSpeedEffect)
- predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
- if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
- limit *= 1.2D;
- // Adjust for jump boost effects
- if (player.hasPotionEffect(PotionEffectType.JUMP))
- predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
- // Adjust for custom walking speed
- double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default
- // 1.4
- predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
- // Slabs sometimes allow for a slight boost after jump
- if (movementManager.halfMovementHistoryCounter > 0)
- predict *= 2.125D;
- if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0)
- predict *= 1.25D;
- // Boats sometimes give a false positive
- if (Utilities.couldBeOnBoat(player, 0.5, true))
- predict *= 1.25D;
- // Strafing in air when nearing terminal velocity gives false positives
- // This fixes the issue but gives hackers some leniency which means we need
- // another check for this
- double deltaMotionY = movementManager.motionY - movementManager.lastMotionY;
- if ((deltaMotionY < 0 && deltaMotionY >= -0.08) || movementManager.airTicks >= 40
- && (movingTowards.getBlockY() - player.getWorld().getHighestBlockYAt(movingTowards)) <= 1.5)
- predict *= (movementManager.airTicks > 60 ? 4.0D : (movementManager.airTicks > 30 ? 3.0D : 2.0D));
- // Players can move faster in air with slow falling
- if (VersionUtil.isSlowFalling(player))
- predict *= 1.25D;
- // Prevent NoSlow
- if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2)
- predict *= 0.8D;
- if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
- predict *= 0.5D;
- // Fixes false positive when coming out of water
- if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
- && movementManager.motionY < -0.18 && movementManager.motionY > -0.182)
- predict += Math.abs(movementManager.motionY);
-
- if (distanceXZ - predict > limit) {
- return new CheckResult(CheckResult.Result.FAILED, "AirSpeed",
- "moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", block="
- + movementManager.blockingTicks + ", box=" + boxedIn + ", at="
- + movementManager.airTicks + ")");
- }
- }
-
- // AirAcceleration
- // As of right now, this falses sometimes, dont know why
- if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airAcceleration") && movementManager.airTicks > 1
- && movementManager.iceInfluenceTicks <= 0 && movementManager.slimeInfluenceTicks <= 0
- && movementManager.elytraEffectTicks <= 0) {
- double initialAcceleration = movementManager.acceleration;
- double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
- // Slight increase when boxed in
- if (boxedIn)
- limit *= 1.08D;
- // Adjust for speed effects
- if (player.hasPotionEffect(PotionEffectType.SPEED))
- limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
- // Adjust for slabs
- if (movementManager.halfMovementHistoryCounter > 15)
- limit *= 2.0D;
- // Adjust for custom walking speed
- double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
- "walkSpeedMultiplier"); // Default 1.4
- limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
- // Boats sometimes give a false positive
- if (Utilities.couldBeOnBoat(player))
- limit *= 1.25D;
- if (initialAcceleration > limit) {
- return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
- "exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")");
- }
- }
-
- // JumpBehaviour
- // Works against YPorts and mini jumps
- if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick
- && !boxedIn && movementManager.slimeInfluenceTicks <= 10) {
- // This happens naturally
- if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
- double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
-
- if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
- return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
- "had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
- + Utilities.roundDouble(movementManager.lastDistanceXZ, 4) + ")");
- }
- }
- }
-
- // GroundSpeed
- if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) {
- double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default
- // 0.34
- double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
- // Leniency when moving back on ground
- if (movementManager.groundTicks < 5)
- limit += 0.1D;
- // Slab leniency
- if (movementManager.halfMovementHistoryCounter > 8)
- limit += 0.2D;
- // LivingEntities can give players a small push boost
- if (!movingTowards.getWorld().getNearbyEntities(movingTowards, 0.3, 0.3, 0.3).isEmpty())
- limit += 0.2D;
- // Leniency when boxed in
- if (boxedIn)
- limit *= 1.1D;
- // Adjust for speed effects
- if (movementManager.hasSpeedEffect)
- limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
- if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3)
- limit *= 1.4D;
- if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
- limit *= 1.2D;
- if (movementManager.iceInfluenceTicks >= 50) {
- // When moving off ice
- if (!Utilities.couldBeOnIce(movingTowards))
- limit *= 2.5D;
- else {
- // When boxed in and spamming space for boost
- if (movementManager.topSolid && movementManager.bottomSolid)
- limit *= 3.0D;
- else
- limit *= 1.25D;
- }
- }
- // Increased speed when stepping on/off half blocks
- if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards)
- || Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0)))
- limit *= 2.0D;
- // Increased speed when stepping on/off boat
- if (Utilities.couldBeOnBoat(player))
- limit += 0.2D;
- // Adjust for custom walk speed
- limit += (player.getWalkSpeed() - 0.2) * 2.0D;
- // Prevent NoSlow
- if (player.isBlocking() && movementManager.groundTicks > 2)
- limit *= 0.45D;
- // Prevent NoWeb
- // TODO config
- if (Utilities.isInWeb(player))
- limit *= 0.65D;
- // Sneak speed check
- // TODO config
- if (movementManager.sneakingTicks > 1)
- limit *= 0.68D;
-
- if (distanceXZ - limit > 0) {
- return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
- "moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking="
- + player.isBlocking() + ", gt=" + movementManager.groundTicks + ")");
- }
- }
-
- return PASS;
- }
-
- public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
- Backend backend = AntiCheatReloaded.getManager().getBackend();
- if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
- || VersionUtil.isRiptiding(player) || Utilities.isNearWater(player))
- return PASS;
- MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
- .getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
- return PASS;
-
- double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
- Utilities.couldBeOnBoat(player),
- Utilities.isClimbableBlock(distance.getFrom().getBlock())
- || Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)),
- movementManager.halfMovement, checksConfig);
- // Fix false positive with soulsand boost
- if (movementManager.nearLiquidTicks > 6)
- maxMotionY *= 1.0525D;
- if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
- return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
- "exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
- }
- return PASS;
- }
-
- private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat,
- boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
- // TODO config for these values
- // TODO something funky vanilla stuff going on with 0.42, like 0.445.., check
- // this..
- double base = couldBeOnBoat ? 0.600000025
- : (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
- if (fromClimbable)
- base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
-
- if (player.hasPotionEffect(PotionEffectType.JUMP))
- base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
- return base;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java
deleted file mode 100644
index 3bf2229..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import org.bukkit.Location;
-import org.bukkit.block.BlockFace;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-/**
- *
- * @author Rammelkast
- *
- */
-public class StrafeCheck {
-
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, double x, double z, Location from, Location to) {
- if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player)
- || Utilities.isNearClimbable(player) || VersionUtil.isFlying(player) || player.isDead()
- || Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)))
- return PASS;
-
- MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
- .getMovementManager();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
-
- if (System.currentTimeMillis() - movementManager.lastTeleport <= checksConfig.getInteger(CheckType.STRAFE,
- "accountForTeleports") || movementManager.elytraEffectTicks >= 20
- || movementManager.halfMovementHistoryCounter >= 20)
- return PASS;
-
- Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
- Vector newAcceleration = new Vector(x, 0, z);
-
- float angle = newAcceleration.angle(oldAcceleration);
- double distance = newAcceleration.lengthSquared();
- if (angle > checksConfig.getDouble(CheckType.STRAFE, "maxAngleChange")
- && distance > checksConfig.getDouble(CheckType.STRAFE, "minActivationDistance")
- && Utilities.cantStandFar(to.getBlock()))
- return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java
deleted file mode 100644
index f21b5cc..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.movement;
-
-import java.util.UUID;
-
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.potion.PotionEffectType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class WaterWalkCheck {
-
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult runCheck(Player player, double x, double y, double z) {
- UUID uuid = player.getUniqueId();
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
- MovementManager movementManager = user.getMovementManager();
-
- if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
- || VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player))
- return PASS;
-
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
- if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
- && Utilities.isSurroundedByWater(player)
- && ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
- || movementManager.motionY == Utilities.JUMP_MOTION_Y)
- && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
- && !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
- return new CheckResult(Result.FAILED, "Walk",
- "tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
-
- if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
- && Utilities.isSurroundedByWater(player) && movementManager.onGround
- && Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
- && !Utilities.couldBeOnBoat(player, 0.3, false))
- return new CheckResult(Result.FAILED, "Hop",
- "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
-
- double minAbsMotionY = 0.12D;
- if (player.hasPotionEffect(PotionEffectType.SPEED))
- minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
- if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
- && Utilities.isSurroundedByWater(player)
- && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
- && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
- && movementManager.lastMotionY > -0.25
- && !Utilities.couldBeOnBoat(player, 0.3, false))
- return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
- + Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
- + Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
-
- return PASS;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java
deleted file mode 100644
index e4479ff..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.packet;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.events.PacketEvent;
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.event.EventListener;
-import com.rammelkast.anticheatreloaded.util.MovementManager;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class BadPacketsCheck {
-
- public static void runCheck(Player player, PacketEvent event) {
- Backend backend = AntiCheatReloaded.getManager().getBackend();
- // Confirm if we should even check for BadPackets
- if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
- || backend.isMovingExempt(player) || player.isDead())
- return;
-
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- PacketContainer packet = event.getPacket();
- float pitch = packet.getFloat().read(1);
- // Check for derp
- if (Math.abs(pitch) > 90) {
- flag(player, event, "had an illegal pitch");
- return;
- }
-
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double tps = AntiCheatReloaded.getPlugin().getTPS();
- MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
- .getMovementManager();
- if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
- || (System.currentTimeMillis() - movementManager.lastTeleport <= 150))
- return;
-
- double x = packet.getDoubles().read(0);
- double y = packet.getDoubles().read(1);
- double z = packet.getDoubles().read(2);
- float yaw = packet.getFloat().read(0);
- // Create location from new data
- Location previous = player.getLocation();
- Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
- double distance = previous.distanceSquared(current);
- double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
- // Fix falling false
- if (movementManager.airTicks >= 40 && movementManager.motionY < 0 && movementManager.lastMotionY < 0)
- maxDistance *= 1.5D;
- boolean hasNewLocation = packet.getBooleans().read(0);
- if (distance > maxDistance) {
- flag(player, event, "moved too far between packets (distance="
- + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ", at=" + movementManager.airTicks + ")");
- return;
- } else if (distance < 1E-10 && !hasNewLocation) {
- // TODO this gives false positives when teleporting
- // Only found this in 1.8.8 though
- // flag(player, event, "sent the same packet twice");
- return;
- }
- }
-
- private static void flag(Player player, PacketEvent event, String message) {
- event.setCancelled(true);
- // We are currently not in the main server thread, so switch
- AntiCheatReloaded.sendToMainThread(new Runnable() {
- @Override
- public void run() {
- EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
- CheckType.BADPACKETS, null);
- player.teleport(player.getLocation());
- }
- });
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java
deleted file mode 100644
index a0feeda..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.check.packet;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.entity.Player;
-
-import com.comphenix.protocol.events.PacketEvent;
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.event.EventListener;
-import com.rammelkast.anticheatreloaded.util.User;
-
-/**
- * @author Rammelkast
- */
-public class MorePacketsCheck {
-
- public static final Map LAST_PACKET_TIME = new HashMap();
- public static final Map EXEMPT_TIMINGS = new HashMap();
- public static final Map PACKET_BALANCE = new HashMap();
-
- public static void runCheck(Player player, PacketEvent event) {
- // Confirm if we should even check for MorePackets
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double tps = AntiCheatReloaded.getPlugin().getTPS();
- if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS)
- || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
- return;
- }
-
- UUID uuid = player.getUniqueId();
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
- int maxPing = checksConfig.getInteger(CheckType.MOREPACKETS, "maxPing");
- boolean disableForLagging = checksConfig.getBoolean(CheckType.MOREPACKETS, "disableForLagging");
- if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)
- || (maxPing > 0 && user.getPing() > maxPing) || (disableForLagging && user.isLagging())) {
- return;
- }
- long packetTimeNow = System.currentTimeMillis();
- long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L);
- double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
-
- long rate = packetTimeNow - lastPacketTime;
- packetBalance += 50;
- packetBalance -= rate;
- int triggerBalance = checksConfig.getInteger(CheckType.MOREPACKETS, "triggerBalance");
- int minimumClamp = checksConfig.getInteger(CheckType.MOREPACKETS, "minimumClamp");
- if (packetBalance >= triggerBalance) {
- int ticks = (int) Math.round(packetBalance / 50);
- packetBalance = -1 * (triggerBalance / 2);
- flag(player, event, "overshot timer by " + ticks + " tick(s)");
- } else if (packetBalance < -1 * minimumClamp) {
- // Clamp minimum, 50ms=1tick of lag leniency
- packetBalance = -1 * minimumClamp;
- }
-
- LAST_PACKET_TIME.put(uuid, packetTimeNow);
- PACKET_BALANCE.put(uuid, packetBalance);
- }
-
- private static void flag(Player player, PacketEvent event, String message) {
- event.setCancelled(true);
- // We are currently not in the main server thread, so switch
- AntiCheatReloaded.sendToMainThread(new Runnable() {
- @Override
- public void run() {
- EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
- CheckType.MOREPACKETS, null);
- player.teleport(player.getLocation());
- }
- });
- }
-
- public static void compensate(Player player) {
- UUID uuid = player.getUniqueId();
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
- PACKET_BALANCE.put(uuid, packetBalance - checksConfig.getInteger(CheckType.MOREPACKETS, "teleportCompensation"));
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java
deleted file mode 100644
index 6b709af..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.check.player;
-
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class IllegalInteract {
-
- private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
-
- public static CheckResult performCheck(Player player, Event event) {
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- if (event instanceof BlockPlaceEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "place")) {
- return checkBlockPlace(player, (BlockPlaceEvent) event);
- } else if (event instanceof BlockBreakEvent
- && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
- return checkBlockBreak(player, (BlockBreakEvent) event);
- } else if (event instanceof PlayerInteractEvent
- && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
- return checkInteract(player, (PlayerInteractEvent) event);
- }
- return PASS;
- }
-
- private static CheckResult checkInteract(Player player, PlayerInteractEvent event) {
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double distance = player.getEyeLocation().toVector().distance(event.getClickedBlock().getLocation().toVector());
- double maxDistance = player.getGameMode() == GameMode.CREATIVE
- ? checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "creativeRange")
- : checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "survivalRange");
-
- maxDistance += user.isLagging() ? 0.12 : 0;
- maxDistance += user.getPing()
- * checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "interact", "pingCompensation");
- maxDistance += player.getVelocity().length()
- * checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
- if (distance > maxDistance) {
- return new CheckResult(CheckResult.Result.FAILED, "Interact",
- "tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
- }
- return PASS;
- }
-
- private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
- if (!isValidTarget(player, event.getBlock())) {
- return new CheckResult(CheckResult.Result.FAILED, "Break", "tried to break a block which was out of view");
- }
- return PASS;
- }
-
- private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
- if (!isValidTarget(player, event.getBlock())) {
- return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view");
- }
- return PASS;
- }
-
- private static boolean isValidTarget(Player player, Block block) {
- Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
- double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0
- : player.getLocation().getDirection().getY() > 0.9 ? 6.0 : 5.5;
- Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
- if (targetBlock == null) {
- // TODO better check here
- return true;
- }
-
- if (Utilities.isClimbableBlock(targetBlock)) {
- if (targetBlock.getLocation().distance(player.getLocation()) <= distance) {
- return true;
- }
- }
-
- if (targetBlock.equals(block)) {
- return true;
- }
-
- Location eyeLocation = player.getEyeLocation();
- double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
- double playerYaw = player.getEyeLocation().getYaw();
- double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
- if (Math.round(angleDifference) > checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "maxAngleDifference")) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java
deleted file mode 100644
index f9692c7..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Server;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.manage.CheckManager;
-import com.rammelkast.anticheatreloaded.manage.UserManager;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandBase {
-
- public static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
- public static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
- public static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
- public static final ChatColor RED = ChatColor.RED;
- public static final ChatColor YELLOW = ChatColor.YELLOW;
- public static final ChatColor GREEN = ChatColor.GREEN;
- public static final ChatColor WHITE = ChatColor.WHITE;
- public static final ChatColor GRAY = ChatColor.GRAY;
- public static final ChatColor GOLD = ChatColor.GOLD;
- public static final ChatColor AQUA = ChatColor.AQUA;
- public static final Server SERVER = Bukkit.getServer();
- public static final String PERMISSIONS_ERROR = RED + "You don't have the permissions to use this command.";
- public static final String MENU_END = GOLD + "-----------------------------------------------------";
-
- private final String name;
- private final String command;
- private final String usage;
- private final String[] help;
- private final Permission permission;
-
- public CommandBase(String name, String command, String usage, String help[], Permission permission) {
- this.name = name;
- this.command = command;
- this.usage = usage;
- this.help = help;
- this.permission = permission;
- }
-
- public void run(CommandSender cs, String[] args) {
- if (permission.get(cs)) {
- execute(cs, args);
- } else {
- if (args == null) {
- cs.sendMessage(GRAY + "Running " + GOLD + "" + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
- } else {
- cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
- }
- }
- }
-
- protected void execute(CommandSender cs, String[] args) {
- return; // Stub
- }
-
- public void sendHelp(CommandSender cs) {
- cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + ChatColor.GRAY + "Help Menu");
- cs.sendMessage(GOLD + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
- cs.sendMessage(GOLD + "Permission: " + GRAY + getPermission().toString());
- for (String string : getHelp()) {
- cs.sendMessage(string);
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getCommand() {
- return command;
- }
-
- public String getUsage() {
- return usage;
- }
-
- public String[] getHelp() {
- return help;
- }
-
- public Permission getPermission() {
- return permission;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java
deleted file mode 100644
index 45e7a6f..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.command.executors.CommandChecks;
-import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
-import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
-import com.rammelkast.anticheatreloaded.command.executors.CommandMute;
-import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
-import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
-import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
-import com.rammelkast.anticheatreloaded.command.executors.CommandVersion;
-
-public class CommandHandler implements CommandExecutor {
-
- private List commands = new ArrayList();
-
- public CommandHandler() {
- commands.add(new CommandHelp());
- commands.add(new CommandChecks());
- commands.add(new CommandLog());
- commands.add(new CommandReload());
- commands.add(new CommandReport());
- commands.add(new CommandMute());
- commands.add(new CommandReset());
- commands.add(new CommandVersion());
- }
-
- @Override
- public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args) {
- if (args.length >= 1) {
- String command = args[0];
- // Shift args down
- String[] newArgs = new String[args.length-1];
- for (int i=1;i.
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.manage.CheckManager;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandChecks extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Checks Management";
- private static final String COMMAND = "checks";
- private static final String USAGE = "anticheat checks";
- private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
- private static final String[] HELP = new String[2];
-
- static {
- HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks";
- StringBuilder builder = new StringBuilder();
- CheckManager checkManager = AntiCheatReloaded.getManager().getCheckManager();
- builder.append(GRAY + "Checks: ");
- for (int i = 0; i < CheckType.values().length; i++) {
- CheckType type = CheckType.values()[i];
- builder.append((checkManager.isActive(type) ? ChatColor.GREEN : ChatColor.RED) + type.getName());
- if (i < CheckType.values().length - 1) {
- builder.append(", ");
- }
- }
- HELP[1] = builder.toString();
- }
-
- public CommandChecks() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- sendHelp(cs);
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandHelp.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandHelp.java
deleted file mode 100644
index b1ff3f2..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandHelp.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandHelp extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Help";
- private static final String COMMAND = "help";
- private static final String USAGE = "anticheat help";
- private static final Permission PERMISSION = Permission.SYSTEM_HELP;
- private static final String[] HELP = {
- GOLD + "/acr " + GRAY + "help",
- GOLD + "/acr " + GRAY + "reload",
- GOLD + "/acr " + GRAY + "version",
- GOLD + "/acr " + GRAY + "mute",
- GOLD + "/acr " + GRAY + "checks",
- GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
- GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
- GOLD + "/acr " + GRAY + "reset " + WHITE + "[user]",
- };
-
- public CommandHelp() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- sendHelp(cs);
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandLog.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandLog.java
deleted file mode 100644
index 93368be..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandLog.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandLog extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Logging";
- private static final String COMMAND = "log";
- private static final String USAGE = "anticheat log [file/console] [on/off]";
- private static final Permission PERMISSION = Permission.SYSTEM_LOG;
- private static final String[] HELP = {
- GRAY + "Use: " + AQUA + "/anticheat log console on" + GRAY + " to enable console logging",
- GRAY + "Use: " + AQUA + "/anticheat log file off" + GRAY + " to disable file logging",
- };
-
- public CommandLog() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- if (args.length == 2) {
- ConfigurationFile.ConfigValue value;
- String name;
- if (args[0].equalsIgnoreCase("file")) {
- value = CONFIG.getConfig().logToFile;
- name = "File logging";
- } else if (args[0].equalsIgnoreCase("console")) {
- value = CONFIG.getConfig().logToConsole;
- name = "Console logging";
- } else {
- sendHelp(cs);
- return;
- }
-
- boolean newValue;
- if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("enable")) {
- newValue = true;
- } else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("disable")) {
- newValue = false;
- } else {
- sendHelp(cs);
- return;
- }
-
- String strValue = (newValue ? " enabled" : " disabled");
- if (value.getValue() == newValue) {
- cs.sendMessage(GREEN + name + " is already " + strValue + "!");
- } else {
- value.setValue(newValue);
- cs.sendMessage(GREEN + name + strValue + ".");
- CONFIG.getConfig().reload();
- }
- } else {
- sendHelp(cs);
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandMute.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandMute.java
deleted file mode 100644
index 1676b68..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandMute.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import java.util.UUID;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandMute extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Mute";
- private static final String COMMAND = "mute";
- private static final String USAGE = "anticheat mute";
- private static final Permission PERMISSION = Permission.SYSTEM_MUTE;
- private static final String[] HELP = {
- GRAY + "Use: " + AQUA + "/anticheat mute" + GRAY + " to mute all notifications", };
-
- public CommandMute() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- if (!(cs instanceof Player)) {
- cs.sendMessage(ChatColor.BOLD + "" + GOLD + "ACR " + GRAY + "This command is only for players");
- return;
- }
- UUID uuid = ((Player) cs).getUniqueId();
- if (AntiCheatReloaded.MUTE_ENABLED_MODS.contains(uuid)) {
- cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been unmuted");
- AntiCheatReloaded.MUTE_ENABLED_MODS.remove(uuid);
- return;
- } else {
- cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been muted");
- AntiCheatReloaded.MUTE_ENABLED_MODS.add(uuid);
- return;
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java
deleted file mode 100644
index 989abb1..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Permission;
-
-public class CommandReload extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Reload";
- private static final String COMMAND = "reload";
- private static final String USAGE = "anticheat reload";
- private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
- private static final String[] HELP = {
- GRAY + "Use: " + AQUA + "/anticheat reload" + GRAY + " to reload AntiCheat settings",
- };
-
- public CommandReload() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- CONFIG.load();
- cs.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + "The configuration was reloaded");
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java
deleted file mode 100644
index 99f0271..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Group;
-import com.rammelkast.anticheatreloaded.util.Permission;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-
-public class CommandReport extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Reports";
- private static final String COMMAND = "report";
- private static final String USAGE = "anticheat report [group/user]";
- private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
- private static final String[] HELP = {
- GRAY + "Use: " + GOLD + "/anticheat report [group]" + GRAY + " to see all users in a given group",
- GRAY + "Use: " + GOLD + "/anticheat report [user]" + GRAY + " to see a single user's report",
- GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report", };
-
- public CommandReport() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- if (args.length >= 1) {
- int page = 1;
- if (args.length == 2) {
- if (Utilities.isInt(args[1])) {
- page = Integer.parseInt(args[1]);
- } else {
- cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
- }
- }
-
- if ("low".equalsIgnoreCase(args[0])) {
- groupReport(cs, null, page);
- } else if ("all".equalsIgnoreCase(args[0])) {
- cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
- for (Group g : CONFIG.getGroups().getGroups()) {
- int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
- cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
- }
- cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY
- + " for a list of players in each group.");
- } else {
- // Test groups
- for (Group group : CONFIG.getGroups().getGroups()) {
- if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0])
- || "all".equalsIgnoreCase(args[0])) {
- groupReport(cs, group, page);
- return;
- }
- }
-
- @SuppressWarnings("deprecation")
- OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
- if (targetPlayer == null) {
- cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
- return;
- }
-
- User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
- if (user != null) {
- playerReport(cs, user, page);
- return;
- }
-
- cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
- }
- } else {
- sendHelp(cs);
- }
- }
-
- private void groupReport(CommandSender cs, Group group, int page) {
- List users = USER_MANAGER.getUsersInGroup(group);
- ChatColor color = group == null ? GREEN : group.getColor();
- String groupName = group == null ? "Low" : group.getName();
- int pages = (int) Math.ceil(((float) users.size()) / 7);
- if (page <= pages && page > 0) {
- cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
- + "]----------------------");
- cs.sendMessage(GRAY + "Group: " + color + groupName);
- for (int x = 0; x < 7; x++) {
- int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
- if (index < users.size()) {
- String player = users.get(index).getName();
- cs.sendMessage(GRAY + player);
- }
- }
- cs.sendMessage(MENU_END);
- } else {
- if (pages == 0) {
- cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
- cs.sendMessage(GRAY + "Group: " + color + groupName);
- cs.sendMessage(GRAY + "There are no users in this group.");
- cs.sendMessage(MENU_END);
- } else {
- cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
- }
- }
- }
-
- private void playerReport(CommandSender cs, User user, int page) {
- List types = new ArrayList();
- for (CheckType type : CheckType.values()) {
- if (type.getUses(user.getUUID()) > 0) {
- types.add(type);
- }
- }
-
- UUID uuid = user.getUUID();
- String name = user.getName();
- int pages = (int) Math.ceil(((float) types.size()) / 6);
-
- Group group = user.getGroup();
- String groupString = GREEN + "Low";
-
- if (group != null) {
- groupString = group.getColor() + group.getName();
- }
- groupString += " (" + user.getLevel() + ")";
-
- if (page <= pages && page > 0) {
- cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
- + "]----------------------");
- cs.sendMessage(GRAY + "Player: " + WHITE + name);
- int ping = user.getPing();
- cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
- : (WHITE + "" + ping + "ms "
- + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
- cs.sendMessage(GRAY + "Group: " + groupString);
- for (int x = 0; x < 6; x++) {
- int index = ((page - 1) * 5) + (x + ((page - 1)));
- if (index < types.size()) {
- CheckType type = types.get(index);
- int use = type.getUses(uuid);
- ChatColor color = WHITE;
- if (use >= 20) {
- color = YELLOW;
- } else if (use > 50) {
- color = RED;
- }
- cs.sendMessage(GRAY + type.getName() + ": " + color + use);
- }
- }
- cs.sendMessage(MENU_END);
- } else {
- if (pages == 0 && page == 1) {
- cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
- cs.sendMessage(GRAY + "Player: " + WHITE + name);
- int ping = user.getPing();
- cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
- : (WHITE + "" + ping + "ms "
- + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
- cs.sendMessage(GRAY + "Group: " + groupString);
- cs.sendMessage(GRAY + "This user has not failed any checks.");
- cs.sendMessage(MENU_END);
- } else {
- cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
- }
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReset.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReset.java
deleted file mode 100644
index bb3ed5f..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReset.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Permission;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class CommandReset extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Resetting";
- private static final String COMMAND = "reset";
- private static final String USAGE = "anticheat reset [user]";
- private static final Permission PERMISSION = Permission.SYSTEM_RESET;
- private static final String[] HELP = {
- GRAY + "Use: " + AQUA + "/anticheat reset [user]" + GRAY + " to reset this user's hack level",
- };
-
- public CommandReset() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- protected void execute(CommandSender cs, String[] args) {
- User user;
- if (args.length == 1) {
- if (Bukkit.getPlayer(args[0]) != null) {
- user = USER_MANAGER.getUser(Bukkit.getPlayer(args[0]).getUniqueId());
- } else {
- user = USER_MANAGER.getUser(Bukkit.getOfflinePlayer(args[0]).getUniqueId());
- }
- if (user != null) {
- user.resetLevel();
- user.clearMessages();
- AntiCheatReloaded.getManager().getBackend().resetChatLevel(user);
- cs.sendMessage(GOLD + args[0] + GRAY + " has been reset.");
- } else {
- cs.sendMessage(RED + "Player: " +args[0] + " not found.");
- }
- } else {
- sendHelp(cs);
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java
deleted file mode 100644
index bf130b2..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.command.executors;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.command.CommandBase;
-import com.rammelkast.anticheatreloaded.util.Permission;
-import com.rammelkast.anticheatreloaded.util.UpdateManager;
-
-public class CommandVersion extends CommandBase {
-
- private static final String NAME = "AntiCheatReloaded Version";
- private static final String COMMAND = "version";
- private static final String USAGE = "anticheat version";
- private static final Permission PERMISSION = Permission.SYSTEM_VERSION;
- private static final String[] HELP = {
- GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
-
- public CommandVersion() {
- super(NAME, COMMAND, USAGE, HELP, PERMISSION);
- }
-
- @Override
- protected void execute(CommandSender cs, String[] args) {
- UpdateManager updateManager = AntiCheatReloaded.getUpdateManager();
- String status = RED + "behind";
- if (updateManager.isLatest()) {
- if (updateManager.isAhead()) {
- status = GREEN + "ahead";
- } else {
- status = GOLD + "up-to-date";
- }
- }
- cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "You are running version " + GOLD
- + updateManager.getCurrentVersion() + GRAY + ". The latest version is " + GOLD
- + updateManager.getLatestVersion() + GRAY + ". This means you are " + status + GRAY + ".");
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/Configuration.java b/src/main/java/com/rammelkast/anticheatreloaded/config/Configuration.java
deleted file mode 100644
index aa62fc4..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/Configuration.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config;
-
-import java.io.File;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.files.Config;
-import com.rammelkast.anticheatreloaded.config.files.Enterprise;
-import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLGroupsHolder;
-import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLangHolder;
-import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLevelsHolder;
-import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLMagicHolder;
-import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLRulesHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlChecksHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlGroupsHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLangHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLevelsHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlMagicHolder;
-import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlRulesHolder;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-import com.rammelkast.anticheatreloaded.config.providers.Groups;
-import com.rammelkast.anticheatreloaded.config.providers.Lang;
-import com.rammelkast.anticheatreloaded.config.providers.Levels;
-import com.rammelkast.anticheatreloaded.config.providers.Magic;
-import com.rammelkast.anticheatreloaded.config.providers.Rules;
-import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
-
-public class Configuration {
-
- private AntiCheatManager manager;
- private Config config;
- private Enterprise enterprise;
-
- private Lang lang;
- private Magic magic;
- private Groups groups;
- private Levels levels;
- private Rules rules;
- private Checks checks;
-
- private ArrayList flatfiles;
- private ArrayList dbfiles;
-
- public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
- removeOldFiles();
- this.manager = manager;
- config = new Config(plugin, this);
- plugin.setVerbose(config.verboseStartup.getValue());
- // Now load others
- enterprise = new Enterprise(plugin, this);
-
- flatfiles = new ArrayList() {
- private static final long serialVersionUID = 4497798966909062852L;
- {
- add(config);
- add(enterprise);
- }
- };
-
- dbfiles = new ArrayList();
-
- // The following values can be configuration from a database, or from flatfile.
- if (config.enterprise.getValue() && enterprise.configGroups.getValue()) {
- groups = new MySQLGroupsHolder(this);
- dbfiles.add((MySQLGroupsHolder) groups);
- } else {
- groups = new YamlGroupsHolder(plugin, this);
- flatfiles.add((YamlGroupsHolder) groups);
- }
-
- if (config.enterprise.getValue() && enterprise.configRules.getValue()) {
- rules = new MySQLRulesHolder(this);
- dbfiles.add((MySQLRulesHolder) rules);
- } else {
- rules = new YamlRulesHolder(plugin, this);
- flatfiles.add((YamlRulesHolder) rules);
- }
-
- checks = new YamlChecksHolder(plugin, this);
- flatfiles.add((YamlChecksHolder) checks);
-
- InvocationHandler handler;
- if (config.enterprise.getValue() && enterprise.configMagic.getValue()) {
- handler = new MySQLMagicHolder(this);
- magic = (Magic) Proxy.newProxyInstance(Magic.class.getClassLoader(),
- new Class[] { Magic.class },
- handler);
- dbfiles.add((MySQLMagicHolder) handler);
- } else {
- handler = new YamlMagicHolder(plugin, this);
- magic = (Magic) Proxy.newProxyInstance(Magic.class.getClassLoader(),
- new Class[] { Magic.class },
- handler);
- flatfiles.add((YamlMagicHolder) handler);
- }
-
- if (config.enterprise.getValue() && enterprise.configLang.getValue()) {
- handler = new MySQLLangHolder(this);
- lang = (Lang) Proxy.newProxyInstance(Lang.class.getClassLoader(),
- new Class[] { Lang.class },
- handler);
- dbfiles.add((MySQLLangHolder) handler);
- } else {
- handler = new YamlLangHolder(plugin, this);
- lang = (Lang) Proxy.newProxyInstance(Lang.class.getClassLoader(),
- new Class[] { Lang.class },
- handler);
- flatfiles.add((YamlLangHolder) handler);
- }
-
- if (config.enterprise.getValue() && enterprise.syncLevels.getValue()) {
- levels = new MySQLLevelsHolder(this);
- dbfiles.add((MySQLLevelsHolder) levels);
- } else {
- levels = new YamlLevelsHolder(plugin, this);
- flatfiles.add((YamlLevelsHolder) levels);
- }
- // End
-
- for (ConfigurationFile file : flatfiles) {
- file.save();
- checkReload(file);
- }
- }
-
- public void load() {
- for (ConfigurationFile file : flatfiles) {
- file.load();
- checkReload(file);
- }
-
- for (ConfigurationTable table : dbfiles)
- table.load();
-
- if (manager.getBackend() != null)
- manager.getBackend().updateConfig(this);
-
- if (manager.getCheckManager() != null)
- manager.getCheckManager().loadCheckIgnoreList(this);
- }
-
- private void checkReload(ConfigurationFile file) {
- if (file.needsReload()) {
- file.reload();
- file.setNeedsReload(false);
- }
- }
-
- private void removeOldFiles() {
- ArrayList removed = new ArrayList();
- File configFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.yml");
- if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
- configFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.old"));
- removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
- }
- File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
- if (eventsFile.exists()) {
- eventsFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.old"));
- removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
- }
- if (removed.size() > 0) {
- AntiCheatReloaded.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
- for (String s : removed) {
- AntiCheatReloaded.getPlugin().getLogger().info(s);
- }
- }
- }
-
- public Config getConfig() {
- return config;
- }
-
- public Groups getGroups() {
- return groups;
- }
-
- public Rules getRules() {
- return rules;
- }
-
- public Lang getLang() {
- return lang;
- }
-
- public Enterprise getEnterprise() {
- return enterprise;
- }
-
- public Levels getLevels() {
- return levels;
- }
-
- public Magic getMagic() {
- return magic;
- }
-
- public Checks getChecks() {
- return checks;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationFile.java b/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationFile.java
deleted file mode 100644
index 7b642bd..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationFile.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config;
-
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-public class ConfigurationFile {
-
- private File rawFile;
- private String fileName;
-
- private CommentedConfiguration configFile;
- private FileConfiguration defaultConfigFile;
- private Configuration config;
-
- private AntiCheatReloaded plugin;
-
- private boolean saveDefault;
-
- protected boolean needsReload;
-
- public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
- this(plugin, config, fileName, true);
- }
-
- public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault) {
- this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
- }
-
- public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
- // Can't change with user editing
- this.plugin = plugin;
- this.config = config;
- this.fileName = fileName;
- this.rawFile = rawFile;
- this.saveDefault = saveDefault;
-
- if (saveDefault) {
- InputStreamReader reader = new InputStreamReader(plugin.getResource(fileName));
- defaultConfigFile = YamlConfiguration.loadConfiguration(reader);
- try {
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- load();
- }
-
- public void load() {
- // Can change with user editing
- if (!rawFile.exists()) {
- if (saveDefault) {
- plugin.saveResource(fileName, true);
- } else {
- if (!rawFile.getParentFile().exists()) {
- rawFile.getParentFile().mkdir();
- }
- try {
- rawFile.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- configFile = CommentedConfiguration.loadConfiguration(rawFile);
-
- open();
- }
-
- public void open() {
- // Nothing to do
- }
-
- public void close() {
- // Nothing to do
- }
-
- public void save() {
- close();
- try {
- configFile.save(rawFile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public void reload() {
- save();
- load();
- }
-
- public File getRawFile() {
- return rawFile;
- }
-
- public CommentedConfiguration getConfigFile() {
- return configFile;
- }
-
- public FileConfiguration getDefaultConfigFile() {
- return defaultConfigFile;
- }
-
- public Configuration getConfiguration() {
- return config;
- }
-
- public void setNeedsReload(boolean reload) {
- this.needsReload = reload;
- }
-
- public boolean needsReload() {
- return needsReload;
- }
-
- public class ConfigValue {
-
- private String path;
-
- private Object value = null;
-
- private boolean didLoadDefault;
-
- public ConfigValue(String path) {
- this(path, true);
- }
-
- public ConfigValue(String path, boolean loadDefault) {
- this.path = path;
-
- if (getConfigFile().contains(path)) {
- value = getConfigFile().get(path);
- } else if (loadDefault) {
- getConfigFile().set(path, getDefaultConfigFile().get(path));
- value = getDefaultConfigFile().get(path);
- getConfigFile().set(path, value);
- save();
- didLoadDefault = true;
- }
- }
-
- public String getPath() {
- return path;
- }
-
- @SuppressWarnings("unchecked")
- public T getValue() {
- return (T) value;
- }
-
- public T setValue(T value) {
- getConfigFile().set(path, value);
- save();
- return value;
- }
-
- @SuppressWarnings("unchecked")
- public T getDefaultValue() {
- return (T) getDefaultConfigFile().get(path);
- }
-
- public boolean hasValue() {
- return value != null;
- }
-
- public boolean didLoadDefault() {
- return didLoadDefault;
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationTable.java b/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationTable.java
deleted file mode 100644
index 3614886..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/ConfigurationTable.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config;
-
-import org.bukkit.Bukkit;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.util.enterprise.Database;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.UUID;
-
-public class ConfigurationTable {
-
- private final String table;
- private final Configuration config;
-
- private Database database;
- private String prefix;
- private String serverName;
-
- public ConfigurationTable(Configuration config, String table) {
- this.config = config;
- this.table = table;
-
- load();
- }
-
- public void load() {
- this.database = config.getEnterprise().database;
- this.prefix = database.getPrefix();
- this.serverName = config.getEnterprise().serverName.getValue();
-
- open();
- }
-
- public void open() {
- // Nothing to do
- }
-
- public void reload() {
- // For after sql inserts have been made
- Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
- @Override
- public void run() {
- load();
- }
- });
- }
-
- public Database getDatabase() {
- return database;
- }
-
- public String getFullTable() {
- return prefix + table;
- }
-
- public boolean tableExists() {
- try {
- return getConnection().getMetaData().getTables(null, null, getFullTable(), null).next();
- } catch (SQLException e) {
- e.printStackTrace();
- return false;
- }
- }
-
- public boolean isUUIDFormatted(String colName) {
- String sqlSelect = "SELECT " + colName + " FROM " + getFullTable() + " LIMIT 1";
- String user;
-
- try {
- ResultSet res = getConnection().prepareStatement(sqlSelect).executeQuery();
-
- if (res.next() && (user = res.getString(colName)) != null) {
- try {
- return UUID.fromString(user) != null;
- } catch (IllegalArgumentException e) {}
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- @SuppressWarnings("deprecation")
- public void convertToUUID(String colName) {
- String sqlSelect = "SELECT " + colName + " FROM " + getFullTable();
- String sqlUpdate = "UPDATE " + getFullTable() + " SET " + colName + " = ? WHERE " + colName + " = ?";
-
- try {
- ResultSet res = getConnection().prepareStatement(sqlSelect).executeQuery();
-
- while (res.next()) {
- PreparedStatement stmt = getConnection().prepareStatement(sqlUpdate);
- stmt.setString(1, (Bukkit.getOfflinePlayer(res.getString(1)).getUniqueId().toString()));
- stmt.setString(2, res.getString(1));
-
- stmt.executeUpdate();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public Connection getConnection() {
- return database.getConnection();
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java
deleted file mode 100644
index 1c0a9da..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.files;
-
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-
-public class Config extends ConfigurationFile {
-
- public static final String FILENAME = "config.yml";
-
- public ConfigValue logToConsole;
- public ConfigValue verboseStartup;
- public ConfigValue silentMode;
- public ConfigValue exemptOp;
- public ConfigValue eventChains;
- public ConfigValue enterprise;
- public ConfigValue debugMode;
- public ConfigValue disableBroadcast;
-
- public ConfigValue blockChatSpamSpeed;
- public ConfigValue blockCommandSpamSpeed;
- public ConfigValue blockChatSpamRepetition;
- public ConfigValue blockCommandSpamRepetition;
- public ConfigValue chatSpamActionOne;
- public ConfigValue chatSpamActionTwo;
- public ConfigValue commandSpamActionOne;
- public ConfigValue commandSpamActionTwo;
-
- public ConfigValue logToFile;
-
- public ConfigValue> disabledWorlds;
-
- public ConfigValue notifyEveryVl;
- public ConfigValue maxSetbackDistance;
-
- public Config(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public void open() {
- logToConsole = new ConfigValue("system.log-to-console");
-
- verboseStartup = new ConfigValue("system.verbose-startup");
- silentMode = new ConfigValue("system.silent-mode");
- exemptOp = new ConfigValue("system.exempt-op");
- eventChains = new ConfigValue("system.event-chains");
- enterprise = new ConfigValue("system.enterprise");
- debugMode = new ConfigValue("system.debug-mode");
- disableBroadcast = new ConfigValue("system.disable-broadcast");
-
- blockChatSpamSpeed = new ConfigValue("spam.chat.block-speed");
- blockChatSpamRepetition = new ConfigValue("spam.chat.block-repetition");
- chatSpamActionOne = new ConfigValue("spam.chat.action-one");
- chatSpamActionTwo = new ConfigValue("spam.chat.action-two");
-
- blockCommandSpamSpeed = new ConfigValue("spam.command.block-speed");
- blockCommandSpamRepetition = new ConfigValue("spam.command.block-repetition");
- commandSpamActionOne = new ConfigValue("spam.command.action-one");
- commandSpamActionTwo = new ConfigValue("spam.command.action-two");
-
- logToFile = new ConfigValue("system.log-to-file");
-
- disabledWorlds = new ConfigValue>("disable-in");
-
- notifyEveryVl = new ConfigValue("system.notify-every-vl");
- if (notifyEveryVl.getValue() < 1) {
- notifyEveryVl.setValue(5);
- }
- maxSetbackDistance = new ConfigValue("system.max-setback-distance");
- if (maxSetbackDistance.getValue() < 5) {
- maxSetbackDistance.setValue(50);
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Enterprise.java b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Enterprise.java
deleted file mode 100644
index 1683395..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Enterprise.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.files;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.util.enterprise.Database;
-
-public class Enterprise extends ConfigurationFile {
-
- public static final String FILENAME = "enterprise.yml";
-
- public ConfigValue serverName;
-
- public ConfigValue loggingEnabled;
- public ConfigValue loggingLife;
- public ConfigValue loggingInterval;
-
- public ConfigValue syncLevels;
- public ConfigValue syncInterval;
-
- public ConfigValue configGroups;
- public ConfigValue configRules;
- public ConfigValue configMagic;
- public ConfigValue configLang;
-
- public Database database;
-
- public Enterprise(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public void open() {
- serverName = new ConfigValue("server.name");
-
- loggingEnabled = new ConfigValue("log.enable");
- loggingLife = new ConfigValue("log.life");
- loggingInterval = new ConfigValue("log.interval");
-
- syncLevels = new ConfigValue("sync.levels");
- syncInterval = new ConfigValue("sync.interval");
-
- configGroups = new ConfigValue("config.groups");
- configRules = new ConfigValue("config.rules");
- configMagic = new ConfigValue("config.magic");
- configLang = new ConfigValue("config.lang");
-
- ConfigValue databaseType = new ConfigValue("database.type");
- ConfigValue databaseHostname = new ConfigValue("database.hostname");
- ConfigValue databaseUsername = new ConfigValue("database.username");
- ConfigValue databasePassword = new ConfigValue("database.password");
- ConfigValue databasePrefix = new ConfigValue("database.prefix");
- ConfigValue databaseSchema = new ConfigValue("database.database");
- ConfigValue databasePort = new ConfigValue("database.port");
-
- if (getConfiguration().getConfig().enterprise.getValue()) {
- // Convert database values to Database
- database = new Database(
- Database.DatabaseType.valueOf(databaseType.getValue()),
- databaseHostname.getValue(),
- databasePort.getValue(),
- databaseUsername.getValue(),
- databasePassword.getValue(),
- databasePrefix.getValue(),
- databaseSchema.getValue(),
- serverName.getValue(),
- loggingInterval.getValue(),
- loggingLife.getValue(),
- syncLevels.getValue(),
- syncInterval.getValue()
- );
-
- database.connect();
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLGroupsHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLGroupsHolder.java
deleted file mode 100644
index 173c43e..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLGroupsHolder.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.mysql;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
-import com.rammelkast.anticheatreloaded.config.providers.Groups;
-import com.rammelkast.anticheatreloaded.util.Group;
-
-public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
-
- private static final String TABLE = "groups";
-
- private List groups;
- private int highestLevel;
-
- public MySQLGroupsHolder(Configuration config) {
- super(config, TABLE);
- }
-
- @Override
- public void open() {
- highestLevel = 0;
- groups = new ArrayList();
-
- String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
- " `id` INT NOT NULL AUTO_INCREMENT," +
- " `name` VARCHAR(45) NOT NULL," +
- " `level` INT NOT NULL," +
- " `color` VARCHAR(45) NOT NULL," +
- " `actions` VARCHAR(45) NOT NULL," +
- " PRIMARY KEY (`id`));";
- String sqlPopulate = "INSERT INTO " + getFullTable() +
- " SELECT t.*" +
- " FROM (" +
- " (SELECT 1 as id, 'Medium' as name, 20 as level, 'YELLOW' as color, 'WARN' as actions)" +
- " UNION ALL " +
- " (SELECT 2 as id, 'High' as name, 50 as level, 'RED' as color, 'KICK' as actions)" +
- " ) t;";
- String sqlLoad = "SELECT * FROM " + getFullTable();
-
- try {
- if (!tableExists()) {
- getConnection().prepareStatement(sqlCreate).executeUpdate();
- getConnection().prepareStatement(sqlPopulate).executeUpdate();
- getConnection().commit();
- }
-
- ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
- while (set.next()) {
- String name = set.getString("name");
- int level = set.getInt("level");
- String color = set.getString("color");
- List actions = Arrays.asList(set.getString("actions").split(","));
-
- groups.add(new Group(name, level, color, actions));
- if (level > highestLevel) {
- highestLevel = level;
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public List getGroups() {
- return groups;
- }
-
- @Override
- public int getHighestLevel() {
- return highestLevel;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLangHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLangHolder.java
deleted file mode 100644
index acf60f1..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLangHolder.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.mysql;
-
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
-import com.rammelkast.anticheatreloaded.config.providers.Lang;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-public class MySQLLangHolder extends ConfigurationTable implements InvocationHandler {
-
- private static final String TABLE = "lang";
-
- private HashMap stringValues;
- private HashMap> listValues;
-
- private FileConfiguration defaults;
-
- public MySQLLangHolder(Configuration config) {
- super(config, TABLE);
- }
-
- @Override
- public void open() {
- InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("lang.yml"));
- defaults = YamlConfiguration.loadConfiguration(reader);
- try {
- reader.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
-
- stringValues = new HashMap();
- listValues = new HashMap>();
-
- String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
- " `id` INT NOT NULL AUTO_INCREMENT," +
- " `key` VARCHAR(45) NOT NULL," +
- " `value` TEXT," +
- " PRIMARY KEY (`id`));";
-
- String sqlPopulate = "INSERT INTO " + getFullTable() +
- " (`key`, `value`) " +
- "SELECT t.*" +
- "FROM (";
-
- Method[] methods = Lang.class.getMethods();
- for (int i=1;i<=methods.length;i++) {
- sqlPopulate += "(SELECT ? as `key`, ? as `value`)";
- if (i < methods.length) sqlPopulate += " UNION ALL ";
- }
- sqlPopulate += ") t;";
-
- String sqlLoad = "SELECT * FROM " + getFullTable();
-
- try {
- PreparedStatement insert = getConnection().prepareStatement(sqlPopulate);
- int strings = 1;
- for (int i=1;i<=methods.length;i++) {
- String key = methods[i-1].getName();
- String value = defaults.getString(key);
- insert.setString(strings, key);
- strings++;
- insert.setString(strings, value);
- strings++;
- }
-
- if (!tableExists()) {
- getConnection().prepareStatement(sqlCreate).executeUpdate();
- insert.executeUpdate();
- getConnection().commit();
- }
-
- ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
- while (set.next()) {
- String key = set.getString("key");
- String value = set.getString("value");
- if (value.matches("^\\[.*\\]$")) {
- listValues.put(key, getList(value));
- } else {
- stringValues.put(key, value);
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) {
- String key = method.getName();
-
- if (method.getReturnType() == List.class) {
- if (listValues.containsKey(key)) {
- return listValues.get(key);
- } else if (defaults.getString(key) != null) {
- String value = defaults.getString(key);
- try {
- PreparedStatement s = getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (key, value) VALUES (?, ?)");
- s.setString(1, key);
- s.setString(2, value);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- reload();
- return getList(value);
- }
- } else {
- if (stringValues.containsKey(key)) {
- return stringValues.get(key);
- } else if (defaults.getString(key) != null) {
- String value = defaults.getString(key);
- try {
- PreparedStatement s = getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (key, value) VALUES (?, ?)");
- s.setString(1, key);
- s.setString(2, value);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- reload();
- return value;
- }
- }
- AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
- return "Language error. See console for details.";
- }
-
- private List getList(String value) {
- value = value.substring(1, value.length() - 1);
- ArrayList list = new ArrayList();
- for (String s : value.split(", ")) {
- list.add(s);
- }
- return list;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLevelsHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLevelsHolder.java
deleted file mode 100644
index 722a5f9..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLLevelsHolder.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.mysql;
-
-import org.bukkit.Bukkit;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
-import com.rammelkast.anticheatreloaded.config.providers.Levels;
-import com.rammelkast.anticheatreloaded.util.User;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
-
- private static final String TABLE = "levels";
- private static final String MANUAL_EDIT_TAG = "MANUAL";
-
- private String sqlSave;
- private String sqlLoad;
- private String sqlUpdate;
-
- public MySQLLevelsHolder(Configuration config) {
- super(config, TABLE);
- }
-
- @Override
- public void open() {
- sqlSave = "INSERT INTO " + getFullTable() +
- " (user, level, last_update_server) " +
- "VALUES (?, ?, ?) " +
- "ON DUPLICATE KEY UPDATE " +
- "level = IF(last_update = ?, ?, level+?), " +
- "last_update=CURRENT_TIMESTAMP, " +
- "last_update_server=?";
-
- sqlLoad = "SELECT level, last_update FROM " + getFullTable() + " " +
- "WHERE user = ?";
-
- sqlUpdate = "SELECT level, last_update FROM " + getFullTable() + " " +
- "WHERE user = ? AND last_update <> ? AND last_update_server = ?";
-
- String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
- " `user` VARCHAR(45) NOT NULL," +
- " `level` INT NOT NULL," +
- " `last_update` TIMESTAMP NOT NULL DEFAULT NOW()," +
- " `last_update_server` VARCHAR(45) NOT NULL," +
- " PRIMARY KEY (`user`));";
-
- try {
- if (!tableExists()) {
- getConnection().prepareStatement(sqlCreate).executeUpdate();
- getConnection().commit();
- } else if (!isUUIDFormatted("user")) {
- convertToUUID("user");
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void saveLevelFromUser(final User user) {
- Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
- @Override
- public void run() {
- if (!user.isWaitingOnLevelSync()) {
- AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
- try {
- PreparedStatement statement = getConnection().prepareStatement(sqlSave);
- statement.setString(1, user.getUUID().toString());
- statement.setInt(2, user.getLevel());
- statement.setString(3, getServerName());
- statement.setTimestamp(4, user.getLevelSyncTimestamp());
- statement.setInt(5, user.getLevel());
- statement.setInt(6, user.getLevel());
- statement.setString(7, getServerName());
-
- statement.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- AntiCheatReloaded.getManager().getUserManager().remove(user);
- }
- });
- }
-
- @Override
- public void loadLevelToUser(final User user) {
- Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
- @Override
- public void run() {
- try {
- PreparedStatement statement = getConnection().prepareStatement(sqlLoad);
- statement.setString(1, user.getUUID().toString());
-
- ResultSet set = statement.executeQuery();
-
- boolean has = false;
- while (set.next()) {
- has = true;
- AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
- user.setLevel(set.getInt("level"));
- user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
- }
- if (!has) user.setLevel(0);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- @Override
- public void saveLevelsFromUsers(List users) {
- try {
- PreparedStatement statement = getConnection().prepareStatement(sqlSave);
- for (User user : users) {
- if (!user.isWaitingOnLevelSync()) {
- try {
- statement.setString(1, user.getUUID().toString());
- statement.setInt(2, user.getLevel());
- statement.setString(3, getServerName());
- statement.setTimestamp(4, user.getLevelSyncTimestamp());
- statement.setInt(5, user.getLevel());
- statement.setInt(6, user.getLevel());
- statement.setString(7, getServerName());
-
- statement.addBatch();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- statement.executeBatch();
- getConnection().commit();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void updateLevelToUser(final User user) {
- Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
- @Override
- public void run() {
- try {
- PreparedStatement statement = getConnection().prepareStatement(sqlUpdate);
- statement.setString(1, user.getUUID().toString());
- statement.setTimestamp(2, user.getLevelSyncTimestamp());
- statement.setString(3, MANUAL_EDIT_TAG);
-
- ResultSet set = statement.executeQuery();
-
- while (set.next()) {
- AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
- user.setLevel(set.getInt("level"));
- user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- });
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLMagicHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLMagicHolder.java
deleted file mode 100644
index 857fd46..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLMagicHolder.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.mysql;
-
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
-import com.rammelkast.anticheatreloaded.config.providers.Magic;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-
-public class MySQLMagicHolder extends ConfigurationTable implements InvocationHandler {
-
- private static final String TABLE = "magic";
-
- private HashMap ints;
- private HashMap doubles;
-
- private FileConfiguration defaults;
-
- public MySQLMagicHolder(Configuration config) {
- super(config, TABLE);
- }
-
- @Override
- public void open() {
- InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("magic.yml"));
- defaults = YamlConfiguration.loadConfiguration(reader);
- try {
- reader.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
-
- ints = new HashMap();
- doubles = new HashMap();
-
- String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
- " `id` INT NOT NULL AUTO_INCREMENT," +
- " `key` VARCHAR(45) NOT NULL," +
- " `value_int` INT," +
- " `value_double` DOUBLE," +
- " PRIMARY KEY (`id`));";
-
- String sqlPopulate = "INSERT INTO " + getFullTable() +
- " (`key`, `value_int`, `value_double`) " +
- "SELECT t.*" +
- "FROM (";
-
- Method[] methods = Magic.class.getMethods();
- for (int i=1;i<=methods.length;i++) {
- String key = methods[i-1].getName();
- Object value = defaults.get(key);
- String type1 = methods[i-1].getReturnType().getSimpleName();
- String type2 = type1.equals("int") ? "double" : "int";
- sqlPopulate += "(SELECT '" + key + "' as `key`, " + (type1.equals("int") ? value : "null") + " as value_" + type1 + ", " + (type1.equals("double") ? value : "null") + " as value_" + type2 + ")";
- if (i < methods.length) sqlPopulate += " UNION ALL ";
- }
-
- sqlPopulate += ") t;";
-
- String sqlLoad = "SELECT * FROM " + getFullTable();
-
- try {
- if (!tableExists()) {
- getConnection().prepareStatement(sqlCreate).executeUpdate();
- getConnection().prepareStatement(sqlPopulate).executeUpdate();
- getConnection().commit();
- }
-
- ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
- while (set.next()) {
- String key = set.getString("key");
-
- if (set.getObject("value_int") != null) {
- ints.put(key, set.getInt("value_int"));
- } else if (set.getObject("value_double") != null) {
- doubles.put(key, set.getDouble("value_double"));
- } else {
- AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
- for (int i=1;i<=methods.length;i++) {
- String name = methods[i-1].getName();
- if (name.equalsIgnoreCase(key)) {
- String type = methods[i-1].getReturnType().getSimpleName();
- if (type.equals("int")) {
- ints.put(key, defaults.getInt(key));
- } else if (type.equals("double")) {
- doubles.put(key, defaults.getDouble(key));
- }
- }
- }
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) {
- String key = method.getName();
-
- if (ints.containsKey(key)) {
- return ints.get(key).intValue();
- } else if (doubles.containsKey(key)) {
- return doubles.get(key).doubleValue();
- } else if (defaults.getString(key) != null ) {
- if (method.getReturnType().getSimpleName().equals("int")) {
- int value = defaults.getInt(key);
- try {
- getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (key, value_int) VALUES ('" + key + "' , '" + value + "')").executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- reload();
- return value;
- } else if (method.getReturnType().getSimpleName().equals("double")) {
- double value = defaults.getDouble(key);
- try {
- getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (key, value_double) VALUES ('" + key + "' , '" + value + "')").executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- reload();
- return value;
- }
- }
- AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
- return 0;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLRulesHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLRulesHolder.java
deleted file mode 100644
index 4dac15f..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/mysql/MySQLRulesHolder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.mysql;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
-import com.rammelkast.anticheatreloaded.config.providers.Rules;
-import com.rammelkast.anticheatreloaded.util.rule.Rule;
-
-public class MySQLRulesHolder extends ConfigurationTable implements Rules {
-
- private static final String TABLE = "rules";
-
- private List rules;
-
- public MySQLRulesHolder(Configuration config) {
- super(config, TABLE);
- }
-
- @Override
- public void open() {
- String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
- " `id` INT NOT NULL AUTO_INCREMENT," +
- " `rule` VARCHAR(256) NOT NULL," +
- " PRIMARY KEY (`id`));";
- String sqlPopulate = "INSERT INTO " + getFullTable() +
- " VALUES (1, 'Check_SPIDER < 0 ? Player.KICK : null')";
-
- String sqlLoad = "SELECT * FROM " + getFullTable();
-
- try {
- if (!tableExists()) {
- getConnection().prepareStatement(sqlCreate).executeUpdate();
- getConnection().prepareStatement(sqlPopulate).executeUpdate();
- getConnection().commit();
- }
-
- this.rules = new ArrayList();
- ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
- while (set.next()) {
- String string = set.getString("rule");
- Rule rule = Rule.load(string);
- if (rule != null) {
- this.rules.add(rule);
- } else {
- AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- public List getRules() {
- return rules;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java
deleted file mode 100644
index 704166e..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.config.providers.Checks;
-
-public class YamlChecksHolder extends ConfigurationFile implements Checks {
-
- public static final String FILENAME = "checks.yml";
-
- public YamlChecksHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public void open() {
-
- }
-
- @Override
- public boolean getBoolean(CheckType checkType, String subcheck, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
- .getBoolean(name);
- }
-
- @Override
- public boolean isSubcheckEnabled(CheckType checkType, String subcheck) {
- return this.getBoolean(checkType, subcheck, "enabled");
- }
-
- @Override
- public double getDouble(CheckType checkType, String subcheck, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
- .getDouble(name);
- }
-
- @Override
- public int getInteger(CheckType checkType, String subcheck, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
- .getInt(name);
- }
-
- @Override
- public boolean getBoolean(CheckType checkType, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean(name);
- }
-
- @Override
- public double getDouble(CheckType checkType, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getDouble(name);
- }
-
- @Override
- public int getInteger(CheckType checkType, String name) {
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getInt(name);
- }
-
- @Override
- public boolean isEnabled(CheckType checkType) {
- // If the root of a check has no enabled or disabled option, it has to be configured on a subcheck basis
- if (!this.getConfigFile().isConfigurationSection(checkType.getName().toLowerCase())) {
- Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED
- + "Missing configuration settings for " + checkType.getName() + "!");
- return true;
- }
- if (!this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).contains("enabled"))
- return true;
- return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean("enabled");
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlGroupsHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlGroupsHolder.java
deleted file mode 100644
index 285c804..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlGroupsHolder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import java.util.*;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.config.providers.Groups;
-import com.rammelkast.anticheatreloaded.util.Group;
-
-public class YamlGroupsHolder extends ConfigurationFile implements Groups {
-
- public static final String FILENAME = "groups.yml";
-
- private List groups;
-
- private int highestLevel;
-
- public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public List getGroups() {
- return groups;
- }
-
- @Override
- public int getHighestLevel() {
- return highestLevel;
- }
-
- @Override
- public void open() {
- ConfigValue> groups = new ConfigValue>("groups");
-
- // Convert groups list to Levels
- this.groups = new ArrayList();
- for (String string : groups.getValue()) {
- Group group = Group.load(string);
- if (group == null || group.getLevel() < 0) {
- continue;
- }
-
- this.groups.add(group);
- highestLevel = group.getLevel() > highestLevel ? group.getLevel() : highestLevel;
- }
-
- // Sort groups
- Collections.sort(this.groups, new Comparator() {
- public int compare(Group l1, Group l2) {
- if (l1.getLevel() == l2.getLevel()) {
- return 0;
- } else if (l1.getLevel() < l2.getLevel()) {
- return -1;
- }
- return 1;
- }
- });
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLangHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLangHolder.java
deleted file mode 100644
index aecb917..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLangHolder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-
-public class YamlLangHolder extends ConfigurationFile implements InvocationHandler {
-
- public static final String FILENAME = "lang.yml";
-
- public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public void open() {
- if (new ConfigValue("chat.ban_broadcast").getValue() != null) {
- update();
- }
- }
-
- private void update() {
- new ConfigValue>("ALERT").setValue(new ConfigValue>("alert").getValue());
- new ConfigValue>("WARNING").setValue(new ConfigValue>("warning.player_warning").getValue());
- new ConfigValue>("alert").setValue(null);
- new ConfigValue>("warning.player_warning").setValue(null);
- updateValue("ban.ban_reason", "BAN_REASON");
- updateValue("ban.ban_broadcast", "BAN_BROADCAST");
- updateValue("kick.kick_reason", "KICK_REASON");
- updateValue("kick.kick_broadcast", "KICK_BROADCAST");
- updateValue("chat.warning", "SPAM_WARNING");
- updateValue("chat.kick_reason", "SPAM_KICK_REASON");
- updateValue("chat.kick_broadcast", "SPAM_KICK_BROADCAST");
- updateValue("chat.ban_reason", "SPAM_BAN_REASON");
- updateValue("chat.ban_broadcast", "SPAM_BAN_BROADCAST");
- }
-
- private void updateValue(String oldValue, String newValue) {
- new ConfigValue(newValue).setValue(new ConfigValue(oldValue).getValue());
- new ConfigValue(oldValue).setValue(null);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) {
- String key = method.getName();
-
- if (method.getReturnType() == List.class) {
- ConfigValue> value = new ConfigValue>(key);
- if (value.getValue() != null) {
- return value.getValue();
- }
- } else {
- ConfigValue value = new ConfigValue(key);
- if (value.getValue() != null) {
- return value.getValue();
- }
- }
- AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
- return "Language error. See console for details.";
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLevelsHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLevelsHolder.java
deleted file mode 100644
index ce78d00..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlLevelsHolder.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import java.util.List;
-import java.util.UUID;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.config.providers.Levels;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class YamlLevelsHolder extends ConfigurationFile implements Levels {
-
- public static final String FILENAME = "data/levels.yml";
-
- public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME, false);
- }
-
- @Override
- public void loadLevelToUser(User user) {
- user.setLevel(getLevel(user.getUUID()));
- }
-
- @Override
- public void saveLevelFromUser(User user) {
- saveLevelFromUser(user, true);
- }
-
- private void saveLevelFromUser(User user, boolean remove) {
- saveLevel(user.getUUID(), user.getLevel());
- if (remove) AntiCheatReloaded.getManager().getUserManager().remove(user);
- }
-
- @Override
- public void saveLevelsFromUsers(List users) {
- for (User user : users) {
- saveLevelFromUser(user, false);
- }
- }
-
- @Override
- public void updateLevelToUser(User user) {
- // This method intentionally left blank.
- return;
- }
-
- private int getLevel(UUID uuid) {
- ConfigValue level = new ConfigValue(uuid.toString(), false);
- if (level.hasValue()) {
- return level.getValue();
- } else {
- return 0;
- }
- }
-
- private void saveLevel(UUID uuid, int level) {
- new ConfigValue(uuid.toString(), false).setValue(level);
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlMagicHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlMagicHolder.java
deleted file mode 100644
index 7c54d02..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlMagicHolder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-
-public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
-
- public static final String FILENAME = "magic.yml";
-
- public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) {
- String key = method.getName();
-
- if (method.getReturnType().getSimpleName().equals("int")) {
- return new ConfigValue(key).getValue();
- } else if (method.getReturnType().getSimpleName().equals("double")) {
- return new ConfigValue(key).getValue();
- } else {
- AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
- return -1;
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlRulesHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlRulesHolder.java
deleted file mode 100644
index 7e49614..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlRulesHolder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.holders.yaml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
-import com.rammelkast.anticheatreloaded.config.providers.Rules;
-import com.rammelkast.anticheatreloaded.util.rule.Rule;
-
-public class YamlRulesHolder extends ConfigurationFile implements Rules {
-
- public static final String FILENAME = "rules.yml";
-
- private List rules;
-
- public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
- super(plugin, config, FILENAME);
- }
-
- @Override
- public List getRules() {
- return rules;
- }
-
- @Override
- public void open() {
- ConfigValue> rules = new ConfigValue>("rules");
-
- // Convert rules list to Rules
- this.rules = new ArrayList();
- List tempRules = rules.getValue();
- for (int i = 0; i < tempRules.size(); i++) {
- String string = tempRules.get(i);
-
- if (string.equals("Check_SPIDER < 0 ? Player.KICK : null")) {
- // Default rule, won't ever run so we shouldn't load it; only used as example
- continue;
- }
-
- Rule rule = Rule.load(string);
- if (rule != null) {
- this.rules.add(rule);
- } else {
- AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
- }
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Checks.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Checks.java
deleted file mode 100644
index 846cdda..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Checks.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.config.providers;
-
-import com.rammelkast.anticheatreloaded.check.CheckType;
-
-public interface Checks {
-
- public boolean getBoolean(CheckType checkType, String name);
-
- public boolean getBoolean(CheckType checkType, String subcheck, String name);
-
- public double getDouble(CheckType checkType, String name);
-
- public double getDouble(CheckType checkType, String subcheck, String name);
-
- public int getInteger(CheckType checkType, String name);
-
- public int getInteger(CheckType checkType, String subcheck, String name);
-
- public boolean isEnabled(CheckType checkType);
-
- public boolean isSubcheckEnabled(CheckType checkType, String subcheck);
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Groups.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Groups.java
deleted file mode 100644
index d9ffaf0..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Groups.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.providers;
-
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.util.Group;
-
-public interface Groups {
-
- /**
- * Get all groups.
- *
- * @return List of groups.
- */
- public List getGroups();
-
- /**
- * Get the highest level value assigned to a group.
- * Used as a maximum cap to rising hack levels.
- *
- * @return Highest group level.
- */
- public int getHighestLevel();
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Lang.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Lang.java
deleted file mode 100644
index cf795c3..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Lang.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.providers;
-
-import java.util.List;
-
-public interface Lang {
-
- /**
- * Get the alert to send when a player's hack group changes.
- *
- * @return Alert
- */
- public List ALERT();
-
- /**
- * Get the warning to send players when they enter a group.
- *
- * @return Warning.
- */
- public List WARNING();
-
- /**
- * Get the warning to send players for spamming.
- *
- * @return Spam warning.
- */
- public String SPAM_WARNING();
-
- /**
- * Get the reason for kicking a player for spam.
- *
- * @return Spam kicking reason.
- */
- public String SPAM_KICK_REASON();
-
- /**
- * Get the reason for banning a player for spam.
- *
- * @return Spam banning reason.
- */
- public String SPAM_BAN_REASON();
-
- /**
- * Get the broadcast for kicking a player for spam.
- *
- * @return Spam kicking broadcast.
- */
- public String SPAM_KICK_BROADCAST();
-
- /**
- * Get the broadcast for banning a player for spam.
- *
- * @return Spam banning broadcast.
- */
- public String SPAM_BAN_BROADCAST();
-
- /**
- * Get the reason for banning a player.
- *
- * @return Banning reason.
- */
- public String BAN_REASON();
-
- /**
- * Get the broadcast for banning a player.
- *
- * @return Banning broadcast.
- */
- public String BAN_BROADCAST();
-
- /**
- * Get the reason for kicking a player.
- *
- * @return Kicking reason.
- */
- public String KICK_REASON();
-
- /**
- * Get the broadcast for kicking a player.
- *
- * @return Kicking broadcast.
- */
- public String KICK_BROADCAST();
-
-
- /**
- * Get the alert prefix for staff and debug.
- *
- * @return Alert prefix.
- */
- public String ALERT_PREFIX();
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Levels.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Levels.java
deleted file mode 100644
index 86b1345..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Levels.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.providers;
-
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.util.User;
-
-public interface Levels {
-
- /**
- * Checks for a stored level for this user, and loads it to their object if found.
- *
- * @param user User to load.
- */
- public void loadLevelToUser(User user);
-
- /**
- * Saves the user's level to storage.
- *
- * @param user User to save.
- */
- public void saveLevelFromUser(User user);
-
- /**
- * Saves a list of user's levels to storage.
- * Used on server shutdown / reload.
- *
- * @param users List of users to save.
- */
- public void saveLevelsFromUsers(List users);
-
- /**
- * Check to see if the user's level has been manually changed since it was loaded, and update it if needed
- *
- * @param user User to update.
- */
- public void updateLevelToUser(User user);
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java
deleted file mode 100644
index f027d68..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.providers;
-
-/**
- * Magic number class. Modifications to values in magic.yml will be accepted here.
- *
- * Note that although each value is documented, changing it may have unintended side-effects. For instance, setting something to 0 that the plugin then uses as a dividend will result in an error.
- * Also realize that the smaller (more precise) a value is, the less you should change it; it's probably small for a reason. The larger a value is, the safer it is to make larger modifications to it.
- *
- * How to read the value documentation:
- *
- * First, you will see a description of the value. Then, you will see a type:
- * Type SYSTEM: This is a millisecond value used to compare past and future events with the current SYSTEM time. Remember, 1000 ms = 1 second.
- * Type INTEGER: This is a regular number. It's typically used as something trivial, such as how many times X event can occur.
- * Type DOUBLE: This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
- *
- * After the type, you may see a recommendation labeled as 'Leniency'. This means 'In order to add leniency to this value, do X'
- * The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the SYSTEM to not judge the people being checked so vigorously.
- * Some values may not have a leniency recommendation because they are internal numbers used for running checks. Values without these recommendations would be best left alone.
- */
-
-public interface Magic {
- /**
- * Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
- */
- public int ENTERED_EXITED_TIME();
- /**
- * Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
- */
- public int TELEPORT_TIME();
- /**
- * Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
- */
- public int JOIN_TIME();
- /**
- * Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
- */
- public int DAMAGE_TIME();
- /**
- * Time to exempt a player from moving because of taking damage with knockback effects; Type=SYSTEM, Leniency=INCREASE.
- */
- public int KNOCKBACK_DAMAGE_TIME();
- /**
- * Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
- */
- public int EXPLOSION_DAMAGE_TIME();
- /**
- * Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
- */
- public int VELOCITY_EXTENSION();
- /**
- * Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
- */
- public int VELOCITY_TIME();
- /**
- * Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE.
- */
- public int VELOCITY_PREVENT();
- /**
- * Maximum amount of velocity tracks; Type=INTEGER, Leniency=INCREASE.
- */
- public int VELOCITY_MAXTIMES();
- /**
- * Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
- */
- public int TELEPORT_MIN();
- /**
- * The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
- */
- public int LAG_DETERMINATION();
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Rules.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Rules.java
deleted file mode 100644
index 097d24e..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Rules.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.providers;
-
-import java.util.List;
-
-import com.rammelkast.anticheatreloaded.util.rule.Rule;
-
-public interface Rules {
-
- /**
- * Get all rules.
- *
- * @return List of rules.
- */
- public List getRules();
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java b/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java
deleted file mode 100644
index 64a4cfe..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.config.yaml;
-
-import org.apache.commons.lang.Validate;
-import org.bukkit.Bukkit;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.configuration.file.YamlConstructor;
-import org.bukkit.configuration.file.YamlRepresenter;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.representer.Representer;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayDeque;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-
-/**
- * An extension of {@link org.bukkit.configuration.file.YamlConfiguration} which preserves comments.
- * Note that this implementation is not synchronized.
- *
- * Some overridden code has been moved to this file from its parent & modified.
- */
-public class CommentedConfiguration extends YamlConfiguration {
- private Map comments = new HashMap();
-
- private final DumperOptions yamlOptions = new DumperOptions();
- private final Representer yamlRepresenter = new YamlRepresenter();
- private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
-
- @Override
- public void loadFromString(String contents) throws InvalidConfigurationException {
- Validate.notNull(contents, "Contents cannot be null");
-
- Map, ?> input;
- try {
- input = (Map, ?>) yaml.load(contents);
- } catch (YAMLException e) {
- throw new InvalidConfigurationException(e);
- } catch (ClassCastException e) {
- throw new InvalidConfigurationException("Top level is not a Map.");
- }
-
- /** - CommentedConfiguration
- String header = parseHeader(contents);
- if (header.length() > 0) {
- options().header(header);
- }
- **/
-
- if (input != null) {
- convertMapsToSections(input, this);
- }
-
- // Begin CommentedConfiguration
- int i = 0;
- int blank = 0;
- String[] lines = contents.split("\n");
- while (i < lines.length) {
- if (lines[i].trim().equalsIgnoreCase("")) {
- i++;
- blank++;
- continue;
- }
- if (lines[i].contains(COMMENT_PREFIX)) {
- comments.put(i - blank, lines[i]);
- }
- i++;
- }
- // End CommentedConfiguration
- }
-
- @Override
- public String saveToString() {
- yamlOptions.setIndent(options().indent());
- yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
-
- // String header = buildHeader(); - CommentedConfiguration
- String dump = yaml.dump(getValues(false));
-
- if (dump.equals(BLANK_CONFIG)) {
- dump = "";
- }
-
- // Begin CommentedConfiguration
- StringBuilder builder = new StringBuilder();
-
- String[] lines = dump.split("\n");
- ArrayDeque queue = new ArrayDeque();
- for (String string : lines) {
- queue.add(string);
- }
-
- int i = 0;
- while (queue.size() > 0) {
- if (comments.containsKey(i)) {
- builder.append(comments.get(i));
-
- // Handle subsequent comments
- int b = i;
- while (true) {
- b++;
- if (comments.containsKey(b)) {
- builder.append('\n');
- builder.append(comments.get(b));
- } else {
- break;
- }
- }
- builder.append('\n');
- i = b;
- }
-
- builder.append(queue.getFirst());
- builder.append('\n');
- queue.pop();
- i++;
- }
- // End CommentedConfiguration
-
- return builder.toString();
- }
-
- /**
- * Creates a new {@link CommentedConfiguration}, loading from the given file.
- *
- * Any errors loading the Configuration will be logged and then ignored.
- * If the specified input is not a valid config, a blank config will be returned.
- *
- * @param file Input file
- * @return Resulting configuration
- * @throws IllegalArgumentException Thrown if file is null
- */
- public static CommentedConfiguration loadConfiguration(File file) {
- Validate.notNull(file, "File cannot be null");
-
- CommentedConfiguration config = new CommentedConfiguration();
-
- try {
- config.load(file);
- } catch (FileNotFoundException ex) {
- } catch (IOException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
- } catch (InvalidConfigurationException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
- }
-
- return config;
- }
-
- /**
- * Creates a new {@link CommentedConfiguration}, loading from the given stream.
- *
- * Any errors loading the Configuration will be logged and then ignored.
- * If the specified input is not a valid config, a blank config will be returned.
- *
- * @param stream Input stream
- * @return Resulting configuration
- * @throws IllegalArgumentException Thrown if stream is null
- */
- public static CommentedConfiguration loadConfiguration(InputStream stream) {
- Validate.notNull(stream, "Stream cannot be null");
-
- CommentedConfiguration config = new CommentedConfiguration();
-
- try {
- InputStreamReader reader = new InputStreamReader(stream);
- config.load(reader);
- reader.close();
- } catch (IOException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
- } catch (InvalidConfigurationException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
- }
-
- return config;
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java
deleted file mode 100644
index 13c9bfe..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.event;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.block.BlockPlaceEvent;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
-
-public class BlockListener extends EventListener {
-
- @EventHandler(ignoreCancelled = true)
- public void onBlockPlace(BlockPlaceEvent event) {
- final Player player = event.getPlayer();
- boolean noHack = true;
- if (getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
- CheckResult result = getBackend().checkFastPlace(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.FAST_PLACE, result.getSubCheck());
- noHack = false;
- }
- }
-
- if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
- CheckResult result = IllegalInteract.performCheck(player, event);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
- noHack = false;
- }
- }
- if (noHack) {
- decrease(player);
- getBackend().logBlockPlace(player);
- }
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onBlockBreak(BlockBreakEvent event) {
- final Player player = event.getPlayer();
- boolean noHack = true;
- CheckResult result;
- if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
- result = IllegalInteract.performCheck(player, event);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
- noHack = false;
- }
- }
- if (noHack) {
- decrease(player);
- }
- getBackend().logBlockBreak(player);
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java
deleted file mode 100644
index a52c5f4..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.event;
-
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.entity.Creeper;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
-import org.bukkit.event.entity.EntityRegainHealthEvent;
-import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
-import org.bukkit.event.entity.EntityShootBowEvent;
-import org.bukkit.event.entity.FoodLevelChangeEvent;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
-import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class EntityListener extends EventListener {
-
- @EventHandler
- public void onEntityShootBow(EntityShootBowEvent event) {
- if (event.getEntity() instanceof Player) {
- Player player = (Player) event.getEntity();
- if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) {
- CheckResult result = getBackend().checkFastBow(player, event.getForce());
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck());
- } else {
- decrease(player);
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onEntityRegainHealth(EntityRegainHealthEvent event) {
- if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
- Player player = (Player) event.getEntity();
- if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
- CheckResult result = getBackend().checkFastHeal(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck());
- } else {
- decrease(player);
- getBackend().logHeal(player);
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onFoodLevelChange(FoodLevelChangeEvent event) {
- if (event.getEntity() instanceof Player) {
- Player player = (Player) event.getEntity();
- if (player.getFoodLevel() < event.getFoodLevel() && getCheckManager().willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
- {
- CheckResult result = getBackend().checkFastEat(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck());
- } else {
- decrease(player);
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
- public void onEntityDamage(EntityDamageEvent event) {
- boolean noHack = true;
- if (event instanceof EntityDamageByEntityEvent) {
- EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
- if (e.getDamager() instanceof Player) {
- if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
- CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
- }
- }
- if (event.getEntity() instanceof Player) {
- Player player = (Player) event.getEntity();
- if (e.getDamager() instanceof Player) {
- Player p = (Player) e.getDamager();
- getBackend().logDamage(p, 1);
- int value = VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
- getBackend().logDamage(player, value);
- } else {
- if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
- getBackend().logDamage(player, 3);
- } else {
- getBackend().logDamage(player, 1);
- }
- }
- }
- if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
- Player player = (Player) e.getDamager();
- if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
- CheckResult result = KillAuraCheck.checkAngle(player, event);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
- noHack = false;
- }
- }
- if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
- CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
- noHack = false;
- }
- }
- if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
- CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
- noHack = false;
- }
- }
- if (noHack) {
- decrease(player);
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java
deleted file mode 100644
index 5bb4a16..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.event;
-
-import java.text.DecimalFormat;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Listener;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
-import com.rammelkast.anticheatreloaded.manage.CheckManager;
-import com.rammelkast.anticheatreloaded.manage.UserManager;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class EventListener implements Listener {
- private static final Map USAGE_LIST = new EnumMap(CheckType.class);
- private static final Map DECREASE_LIST = new HashMap();
- private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
- private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
- private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
- private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
- private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
- private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
-
- public static void log(String message, Player player, CheckType type, String subcheck) {
- User user = getUserManager().getUser(player.getUniqueId());
- if (user == null)
- return;
-
- boolean debugMode = CONFIG.getConfig().debugMode.getValue();
- int vlForType = type.getUses(player.getUniqueId()) + 1;
- int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
- String prefix = ChatColor.translateAlternateColorCodes('&', CONFIG.getLang().ALERT_PREFIX());
- if (message == null || message.equals("")) {
- if (debugMode) {
- message = prefix + player.getName() + " failed "
- + type.getName();
- } else {
- message = prefix + player.getName() + " failed "
- + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")";
- }
- } else {
- if (debugMode) {
- message = prefix + player.getName() + " failed "
- + type.getName() + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
- + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
- + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
- } else {
- message = prefix
- + player.getName() + " failed " + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"
- + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY
- + (subcheck != null ? ("type: " + subcheck.toLowerCase() + ", ") : "") + "ping: " + user.getPing() + "ms"
- + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
- }
- }
-
- logCheat(type, user);
- if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
- AntiCheatReloaded.getManager().log(message);
- }
- removeDecrease(user);
-
- if (debugMode) {
- player.sendMessage(message);
- return;
- }
-
- if (vlForType % notifyEveryVl == 0) {
- AntiCheatReloaded.getPlugin().sendToStaff(message);
- }
- }
-
- private static void logCheat(CheckType type, User user) {
- USAGE_LIST.put(type, getCheats(type) + 1);
- // Ignore plugins that are creating NPCs with no names (why the hell)
- if (user != null && user.getUUID() != null) {
- type.logUse(user);
- if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
- CONFIG.getEnterprise().database.logEvent(user, type);
- }
- }
- }
-
- public void resetCheck(CheckType type) {
- USAGE_LIST.put(type, 0);
- }
-
- public static int getCheats(CheckType type) {
- int x = 0;
- if (USAGE_LIST.get(type) != null) {
- x = USAGE_LIST.get(type);
- }
- return x;
- }
-
- private static void removeDecrease(User user) {
- int x = 0;
- // Ignore plugins that are creating NPCs with no names
- if (user.getUUID() != null) {
- if (DECREASE_LIST.get(user.getUUID()) != null) {
- x = DECREASE_LIST.get(user.getUUID());
- x -= 2;
- if (x < 0) {
- x = 0;
- }
- }
- DECREASE_LIST.put(user.getUUID(), x);
- }
- }
-
- public static void decrease(Player player) {
- User user = getUserManager().getUser(player.getUniqueId());
- // Ignore plugins that are creating NPCs with no names
- if (user.getUUID() != null) {
- int x = 0;
-
- if (DECREASE_LIST.get(user.getUUID()) != null) {
- x = DECREASE_LIST.get(user.getUUID());
- }
-
- x += 1;
- DECREASE_LIST.put(user.getUUID(), x);
-
- if (x >= 10) {
- user.decreaseLevel();
- DECREASE_LIST.put(user.getUUID(), 0);
- }
- }
- }
-
- public static CheckManager getCheckManager() {
- return CHECK_MANAGER;
- }
-
- public static AntiCheatManager getManager() {
- return AntiCheatReloaded.getManager();
- }
-
- public static Backend getBackend() {
- return BACKEND;
- }
-
- public static UserManager getUserManager() {
- return USER_MANAGER;
- }
-
- public static AntiCheatReloaded getPlugin() {
- return PLUGIN;
- }
-
- public static Configuration getConfig() {
- return CONFIG;
- }
-
- public static boolean silentMode() {
- return CONFIG.getConfig().silentMode.getValue();
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/InventoryListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/InventoryListener.java
deleted file mode 100644
index 7aa35b4..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/InventoryListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.event;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryCloseEvent;
-import org.bukkit.event.inventory.InventoryOpenEvent;
-import org.bukkit.event.inventory.InventoryType;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.util.User;
-
-public class InventoryListener extends EventListener {
-
- @EventHandler
- public void onInventoryClick(InventoryClickEvent event) {
- if (!event.isRightClick() && !event.isShiftClick() && event.getWhoClicked() instanceof Player) {
- Player player = (Player) event.getWhoClicked();
- if (getCheckManager().willCheck(player, CheckType.FAST_INVENTORY)) {
- CheckResult result = getBackend().checkInventoryClicks(player);
- if (result.failed()) {
- if (!silentMode()) {
- //getUserManager().getUser(player.getName()).restoreInventory(event.getInventory());
- player.getInventory().clear();
- event.setCancelled(true);
- }
- log(result.getMessage(), player, CheckType.FAST_INVENTORY, result.getSubCheck());
- } else {
- decrease(player);
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onInventoryOpen(InventoryOpenEvent event) {
- if (event.getInventory().getType() != InventoryType.BEACON) {
- getUserManager().getUser(event.getPlayer().getUniqueId()).setInventorySnapshot(event.getInventory().getContents());
- }
- }
-
- @EventHandler
- public void onInventoryClose(InventoryCloseEvent event) {
- User user = getUserManager().getUser(event.getPlayer().getUniqueId());
- if (user != null) {
- user.removeInventorySnapshot();
- }
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java
deleted file mode 100644
index ecaccab..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.event;
-
-import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Arrow;
-import org.bukkit.entity.Boat;
-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.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerAnimationEvent;
-import org.bukkit.event.player.PlayerBedEnterEvent;
-import org.bukkit.event.player.PlayerBedLeaveEvent;
-import org.bukkit.event.player.PlayerChangedWorldEvent;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.player.PlayerGameModeChangeEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerRespawnEvent;
-import org.bukkit.event.player.PlayerTeleportEvent;
-import org.bukkit.event.player.PlayerToggleFlightEvent;
-import org.bukkit.event.player.PlayerToggleSneakEvent;
-import org.bukkit.event.player.PlayerToggleSprintEvent;
-import org.bukkit.event.player.PlayerVelocityEvent;
-import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
-import org.bukkit.inventory.EquipmentSlot;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.CheckResult;
-import com.rammelkast.anticheatreloaded.check.CheckType;
-import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
-import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
-import com.rammelkast.anticheatreloaded.check.movement.BoatFlyCheck;
-import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
-import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
-import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
-import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
-import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck;
-import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
-import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
-import com.rammelkast.anticheatreloaded.util.Distance;
-import com.rammelkast.anticheatreloaded.util.Permission;
-import com.rammelkast.anticheatreloaded.util.User;
-import com.rammelkast.anticheatreloaded.util.Utilities;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-import com.rammelkast.anticheatreloaded.util.XMaterial;
-
-public class PlayerListener extends EventListener {
-
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
- Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)
- && !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
- CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
- if (result.failed()) {
- event.setCancelled(!silentMode());
- if (!silentMode())
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
- getBackend().processCommandSpammer(player);
- log(null, player, CheckType.COMMAND_SPAM, result.getSubCheck());
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
- if (!event.isFlying()) {
- getBackend().logEnterExit(event.getPlayer());
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
- if (event.getNewGameMode() != GameMode.CREATIVE) {
- getBackend().logEnterExit(event.getPlayer());
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onProjectileLaunch(ProjectileLaunchEvent event) {
- if (event.getEntity().getShooter() instanceof Player) {
- Player player = (Player) event.getEntity().getShooter();
-
- if (event.getEntity() instanceof Arrow) {
- return;
- }
-
- if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
- CheckResult result = getBackend().checkProjectile(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.FAST_PROJECTILE, result.getSubCheck());
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerTeleport(PlayerTeleportEvent event) {
- getBackend().logTeleport(event.getPlayer());
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
- getBackend().logTeleport(event.getPlayer());
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
- Player player = event.getPlayer();
- if (event.isSneaking()) {
- if (getCheckManager().willCheck(player, CheckType.SNEAK)) {
- CheckResult result = getBackend().checkSneakToggle(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.SNEAK, result.getSubCheck());
- }
- }
- // getBackend().logToggleSneak(event.getPlayer());
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerVelocity(PlayerVelocityEvent event) {
- Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.FLIGHT)) {
- if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
- event.setCancelled(!silentMode());
- return;
- }
- getBackend().logVelocity(player);
- }
-
- // Part of Velocity check
- User user = AntiCheatReloaded.getManager().getUserManager()
- .getUser(event.getPlayer().getUniqueId());
- if (!user.getMovementManager().onGround)
- return;
- double motionY = event.getVelocity().getY();
- user.getMovementManager().velocityExpectedMotionY = motionY;
- // End part of Velocity check
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onPlayerChat(AsyncPlayerChatEvent event) {
- Player player = event.getPlayer();
-
- if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
- CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
- if (result.failed()) {
- event.setCancelled(!silentMode());
- if (!result.getMessage().equals("") && !silentMode()) {
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
- }
- getBackend().processChatSpammer(player);
- AntiCheatReloaded.sendToMainThread(new Runnable() {
- @Override
- public void run() {
- log(null, player, CheckType.CHAT_SPAM, result.getSubCheck());
- }
- });
- }
- }
-
- if (getCheckManager().willCheck(player, CheckType.CHAT_UNICODE)) {
- CheckResult result = getBackend().checkChatUnicode(player, event.getMessage());
- if (result.failed()) {
- event.setCancelled(true);
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
- AntiCheatReloaded.sendToMainThread(new Runnable() {
- @Override
- public void run() {
- log(null, player, CheckType.CHAT_UNICODE, result.getSubCheck());
- }
- });
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerKick(PlayerKickEvent event) {
- getBackend().garbageClean(event.getPlayer());
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event) {
- getBackend().garbageClean(event.getPlayer());
-
- User user = getUserManager().getUser(event.getPlayer().getUniqueId());
-
- getConfig().getLevels().saveLevelFromUser(user);
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerVehicleCollide(VehicleEntityCollisionEvent event) {
- if (!(event.getVehicle() instanceof Boat) || !(event.getEntity() instanceof Player))
- return;
-
- Player player = (Player) event.getEntity();
- getBackend().logBoatCollision(player);
- }
-
- @EventHandler
- public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
- Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
- CheckResult result = getBackend().checkSprintHungry(event);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.SPRINT, result.getSubCheck());
- } else {
- decrease(player);
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- PlayerInventory inv = player.getInventory();
- if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- ItemStack itemInHand;
- if (VersionUtil.isBountifulUpdate()) {
- itemInHand = VersionUtil.getItemInHand(player);
- } else {
- itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand()
- : inv.getItemInOffHand());
- }
-
- if (itemInHand.getType() == Material.BOW) {
- getBackend().logBowWindUp(player);
- } else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
- getBackend().logEatingStart(player);
- }
-
- if (!VersionUtil.isBountifulUpdate()) {
- if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
- ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
- if (player.isGliding()) {
- // TODO config max elytra height?
- ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
- }
- }
- }
- }
-
- Block block = event.getClickedBlock();
- if (block != null
- && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
- if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
- CheckResult result = IllegalInteract.performCheck(player, event);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onPlayerDropItem(PlayerDropItemEvent event) {
- Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
- CheckResult result = getBackend().checkFastDrop(player);
- if (result.failed()) {
- event.setCancelled(!silentMode());
- log(result.getMessage(), player, CheckType.ITEM_SPAM, result.getSubCheck());
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onPlayerEnterBed(PlayerBedEnterEvent event) {
- if (event.getBed().getType().name().endsWith("BED"))
- return;
- getBackend().logEnterExit(event.getPlayer());
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onPlayerExitBed(PlayerBedLeaveEvent event) {
- if (event.getBed().getType().name().endsWith("BED"))
- return;
- getBackend().logEnterExit(event.getPlayer());
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerAnimation(PlayerAnimationEvent event) {
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) {
- Player player = event.getPlayer();
- getBackend().logJoin(player);
-
- User user = new User(player.getUniqueId());
- user.setIsWaitingOnLevelSync(true);
- getConfig().getLevels().loadLevelToUser(user);
- getUserManager().addUser(user);
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
-
- if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
- player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY
- + "Your version of AntiCheatReloaded is outdated! You can download "
- + AntiCheatReloaded.getUpdateManager().getLatestVersion()
- + " from the Spigot forums or DevBukkit.");
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onPlayerMove(PlayerMoveEvent event) {
- final Player player = event.getPlayer();
- if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
- final Location from = event.getFrom();
- final Location to = event.getTo();
-
- final Distance distance = new Distance(from, to);
- final double y = distance.getYDifference();
-
- final User user = getUserManager().getUser(player.getUniqueId());
- user.setTo(to.getX(), to.getY(), to.getZ());
- user.getMovementManager().handle(player, from, to, distance);
-
- if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
- CheckResult result = FlightCheck.runCheck(player, distance);
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.FLIGHT, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
- CheckResult result = ElytraCheck.runCheck(player, distance);
- if (result.failed()) {
- log(result.getMessage(), player, CheckType.ELYTRAFLY, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.BOATFLY)) {
- CheckResult result = BoatFlyCheck.runCheck(player, user.getMovementManager(), to);
- if (result.failed()) {
- if (!silentMode()) {
- player.eject();
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.BOATFLY, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
- && event.getFrom().getY() > event.getTo().getY()) {
- CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
- if (result.failed()) {
- if (!silentMode()) {
- int data = result.getData() > 3 ? 3 : result.getData();
- Location newloc = new Location(player.getWorld(), event.getFrom().getX(),
- event.getFrom().getY() + data, event.getFrom().getZ());
- if (newloc.getBlock().getType() == Material.AIR) {
- event.setTo(newloc);
- } else {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- player.damage(3);
- }
- log(result.getMessage(), player, CheckType.VCLIP, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.NOFALL)
- && getCheckManager().willCheck(player, CheckType.FLIGHT)
- && !Utilities.isClimbableBlock(player.getLocation().getBlock())
- && event.getFrom().getY() > event.getTo().getY()) {
- CheckResult result = getBackend().checkNoFall(player, y);
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- // TODO better handling of this
- }
- log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck());
- }
- }
-
- if (event.getTo() != event.getFrom()) {
- double x = distance.getXDifference();
- double z = distance.getZDifference();
- if (getCheckManager().willCheckQuick(player, CheckType.SPEED)
- && getCheckManager().willCheck(player, CheckType.FLIGHT)) {
- if (event.getFrom().getY() < event.getTo().getY()) {
- CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance);
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
- }
- }
- CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
- CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
- if (result.failed()) {
- if (!silentMode()) {
- // TODO check this
- player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
- }
- log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
- CheckResult result = getBackend().checkSpider(player, y);
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.SPIDER, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
- // Does not use y value created before because that value is absolute
- CheckResult result = FastLadderCheck.runCheck(player,
- event.getTo().getY() - event.getFrom().getY());
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
- CheckResult result = StrafeCheck.runCheck(player, x, z, event.getFrom(), event.getTo());
- if (result.failed()) {
- if (!silentMode()) {
- event.setTo(user.getGoodLocation(from.clone()));
- }
- log(result.getMessage(), player, CheckType.STRAFE, result.getSubCheck());
- }
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
- CheckResult result = AimbotCheck.runCheck(player, event);
- if (result.failed()) {
- log(result.getMessage(), player, CheckType.AIMBOT, result.getSubCheck());
- }
- }
- if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
- CheckResult result = VelocityCheck.runCheck(player, distance);
- if (result.failed()) {
- log(result.getMessage(), player, CheckType.VELOCITY, result.getSubCheck());
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onRespawn(PlayerRespawnEvent event) {
- getBackend().logTeleport(event.getPlayer());
- }
-
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/VehicleListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/VehicleListener.java
deleted file mode 100644
index 765f8fa..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/VehicleListener.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.rammelkast.anticheatreloaded.event;
-
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.vehicle.VehicleDestroyEvent;
-import org.bukkit.event.vehicle.VehicleEnterEvent;
-import org.bukkit.event.vehicle.VehicleExitEvent;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.util.VersionUtil;
-
-public class VehicleListener extends EventListener {
-
- @EventHandler(ignoreCancelled = true)
- public void onVehicleEnter(VehicleEnterEvent event) {
- if (event.getEntered() instanceof Player) {
- getBackend().logEnterExit((Player) event.getEntered());
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onVehicleExit(VehicleExitEvent event) {
- if (event.getExited() instanceof Player) {
- getBackend().logEnterExit((Player) event.getExited());
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-
- @SuppressWarnings("deprecation")
- @EventHandler(ignoreCancelled = true)
- public void onVehicleDestroy(VehicleDestroyEvent event) {
- if (VersionUtil.isBountifulUpdate()) {
- if (event.getVehicle().getPassenger() != null) {
- Entity entity = event.getVehicle().getPassenger();
- if (entity instanceof Player) {
- getBackend().logEnterExit((Player) entity);
- }
- }
- } else {
- if (!event.getVehicle().getPassengers().isEmpty()) {
- for (Entity entity : event.getVehicle().getPassengers()) {
- if (entity instanceof Player) {
- getBackend().logEnterExit((Player) entity);
- }
- }
- }
- }
-
- AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
- }
-}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/AntiCheatManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/AntiCheatManager.java
deleted file mode 100644
index 0ffac73..0000000
--- a/src/main/java/com/rammelkast/anticheatreloaded/manage/AntiCheatManager.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * AntiCheatReloaded for Bukkit and Spigot.
- * Copyright (c) 2012-2015 AntiCheat Team
- * Copyright (c) 2016-2020 Rammelkast
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.-
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.rammelkast.anticheatreloaded.manage;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-import org.bukkit.plugin.RegisteredListener;
-
-import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
-import com.rammelkast.anticheatreloaded.check.Backend;
-import com.rammelkast.anticheatreloaded.config.Configuration;
-
-/**
- * The internal hub for all managers.
- */
-public class AntiCheatManager {
- private static AntiCheatReloaded plugin = null;
- private static Configuration configuration;
- private static UserManager userManager = null;
- private static CheckManager checkManager = null;
- private static LoggingManager loggingManager = null;
- private static Backend backend = null;
- private static Map eventchains = new ConcurrentHashMap();
- private static Map eventcache = new ConcurrentHashMap