mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Added #66 and fixed issue with Velocity check
This commit is contained in:
1 parent
aa9fa9b290
commit
27bb684736
17 files changed
+106
-113
No files matched your search
@@ -51,12 +51,13 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class AntiCheatReloaded extends JavaPlugin {
|
||||
|
||||
public static final List<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
||||
|
||||
private static AntiCheatManager manager;
|
||||
private static AntiCheatReloaded plugin;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static boolean developer;
|
||||
private static ProtocolManager protocolManager;
|
||||
private static SecureRandom random;
|
||||
private static Long loadTime;
|
||||
@@ -232,19 +233,11 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
manager = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public static boolean developerMode() {
|
||||
return developer;
|
||||
}
|
||||
|
||||
public static void setDeveloperMode(boolean b) {
|
||||
developer = b;
|
||||
}
|
||||
|
||||
|
||||
public static void debugLog(final String string) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||
public void run() {
|
||||
if (developer) {
|
||||
if (getManager().getConfiguration().getConfig().debugMode.getValue()) {
|
||||
manager.debugLog("[DEBUG] " + string);
|
||||
}
|
||||
}
|
||||
@@ -283,7 +276,14 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void sendToStaff(String message) {
|
||||
Bukkit.broadcast(message, "anticheat.system.alert");
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (player.hasPermission("anticheat.system.alert")) {
|
||||
if (!MUTE_ENABLED_MODS.contains(player.getUniqueId())) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
}
|
||||
|
||||
public static UpdateManager getUpdateManager() {
|
||||
|
||||
@@ -510,16 +510,12 @@ public class Backend {
|
||||
fastPlaceViolation.put(uuid, 0);
|
||||
}
|
||||
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
|
||||
AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value "
|
||||
+ fastPlaceViolation.get(uuid));
|
||||
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
|
||||
AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
|
||||
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
||||
lastBlockPlaced.put(uuid, time);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
|
||||
+ fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
|
||||
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
||||
AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid);
|
||||
fastPlaceViolation.put(uuid, 0);
|
||||
}
|
||||
} else if (lastBlockPlaced.containsKey(uuid)) {
|
||||
|
||||
@@ -41,34 +41,34 @@ public class VelocityCheck {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
|
||||
public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
|
||||
if (AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
|
||||
|| AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
|
||||
public static void runCheck(EntityDamageByEntityEvent e, final Player player) {
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.VELOCITY))
|
||||
return;
|
||||
final Location then = p.getLocation();
|
||||
final Location then = player.getLocation();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!p.isOnline())
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
if (then.distance(p.getLocation()) < 0.125) {
|
||||
if (!VL_COUNT.containsKey(p.getUniqueId()))
|
||||
VL_COUNT.put(p.getUniqueId(), 1);
|
||||
if (then.distance(player.getLocation()) < 0.125) {
|
||||
if (!VL_COUNT.containsKey(player.getUniqueId()))
|
||||
VL_COUNT.put(player.getUniqueId(), 1);
|
||||
else {
|
||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
VL_COUNT.put(player.getUniqueId(), VL_COUNT.get(player.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(player.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.VELOCITY_MAX_FLAGS()) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED,
|
||||
"had zero/low velocity "
|
||||
+ VL_COUNT.get(p.getUniqueId()) + " times (max="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_MAX_FLAGS()
|
||||
+ ", dist=" + then.distance(p.getLocation()) + ")").getMessage(),
|
||||
p, CheckType.VELOCITY);
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
EventListener.log(
|
||||
new CheckResult(CheckResult.Result.FAILED,
|
||||
"had zero/low velocity " + VL_COUNT.get(player.getUniqueId()) + " times (max="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.VELOCITY_MAX_FLAGS()
|
||||
+ ", dist=" + then.distance(player.getLocation()) + ")").getMessage(),
|
||||
player, CheckType.VELOCITY);
|
||||
VL_COUNT.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
VL_COUNT.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
|
||||
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;
|
||||
@@ -42,10 +42,10 @@ public class CommandHandler implements CommandExecutor {
|
||||
public CommandHandler() {
|
||||
commands.add(new CommandHelp());
|
||||
commands.add(new CommandCheck());
|
||||
commands.add(new CommandDeveloper());
|
||||
commands.add(new CommandLog());
|
||||
commands.add(new CommandReload());
|
||||
commands.add(new CommandReport());
|
||||
commands.add(new CommandMute());
|
||||
commands.add(new CommandReset());
|
||||
commands.add(new CommandVersion());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public class CommandCheck extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Check Management";
|
||||
private static final String NAME = "AntiCheatReloaded Check Management";
|
||||
private static final String COMMAND = "check";
|
||||
private static final String USAGE = "anticheat check [check] [on/off]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
||||
|
||||
-46
@@ -1,46 +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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandDeveloper extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Developer Mode";
|
||||
private static final String COMMAND = "developer";
|
||||
private static final String USAGE = "anticheat developer";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat developer" + GRAY + " to turn on developer mode",
|
||||
};
|
||||
|
||||
public CommandDeveloper() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
AntiCheatReloaded.setDeveloperMode(!AntiCheatReloaded.developerMode());
|
||||
cs.sendMessage(GREEN + "Developer mode " + (AntiCheatReloaded.developerMode() ? "ON" : "OFF"));
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class CommandHelp extends CommandBase {
|
||||
GOLD + "/acr " + GRAY + "help",
|
||||
GOLD + "/acr " + GRAY + "reload",
|
||||
GOLD + "/acr " + GRAY + "version",
|
||||
GOLD + "/acr " + GRAY + "mute",
|
||||
GOLD + "/acr " + GRAY + "check " + WHITE + "[check] [on/off]",
|
||||
GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
||||
GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandLog extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Logging";
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 reload";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandReload extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Reload";
|
||||
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;
|
||||
|
||||
+1
-15
@@ -36,7 +36,7 @@ import java.util.UUID;
|
||||
|
||||
public class CommandReport extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Reports";
|
||||
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;
|
||||
@@ -182,19 +182,5 @@ public class CommandReport extends CommandBase {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (AntiCheatReloaded.developerMode()) {
|
||||
int permission = 0;
|
||||
int check = 0;
|
||||
for (Permission perm : Permission.values()) {
|
||||
if (perm.get(user.getPlayer())) permission++;
|
||||
}
|
||||
CheckManager manager = AntiCheatReloaded.getManager().getCheckManager();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (manager.willCheck(user.getPlayer(), type)) check++;
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + "User has " + permission + "/" + Permission.values().length + " permissions");
|
||||
cs.sendMessage(ChatColor.GOLD + "User will be checked for " + check + "/" + CheckType.values().length + " checks");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class CommandReset extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Resetting";
|
||||
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;
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ 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_NOTICE;
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_VERSION;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
|
||||
|
||||
|
||||
@@ -70,9 +70,8 @@ public class EventListener implements Listener {
|
||||
|
||||
if (CONFIG.getConfig().debugMode.getValue()) {
|
||||
player.sendMessage(message);
|
||||
} else {
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
|
||||
@@ -177,7 +177,6 @@ public class CheckManager {
|
||||
&& !isExempt(player, type)
|
||||
&& !type.checkPermission(player)
|
||||
&& !isOpExempt(player);
|
||||
AntiCheatReloaded.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
||||
if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player))
|
||||
return false;
|
||||
return check;
|
||||
|
||||
@@ -30,7 +30,7 @@ system:
|
||||
event-chains: true
|
||||
# Should Enterprise options be enabled? Only set this to true if you're an advanced user.
|
||||
enterprise: false
|
||||
# Running AntiCheatReloaded in debug mode will send alerts to the cheating players
|
||||
# Running AntiCheatReloaded in debug mode will send alerts to the cheating players and enable debug logging
|
||||
# Do NOT enable this in a production environment!
|
||||
debug-mode: false
|
||||
# Use /AntiCheatReloaded check for a list of valid checks
|
||||
|
||||
@@ -18,6 +18,8 @@ permissions:
|
||||
description: See alerts when a player might be cheating
|
||||
anticheat.system.help:
|
||||
description: Access the help message
|
||||
anticheat.system.mute:
|
||||
description: Access the mute function
|
||||
anticheat.system.report:
|
||||
description: Access cheat reports
|
||||
anticheat.mod:
|
||||
@@ -27,6 +29,7 @@ permissions:
|
||||
anticheat.system.alert: true
|
||||
anticheat.system.help: true
|
||||
anticheat.system.report: true
|
||||
anticheat.system.mute: true
|
||||
anticheat.system.log:
|
||||
description: Access turning console logging on or off
|
||||
anticheat.system.reload:
|
||||
@@ -35,10 +38,6 @@ permissions:
|
||||
description: Access resetting a player's cheat level
|
||||
anticheat.system.version:
|
||||
description: Access information about whether the system is updated
|
||||
anticheat.system.calibrate:
|
||||
description: Access the calibration system
|
||||
anticheat.system.debug:
|
||||
description: Access debug reports
|
||||
anticheat.admin:
|
||||
description: Admin helper perm
|
||||
children:
|
||||
@@ -46,9 +45,7 @@ permissions:
|
||||
anticheat.system.log: true
|
||||
anticheat.system.reload: true
|
||||
anticheat.system.reset: true
|
||||
anticheat.system.update: true
|
||||
anticheat.system.calibrate: true
|
||||
anticheat.system.debug: true
|
||||
anticheat.system.mute: true
|
||||
anticheat.check.flight:
|
||||
description: Allow players to use fly cheats
|
||||
default: false
|
||||
|
||||
Reference in new issue
Block a user