Compare commits

...
11 Commits
86 changed files with 2758 additions and 3193 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
acr.rammelkast.com
+5 -5
View File
@@ -1,10 +1,10 @@
AntiCheatReloaded AntiCheatReloaded
============= =============
AntiCheatReloaded is a fork of the old 'AntiCheat' project. AntiCheatReloaded helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players. It is based on one of the oldest anti-cheats in the community, AntiCheat.
AntiCheat helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players.
### BTC donations: 1DwUKboRQKrgR9o1oZC4VutkCUwdZStHtk + BTC donations: bc1q5qgmzq9e63h7ptf3kneg78uf0mghtwsmvwxt8m
### LTC donations: LTXzGnVLXmiH5XJch1bKrcZtzQjaF9rd8V + LTC donations: LYZLe6AGRQZTey5UHe7CCF3e9HAyQooSmh
+ ETH donations: 0x2a2171fB3600fc67951734c2872E0Ad742741Cf2
Bug Reporting Bug Reporting
------------ ------------
@@ -30,7 +30,7 @@ Hacks blocked
* Jesus * Jesus
* Step * Step
* Criticals * Criticals
* KillAura * KillAura (not available on MC > 1.12.2
* Anti-Knockback * Anti-Knockback
* FastBow * FastBow
* FastDrop * FastDrop
+1
View File
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
+8 -15
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.6.3-ALPHA</version> <version>1.7.0-ALPHA</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://rammelkast.com</url> <url>https://rammelkast.com</url>
<properties> <properties>
@@ -13,7 +13,7 @@
<repositories> <repositories>
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url> <url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository> </repository>
</repositories> </repositories>
<build> <build>
@@ -80,21 +80,14 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-API</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.3.0</version> <version>4.5.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.spigotmc</groupId>
<artifactId>junit</artifactId> <artifactId>spigot</artifactId>
<version>4.11</version> <version>1.15.2-R0.1-SNAPSHOT</version>
<type>jar</type> <scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -70,17 +71,17 @@ public class AntiCheatReloaded extends JavaPlugin {
eventList.add(new InventoryListener()); eventList.add(new InventoryListener());
// Order is important in some cases, don't screw with these unless // Order is important in some cases, don't screw with these unless
// needed, especially config // needed, especially config
setupConfig(); this.setupConfig();
setupEvents(); this.setupEvents();
setupCommands(); this.setupCommands();
// Enterprise must come before levels // Enterprise must come before levels
setupEnterprise(); this.setupEnterprise();
restoreLevels(); this.restoreLevels();
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
setupProtocol(); this.setupProtocol();
} else { } else {
getLogger().severe("Shutting down, ProtocolLib not found!"); Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.RED + "Shutting down, ProtocolLib not found!");
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
return; return;
} }
@@ -105,6 +106,13 @@ public class AntiCheatReloaded extends JavaPlugin {
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning."); getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
getLogger().severe("*----------------------------------------------*"); getLogger().severe("*----------------------------------------------*");
} }
if (Bukkit.getPluginManager().getPlugin("Matrix") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running Matrix!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("AAC") != null) { if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
getLogger().severe("*----------------------------------------------*"); getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running AAC!"); getLogger().severe("You are also running AAC!");
@@ -322,4 +330,8 @@ public class AntiCheatReloaded extends JavaPlugin {
this.glideViolations++; this.glideViolations++;
} }
public static void sendToMainThread(Runnable runnable) {
Bukkit.getServer().getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
}
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -44,7 +45,7 @@ public class AntiCheatAPI {
* *
* @param type Check to start watching for * @param type Check to start watching for
*/ */
public static void activateCheck(CheckType type, Class caller) { public static void activateCheck(CheckType type, Class<?> caller) {
chk.activateCheck(type, caller.getName()); chk.activateCheck(type, caller.getName());
} }
@@ -53,7 +54,7 @@ public class AntiCheatAPI {
* *
* @param type Check to stop watching for * @param type Check to stop watching for
*/ */
public static void deactivateCheck(CheckType type, Class caller) { public static void deactivateCheck(CheckType type, Class<?> caller) {
chk.deactivateCheck(type, caller.getName()); chk.deactivateCheck(type, caller.getName());
} }
@@ -73,7 +74,7 @@ public class AntiCheatAPI {
* @param player Player to stop watching * @param player Player to stop watching
* @param type Check to stop watching for * @param type Check to stop watching for
*/ */
public static void exemptPlayer(Player player, CheckType type, Class caller) { public static void exemptPlayer(Player player, CheckType type, Class<?> caller) {
chk.exemptPlayer(player, type, caller.getName()); chk.exemptPlayer(player, type, caller.getName());
} }
@@ -83,7 +84,7 @@ public class AntiCheatAPI {
* @param player Player to start watching * @param player Player to start watching
* @param type Check to start watching for * @param type Check to start watching for
*/ */
public static void unexemptPlayer(Player player, CheckType type, Class caller) { public static void unexemptPlayer(Player player, CheckType type, Class<?> caller) {
chk.unexemptPlayer(player, type, caller.getName()); chk.unexemptPlayer(player, type, caller.getName());
} }
@@ -111,31 +112,6 @@ public class AntiCheatAPI {
// PlayerManager API // PlayerManager API
/**
* Get a player's integer hack level
*
* @param player Player to check
* @return player's hack level
* @deprecated see {@link #getGroup(org.bukkit.entity.Player)}
*/
@Deprecated
public static int getLevel(Player player) {
return umr.safeGetLevel(player.getUniqueId());
}
/**
* Set a player's hack level
*
* @param player Player to set
* @param level Group to set to
* @deprecated see {@link #resetPlayer(org.bukkit.entity.Player)}
*/
@Deprecated
public static void setLevel(Player player, int level) {
umr.safeSetLevel(player.getUniqueId(), level);
}
/** /**
* Reset a player's hack level to 0 * Reset a player's hack level to 0
* *
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -18,6 +19,7 @@
package com.rammelkast.anticheatreloaded.check; package com.rammelkast.anticheatreloaded.check;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -261,7 +263,7 @@ public class Backend {
} }
public CheckResult checkYSpeed(Player player, double y) { public CheckResult checkYSpeed(Player player, double y) {
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > (VersionUtil.isNewYSpeed() ? magic.Y_SPEED_MAX() + 0.05 : magic.Y_SPEED_MAX())) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) { if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX()) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")"); return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
} else { } else {
return PASS; return PASS;
@@ -431,7 +433,7 @@ public class Backend {
public CheckResult checkSwing(Player player, Block block) { public CheckResult checkSwing(Player player, Block block) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (!isInstantBreakExempt(player)) { if (!isInstantBreakExempt(player)) {
if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) { if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType().name().endsWith("LEAVES"))) {
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) { if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
int i = blockPunches.get(uuid); int i = blockPunches.get(uuid);
if (i < magic.BLOCK_PUNCH_MIN()) { if (i < magic.BLOCK_PUNCH_MIN()) {
@@ -447,7 +449,7 @@ public class Backend {
public CheckResult checkFastBreak(Player player, Block block) { public CheckResult checkFastBreak(Player player, Block block) {
int violations = magic.FASTBREAK_MAXVIOLATIONS(); int violations = magic.FASTBREAK_MAXVIOLATIONS();
long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(player.getInventory().getItemInHand(), block.getType()); long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType());
if (player.getGameMode() == GameMode.CREATIVE) { if (player.getGameMode() == GameMode.CREATIVE) {
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE(); violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE(); timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
@@ -583,7 +585,21 @@ public class Backend {
user.addMessage(msg); user.addMessage(msg);
return PASS; return PASS;
} }
public CheckResult checkChatUnicode(Player player, String msg) {
UUID uuid = player.getUniqueId();
User user = manager.getUserManager().getUser(uuid);
if (!isPureAscii(msg)) {
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
}
user.addMessage(msg);
return PASS;
}
private boolean isPureAscii(String v) {
return StandardCharsets.US_ASCII.newEncoder().canEncode(v.replaceAll("¡", "!").replaceAll("¿", "?"));
}
public CheckResult checkCommandSpam(Player player, String cmd) { public CheckResult checkCommandSpam(Player player, String cmd) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
User user = manager.getUserManager().getUser(uuid); User user = manager.getUserManager().getUser(uuid);
@@ -634,8 +650,8 @@ public class Backend {
} }
public CheckResult checkAutoTool(Player player) { public CheckResult checkAutoTool(Player player) {
if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != player.getItemInHand().getType()) { if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " switched tools too fast (had " + itemInHand.get(player.getName()) + ", has " + player.getItemInHand().getType() + ")"); return new CheckResult(CheckResult.Result.FAILED, player.getName() + " switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has " + VersionUtil.getItemInHand(player).getType() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -38,7 +39,8 @@ public enum CheckType {
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY), ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP), ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT), ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
FLY(Permission.CHECK_FLY), FLIGHT(Permission.CHECK_FLIGHT),
ELYTRA(Permission.CHECK_FLIGHT),
WATER_WALK(Permission.CHECK_WATERWALK), WATER_WALK(Permission.CHECK_WATERWALK),
NO_SWING(Permission.CHECK_NOSWING), NO_SWING(Permission.CHECK_NOSWING),
FAST_BREAK(Permission.CHECK_FASTBREAK), FAST_BREAK(Permission.CHECK_FASTBREAK),
@@ -62,8 +64,9 @@ public enum CheckType {
AUTOTOOL(Permission.CHECK_AUTOTOOL), AUTOTOOL(Permission.CHECK_AUTOTOOL),
KILLAURA(Permission.CHECK_KILLAURA), KILLAURA(Permission.CHECK_KILLAURA),
BLINK(Permission.CHECK_BLINK), BLINK(Permission.CHECK_BLINK),
VELOCITY(Permission.VELOCITY), VELOCITY(Permission.CHECK_VELOCITY),
CRITICALS(Permission.CRITICALS); CRITICALS(Permission.CHECK_CRITICALS),
CHAT_UNICODE(Permission.CHECK_UNICODE);
private final Permission permission; private final Permission permission;
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>(); private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
@@ -1,3 +1,21 @@
/*
* 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.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
import org.bukkit.Material; import org.bukkit.Material;
@@ -16,17 +34,24 @@ public class CriticalsCheck {
public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) { public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) {
if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK) if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK)
return; return;
Player p = (Player)e.getDamager(); Player p = (Player) e.getDamager();
if (isCritical(p)) { if (isCritical(p)) {
if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0) && p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) { if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0)
&& p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
e.setCancelled(true); e.setCancelled(true);
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Criticals, tried to do a critical without needed conditions").getMessage(), p, CheckType.CRITICALS); EventListener.log(new CheckResult(CheckResult.Result.FAILED,
p.getName() + " failed Criticals, tried to do a critical without needed conditions")
.getMessage(),
p, CheckType.CRITICALS);
} }
} }
} }
private static boolean isCritical(Player player) { 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; return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle()
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)
&& !Utilities.isHoveringOverWater(player.getLocation())
&& player.getEyeLocation().getBlock().getType() != Material.LADDER;
} }
} }
@@ -1,44 +1,50 @@
package com.rammelkast.anticheatreloaded.check.combat; /*
* 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/>.
*/
import java.util.HashMap; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
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.event.EventListener;
import com.rammelkast.anticheatreloaded.util.NPC_1_12;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast
*/ */
@Deprecated
public class KillAuraCheck { public class KillAuraCheck {
private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>(); //private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>();
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>(); //private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) { public static void cleanPlayer(Player p) {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { /*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return; return;
} }
NPC_LIST.remove(p.getUniqueId()); NPC_LIST.remove(p.getUniqueId());*/
} }
public static void listenPackets() { public static void listenPackets() {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { /*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return; return;
} }
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) { AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
ListenerPriority.NORMAL, new PacketType[] { PacketType.Play.Client.USE_ENTITY }) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@@ -53,20 +59,24 @@ public class KillAuraCheck {
if (!VL_COUNT.containsKey(p.getUniqueId())) { if (!VL_COUNT.containsKey(p.getUniqueId())) {
VL_COUNT.put(p.getUniqueId(), 1); VL_COUNT.put(p.getUniqueId(), 1);
NPC_LIST.get(p.getUniqueId()).damage(); NPC_LIST.get(p.getUniqueId()).damage();
}else { } else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1); VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) >= 5) { if (VL_COUNT.get(p.getUniqueId()) >= 5) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.KILLAURA); EventListener.log(
new CheckResult(CheckResult.Result.FAILED,
p.getName() + " failed KillAura (botcheck), hit the bot "
+ VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(),
p, CheckType.KILLAURA);
AntiCheatReloaded.getPlugin().onKillAuraViolation(); AntiCheatReloaded.getPlugin().onKillAuraViolation();
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
} }
} }
}); });*/
} }
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) { public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { /*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return; return;
} }
if (NPC_LIST.containsKey(p.getUniqueId())) if (NPC_LIST.containsKey(p.getUniqueId()))
@@ -75,16 +85,16 @@ public class KillAuraCheck {
NPC_1_12 npc = new NPC_1_12(p); NPC_1_12 npc = new NPC_1_12(p);
NPC_LIST.put(p.getUniqueId(), npc); NPC_LIST.put(p.getUniqueId(), npc);
npc.spawn(); npc.spawn();
} }*/
} }
public static void doMove(PlayerMoveEvent e) { public static void doMove(PlayerMoveEvent e) {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { /*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return; return;
} }
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) { if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) {
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e); NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
} }*/
} }
} }
@@ -1,3 +1,22 @@
/*
* 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.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap; import java.util.HashMap;
@@ -17,13 +36,14 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
public class VelocityCheck { public class VelocityCheck {
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>(); private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) { public static void cleanPlayer(Player p) {
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
public static void runCheck(EntityDamageByEntityEvent e, final Player p) { public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
if (AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p) || AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY)) if (AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
|| AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
return; return;
final Location then = p.getLocation(); final Location then = p.getLocation();
new BukkitRunnable() { new BukkitRunnable() {
@@ -36,16 +56,22 @@ public class VelocityCheck {
VL_COUNT.put(p.getUniqueId(), 1); VL_COUNT.put(p.getUniqueId(), 1);
else { else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1); VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_AMT()) { if (VL_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Velocity, had zero/low velocity " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_AMT() + ", dist=" + then.distance(p.getLocation()) + ")").getMessage(), p, CheckType.VELOCITY); .VELOCITY_AMT()) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED,
p.getName() + " failed Velocity, had zero/low velocity "
+ VL_COUNT.get(p.getUniqueId()) + " times (max="
+ AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_AMT()
+ ", dist=" + then.distance(p.getLocation()) + ")").getMessage(),
p, CheckType.VELOCITY);
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
} }
}else { } else {
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
} }
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4); }.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
} }
} }
@@ -1,9 +1,29 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@@ -16,6 +36,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast
@@ -23,37 +44,65 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
public class BlinkCheck { public class BlinkCheck {
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>(); public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
public static void startTimer() { public static void startTimer() {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
MOVE_COUNT.clear(); MOVE_COUNT.clear();
} }
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20); }.runTaskTimer(AntiCheatReloaded.getPlugin(), 100, 20);
} }
public static void listenPackets() { public static void listenPackets() {
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) { AntiCheatReloaded.getProtocolManager()
@Override .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.NORMAL,
public void onPacketReceiving(PacketEvent e) { new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
Player p = e.getPlayer(); @Override
Location cur = e.getPlayer().getLocation(); public void onPacketReceiving(PacketEvent e) {
if (!MOVE_COUNT.containsKey(p.getUniqueId())) { Player p = e.getPlayer();
MOVE_COUNT.put(p.getUniqueId(), 1); Location cur = e.getPlayer().getLocation();
} else { if (!MOVE_COUNT.containsKey(p.getUniqueId())) {
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1); MOVE_COUNT.put(p.getUniqueId(), 1);
if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p) && !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p) && !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) { } else {
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET()) { MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId()) + " packets in one second (max=" + AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.BLINK); if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p)
MOVE_COUNT.remove(p.getUniqueId()); && !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
e.setCancelled(true); && !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
e.getPlayer().teleport(cur); int ping = VersionUtil.getPlayerPing(p);
int blinkMagic = AntiCheatReloaded.getManager().getBackend()
.getMagic().BLINK_PACKET();
float pingLeniency = (float) ((ping / 120));
if (pingLeniency < 1) pingLeniency = 1;
if (pingLeniency > 3) pingLeniency = 3;
blinkMagic = Math.round(pingLeniency * blinkMagic);
final float finalPingLeniency = pingLeniency;
try {
if (MOVE_COUNT.get(p.getUniqueId()) > blinkMagic) {
final int packets = MOVE_COUNT.get(p.getUniqueId());
MOVE_COUNT.remove(p.getUniqueId());
AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override
public void run() {
EventListener.log(
new CheckResult(CheckResult.Result.FAILED, p.getName()
+ " failed Blink, sent " + packets
+ " packets in one second (max=" + AntiCheatReloaded.getManager()
.getBackend().getMagic().BLINK_PACKET()
+ ", leniency=" + finalPingLeniency + ", ping=" + ping + ")").getMessage(),
p, CheckType.BLINK);
e.setCancelled(true);
e.getPlayer().teleport(cur);
}
});
}
} catch (NullPointerException nullPointer) {
// TODO this is thrown sometimes, might have something to do with line 83
}
}
} }
} }
} });
}
});
} }
} }
@@ -0,0 +1,58 @@
/*
* 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.check.movement;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
/**
* TODO
*/
public class ElytraCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
// This was a teleport, so skip check.
return PASS;
}
/*if (!FlightCheck.isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
&& Utilities.cantStandAtExp(player.getLocation())
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
new Material[] { Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL,
Material.ACACIA_FENCE, Material.ACACIA_FENCE_GATE, Material.BIRCH_FENCE,
Material.BIRCH_FENCE_GATE, Material.DARK_OAK_FENCE, Material.DARK_OAK_FENCE_GATE,
Material.IRON_FENCE, Material.JUNGLE_FENCE, Material.JUNGLE_FENCE_GATE,
Material.fence, Material.SPRUCE_FENCE, Material.SPRUCE_FENCE_GATE, Material.IRON_BARS })) {
}*/
//TODO 1.15 update
return PASS;
}
}
@@ -1,19 +0,0 @@
package com.rammelkast.anticheatreloaded.check.movement;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
/**
* TODO
*/
public class ElytraFly {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, Distance distance) {
return PASS;
}
}
@@ -1,3 +1,22 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
@@ -15,8 +34,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast TODO rewrite this check
* TODO rewrite this check
*/ */
public class FlightCheck { public class FlightCheck {
@@ -38,7 +56,11 @@ public class FlightCheck {
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1) if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
&& Utilities.cantStandAtExp(player.getLocation()) && Utilities.cantStandAtExp(player.getLocation())
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), && Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
new Material[] { Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL })) { new Material[] { Material.IRON_BARS })
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), new String[] {
"FENCE",
"FENCE_GATE"
})) {
if (!blocksOverFlight.containsKey(uuid)) { if (!blocksOverFlight.containsKey(uuid)) {
blocksOverFlight.put(uuid, 0D); blocksOverFlight.put(uuid, 0D);
@@ -1,3 +1,22 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -5,31 +24,30 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class GlideCheck { public class GlideCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastDiff = new HashMap<UUID, Double>(); public static Map<UUID, Double> lastDiff = new HashMap<UUID, Double>();
public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>(); public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>();
public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>(); public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>();
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (VersionUtil.isFlying(player)) { if (VersionUtil.isFlying(player)) {
return PASS; return PASS;
} }
if (player.getLocation().getBlock().getType() == Material.LADDER || player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
return PASS;
}
if (!lastDiff.containsKey(player.getUniqueId())) { if (!lastDiff.containsKey(player.getUniqueId())) {
lastDiff.put(player.getUniqueId(), distance.getYDifference()); lastDiff.put(player.getUniqueId(), distance.getYDifference());
return PASS; return PASS;
@@ -44,7 +62,8 @@ public class GlideCheck {
if (!violations.containsKey(player.getUniqueId())) { if (!violations.containsKey(player.getUniqueId())) {
violations.put(player.getUniqueId(), 1); violations.put(player.getUniqueId(), 1);
} else { } else {
if (violations.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()) { if (violations.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic()
.GLIDE_LIMIT()) {
violations.remove(player.getUniqueId()); violations.remove(player.getUniqueId());
Location to = player.getLocation(); Location to = player.getLocation();
to.setY(to.getY() - distanceToFall(to)); to.setY(to.getY() - distanceToFall(to));
@@ -52,15 +71,18 @@ public class GlideCheck {
// Report glide violation to statistics, just for the lulz jk // Report glide violation to statistics, just for the lulz jk
AntiCheatReloaded.getPlugin().onGlideViolation(); AntiCheatReloaded.getPlugin().onGlideViolation();
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " was set back for gliding (yDiff=" + new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")"); player.getName() + " was set back for gliding (yDiff="
+ new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")");
} else { } else {
violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1); violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1);
} }
} }
} else {
// TODO more sophisticated check
} }
lastDiff.put(player.getUniqueId(), distance.getYDifference()); lastDiff.put(player.getUniqueId(), distance.getYDifference());
lastFallDistance.put(player.getUniqueId(), player.getFallDistance()); lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
return PASS; return PASS;
} }
private static double distanceToFall(Location location) { private static double distanceToFall(Location location) {
@@ -1,3 +1,21 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
@@ -1,3 +1,22 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.ArrayList; import java.util.ArrayList;
@@ -40,15 +59,17 @@ public class WaterWalkCheck {
boolean b; boolean b;
if (!Utilities.sprintFly(player)) { if (!Utilities.sprintFly(player)) {
b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER() b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER()
|| z > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER(); || z > AntiCheatReloaded.getManager().getBackend().getMagic()
.XZ_SPEED_MAX_WATER();
} else { } else {
b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT() b = x > AntiCheatReloaded.getManager().getBackend().getMagic()
.XZ_SPEED_MAX_WATER_SPRINT()
|| z > AntiCheatReloaded.getManager().getBackend().getMagic() || z > AntiCheatReloaded.getManager().getBackend().getMagic()
.XZ_SPEED_MAX_WATER_SPRINT(); .XZ_SPEED_MAX_WATER_SPRINT();
} }
if (!b && !Utilities.isFullyInWater(player.getLocation()) if (!b && !Utilities.isFullyInWater(player.getLocation())
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D && Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
&& !block.getType().equals(Material.WATER_LILY)) { && !block.getType().equals(Material.LILY_PAD)) {
b = true; b = true;
} }
if (b) { if (b) {
@@ -1,11 +1,28 @@
/*
* 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.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@@ -52,7 +69,8 @@ public class YAxisCheck {
lastYtime.put(uuid, System.currentTimeMillis()); lastYtime.put(uuid, System.currentTimeMillis());
} else { } else {
if (y1 > lastYcoord.get(uuid) if (y1 > lastYcoord.get(uuid)
&& yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() && yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
.Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheatReloaded.getManager() && (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) { .getBackend().getMagic().Y_MAXVIOTIME()) {
Location g = player.getLocation(); Location g = player.getLocation();
@@ -68,9 +86,10 @@ public class YAxisCheck {
player.getName() + " tried to fly on y-axis " + yAxisViolations.get(uuid) + " times (max =" player.getName() + " tried to fly on y-axis " + yAxisViolations.get(uuid) + " times (max ="
+ AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")"); + AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
} else { } else {
if (yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() if (yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheatReloaded.getManager() .Y_MAXVIOLATIONS()
.getBackend().getMagic().Y_MAXVIOTIME()) { && (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheatReloaded
.getManager().getBackend().getMagic().Y_MAXVIOTIME()) {
yAxisViolations.put(uuid, 0); yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L); yAxisLastViolation.put(uuid, 0L);
} }
@@ -78,7 +97,8 @@ public class YAxisCheck {
long i = System.currentTimeMillis() - lastYtime.get(uuid); long i = System.currentTimeMillis() - lastYtime.get(uuid);
double diff = AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF() double diff = AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
+ (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0); + (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
if ((y1 - lastYcoord.get(uuid)) > diff && i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) { if ((y1 - lastYcoord.get(uuid)) > diff
&& i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) {
Location g = player.getLocation(); Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1); yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis()); yAxisLastViolation.put(uuid, System.currentTimeMillis());
@@ -91,9 +111,10 @@ public class YAxisCheck {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in " return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in "
+ i + " ms (min =" + AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME() + ")"); + i + " ms (min =" + AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME() + ")");
} else { } else {
if ((y1 - lastYcoord.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF() + 1 if ((y1 - lastYcoord.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheatReloaded.getManager().getBackend() + 1
.getMagic().Y_TIME()) { || (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_TIME()) {
lastYtime.put(uuid, System.currentTimeMillis()); lastYtime.put(uuid, System.currentTimeMillis());
lastYcoord.put(uuid, y1); lastYcoord.put(uuid, y1);
} }
@@ -105,7 +126,8 @@ public class YAxisCheck {
} }
public static boolean isMoveUpBlock(Block block) { public static boolean isMoveUpBlock(Block block) {
return VersionUtil.getMoveUpBlocks().contains(block.getType()); Material type = block.getType();
return type.name().endsWith("STAIRS"); // TODO slabs/others?
} }
} }
@@ -1,3 +1,22 @@
/*
* 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.check.player; package com.rammelkast.anticheatreloaded.check.player;
import java.util.HashMap; import java.util.HashMap;
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -26,7 +27,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck; import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
import com.rammelkast.anticheatreloaded.command.executors.CommandDebug;
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper; import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp; import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
import com.rammelkast.anticheatreloaded.command.executors.CommandLog; import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
@@ -41,7 +41,6 @@ public class CommandHandler implements CommandExecutor {
public CommandHandler() { public CommandHandler() {
commands.add(new CommandHelp()); commands.add(new CommandHelp());
commands.add(new CommandCheck()); commands.add(new CommandCheck());
commands.add(new CommandDebug());
commands.add(new CommandDeveloper()); commands.add(new CommandDeveloper());
commands.add(new CommandLog()); commands.add(new CommandLog());
commands.add(new CommandReload()); commands.add(new CommandReload());
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,60 +0,0 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
*
* 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.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.PastebinReport;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandDebug extends CommandBase {
private static final String NAME = "AntiCheat Debug Reporting";
private static final String COMMAND = "debug";
private static final String USAGE = "anticheat debug <user>";
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
private static final String[] HELP = {
GRAY + "Use: " + AQUA + "/anticheat debug" + GRAY + " to create a debug report",
GRAY + "Use: " + AQUA + "/anticheat debug <user>" + GRAY + " to create a debug report for a user",
};
public CommandDebug() {
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
}
@Override
protected void execute(CommandSender cs, String[] args) {
Player player = null;
if (args.length == 1) {
player = Bukkit.getPlayer(args[0]);
} else {
if (cs instanceof Player) {
player = (Player) cs;
}
}
cs.sendMessage(GRAY + "Please wait while I collect some data...");
PastebinReport report = new PastebinReport(cs, player);
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
}
}
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -15,7 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.rammelkast.anticheatreloaded.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -30,14 +31,13 @@ public class CommandHelp extends CommandBase {
private static final String USAGE = "anticheat help"; private static final String USAGE = "anticheat help";
private static final Permission PERMISSION = Permission.SYSTEM_HELP; private static final Permission PERMISSION = Permission.SYSTEM_HELP;
private static final String[] HELP = { private static final String[] HELP = {
RED + "/anti " + GRAY + "help", RED + "/acr " + GRAY + "help",
RED + "/anti " + GRAY + "reload", RED + "/acr " + GRAY + "reload",
RED + "/anti " + GRAY + "update", RED + "/acr " + GRAY + "update",
RED + "/anti " + GRAY + "debug " + WHITE + "<user>", RED + "/acr " + GRAY + "check " + WHITE + "[check] [on/off]",
RED + "/anti " + GRAY + "check " + WHITE + "[check] [on/off]", RED + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
RED + "/anti " + GRAY + "log " + WHITE + "[file/console] [on/off]", RED + "/acr " + GRAY + "report " + WHITE + "[group/user]",
RED + "/anti " + GRAY + "report " + WHITE + "[group/user]", RED + "/acr " + GRAY + "reset " + WHITE + "[user]",
RED + "/anti " + GRAY + "reset " + WHITE + "[user]",
}; };
public CommandHelp() { public CommandHelp() {
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -29,7 +30,6 @@ public class Config extends ConfigurationFile {
public static final String FILENAME = "config.yml"; public static final String FILENAME = "config.yml";
public ConfigValue<Boolean> logToConsole; public ConfigValue<Boolean> logToConsole;
public ConfigValue<Boolean> autoUpdate;
public ConfigValue<Boolean> verboseStartup; public ConfigValue<Boolean> verboseStartup;
public ConfigValue<Boolean> silentMode; public ConfigValue<Boolean> silentMode;
public ConfigValue<Boolean> exemptOp; public ConfigValue<Boolean> exemptOp;
@@ -59,7 +59,6 @@ public class Config extends ConfigurationFile {
public void open() { public void open() {
logToConsole = new ConfigValue<Boolean>("system.log-to-console"); logToConsole = new ConfigValue<Boolean>("system.log-to-console");
autoUpdate = new ConfigValue<Boolean>("system.auto-update");
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup"); verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
silentMode = new ConfigValue<Boolean>("system.silent-mode"); silentMode = new ConfigValue<Boolean>("system.silent-mode");
exemptOp = new ConfigValue<Boolean>("system.exempt-op"); exemptOp = new ConfigValue<Boolean>("system.exempt-op");
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,3 +1,22 @@
/*
* 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.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List; import java.util.List;
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.rammelkast.anticheatreloaded.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List; import java.util.List;
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -54,8 +55,7 @@ import org.bukkit.inventory.PlayerInventory;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraFly;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck; import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
@@ -152,7 +152,7 @@ public class PlayerListener extends EventListener {
@EventHandler @EventHandler
public void onPlayerVelocity(PlayerVelocityEvent event) { public void onPlayerVelocity(PlayerVelocityEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (getCheckManager().willCheck(player, CheckType.FLY)) { if (getCheckManager().willCheck(player, CheckType.FLIGHT)) {
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) { if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
return; return;
@@ -175,7 +175,26 @@ public class PlayerListener extends EventListener {
player.sendMessage(ChatColor.RED + result.getMessage()); player.sendMessage(ChatColor.RED + result.getMessage());
} }
getBackend().processChatSpammer(player); getBackend().processChatSpammer(player);
log(null, player, CheckType.CHAT_SPAM); AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override
public void run() {
log(null, player, CheckType.CHAT_SPAM);
}
});
}
}
if (getCheckManager().willCheck(player, CheckType.CHAT_UNICODE)) {
CheckResult result = getBackend().checkChatUnicode(player, event.getMessage());
if (result.failed()) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + result.getMessage());
AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override
public void run() {
log(null, player, CheckType.CHAT_UNICODE);
}
});
} }
} }
@@ -224,10 +243,9 @@ public class PlayerListener extends EventListener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Material m = inv.getItemInHand().getType(); if (inv.getItemInMainHand().getType() == Material.BOW) {
if (m == Material.BOW) {
getBackend().logBowWindUp(player); getBackend().logBowWindUp(player);
} else if (Utilities.isFood(m)) { } else if (Utilities.isFood(inv.getItemInMainHand().getType()) || Utilities.isFood(inv.getItemInOffHand().getType())) {
getBackend().logEatingStart(player); getBackend().logEatingStart(player);
} }
} }
@@ -257,7 +275,7 @@ public class PlayerListener extends EventListener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerEnterBed(PlayerBedEnterEvent event) { public void onPlayerEnterBed(PlayerBedEnterEvent event) {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType().name().endsWith("BED")) return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
@@ -265,7 +283,7 @@ public class PlayerListener extends EventListener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerExitBed(PlayerBedLeaveEvent event) { public void onPlayerExitBed(PlayerBedLeaveEvent event) {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType().name().endsWith("BED")) return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
@@ -300,7 +318,7 @@ public class PlayerListener extends EventListener {
if (player.hasMetadata(Utilities.SPY_METADATA)) { if (player.hasMetadata(Utilities.SPY_METADATA)) {
for (Player p : player.getServer().getOnlinePlayers()) { for (Player p : player.getServer().getOnlinePlayers()) {
if (!Permission.SYSTEM_SPY.get(p)) { if (!Permission.SYSTEM_SPY.get(p)) {
p.hidePlayer(player); p.hidePlayer(AntiCheatReloaded.getPlugin(), player);
} }
} }
} }
@@ -322,7 +340,8 @@ public class PlayerListener extends EventListener {
final User user = getUserManager().getUser(player.getUniqueId()); final User user = getUserManager().getUser(player.getUniqueId());
user.setTo(to.getX(), to.getY(), to.getZ()); user.setTo(to.getX(), to.getY(), to.getZ());
KillAuraCheck.doMove(event); //KillAuraCheck.doMove(event);
//TODO
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) { if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
CheckResult result = getBackend().checkSprintStill(player, from, to); CheckResult result = getBackend().checkSprintStill(player, from, to);
@@ -331,26 +350,26 @@ public class PlayerListener extends EventListener {
log(result.getMessage(), player, CheckType.SPRINT); log(result.getMessage(), player, CheckType.SPRINT);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) { if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
CheckResult result = FlightCheck.runCheck(player, distance); CheckResult result = FlightCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.FLY); log(result.getMessage(), player, CheckType.FLIGHT);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) { if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
CheckResult result = GlideCheck.runCheck(player, distance); CheckResult result = GlideCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF // NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
log(result.getMessage(), player, CheckType.FLY); log(result.getMessage(), player, CheckType.FLIGHT);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY)) { if (getCheckManager().willCheckQuick(player, CheckType.ELYTRA)) {
CheckResult result = ElytraFly.runCheck(player, distance); CheckResult result = ElytraCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.FLY); log(result.getMessage(), player, CheckType.ELYTRA);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) { if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
@@ -369,7 +388,7 @@ public class PlayerListener extends EventListener {
log(result.getMessage(), player, CheckType.VCLIP); log(result.getMessage(), player, CheckType.VCLIP);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) { 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); CheckResult result = getBackend().checkNoFall(player, y);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
@@ -384,7 +403,7 @@ public class PlayerListener extends EventListener {
if (event.getTo() != event.getFrom()) { if (event.getTo() != event.getFrom()) {
double x = distance.getXDifference(); double x = distance.getXDifference();
double z = distance.getZDifference(); double z = distance.getZDifference();
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) { if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLIGHT)) {
if (event.getFrom().getY() < event.getTo().getY()) { if (event.getFrom().getY() < event.getTo().getY()) {
CheckResult result = getBackend().checkYSpeed(player, y); CheckResult result = getBackend().checkYSpeed(player, y);
if (result.failed()) { if (result.failed()) {
@@ -445,7 +464,8 @@ public class PlayerListener extends EventListener {
@EventHandler(priority=EventPriority.HIGHEST) @EventHandler(priority=EventPriority.HIGHEST)
public void onDeath(PlayerDeathEvent e) { public void onDeath(PlayerDeathEvent e) {
KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag //KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag
//TODO
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -461,7 +481,7 @@ public class PlayerListener extends EventListener {
return; return;
} }
if (getCheckManager().willCheck(player, CheckType.FLY) && !player.isFlying()) { if (getCheckManager().willCheck(player, CheckType.FLIGHT) && !player.isFlying()) {
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to)); CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY()); CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : ""; String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
@@ -469,7 +489,7 @@ public class PlayerListener extends EventListener {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(log, player, CheckType.FLY); log(log, player, CheckType.FLIGHT);
} }
} }
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -18,6 +19,7 @@
package com.rammelkast.anticheatreloaded.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
@@ -49,9 +51,19 @@ public class VehicleListener extends EventListener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onVehicleDestroy(VehicleDestroyEvent event) { public void onVehicleDestroy(VehicleDestroyEvent event) {
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) { // TODO fix deprecations
getBackend().logEnterExit((Player) event.getVehicle().getPassenger()); //if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
} // getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
//}
// TODO this should work, untested though.
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()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -24,6 +25,7 @@ import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -176,8 +178,7 @@ public class CheckManager {
&& !type.checkPermission(player) && !type.checkPermission(player)
&& !isOpExempt(player); && !isOpExempt(player);
AntiCheatReloaded.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName()); AntiCheatReloaded.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
// TODO temp fix if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player))
if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying())
return false; return false;
return check; return check;
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -43,7 +44,7 @@ public class LoggingManager {
private final Configuration config; private final Configuration config;
public LoggingManager(AntiCheatReloaded plugin, Logger logger, Configuration config) { public LoggingManager(AntiCheatReloaded plugin, Logger logger, Configuration config) {
this.fileLogger = Logger.getLogger("net.gravitydevelopment.anticheat.AntiCheat"); this.fileLogger = Logger.getLogger("com.rammelkast.anticheatreloaded.AntiCheatReloaded");
this.config = config; this.config = config;
try { try {
File file = new File(plugin.getDataFolder(), "log"); File file = new File(plugin.getDataFolder(), "log");
@@ -1,37 +0,0 @@
package com.rammelkast.anticheatreloaded.manage;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.*;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class PacketManager {
private ProtocolManager protocolManager;
private AntiCheatReloaded plugin;
private AntiCheatManager manager;
public PacketManager(ProtocolManager protocolManager, AntiCheatReloaded plugin, AntiCheatManager manager) {
this.protocolManager = protocolManager;
this.plugin = plugin;
this.manager = manager;
addListeners();
}
private void addListeners() {
// Arm Animation
protocolManager.addPacketListener(new PacketAdapter(plugin,
ConnectionSide.CLIENT_SIDE,
ListenerPriority.NORMAL,
Packets.Client.ARM_ANIMATION) {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.getPacketID() == Packets.Client.ARM_ANIMATION) {
PacketContainer packet = event.getPacket();
//System.out.println("Arm animation from "+packet.getIntegers().read(0));
}
}
});
}
}
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
File diff suppressed because it is too large. Load diff
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -21,205 +22,65 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Material; import org.bukkit.Material;
public enum BlockHardness { public enum BlockHardness {
STONE(1.50D), STONE(1.50D), GRASS(0.60D), DIRT(0.50D), COBBLESTONE(2.00D), WOOD(2.00D), SAPLING(0.00D), WATER(100.00D),
GRASS(0.60D), STATIONARY_WATER(100.00D), LAVA(0.00D), STATIONARY_LAVA(100.00D), SAND(0.50D), GRAVEL(0.60D), GOLD_ORE(3.00D),
DIRT(0.50D), IRON_ORE(3.00D), COAL_ORE(3.00D), LOG(2.00D), LOG_2(2.00D), LEAVES(0.20D), LEAVES_2(0.20D), SPONGE(0.60D),
COBBLESTONE(2.00D), GLASS(0.30D), LAPIS_ORE(3.00D), LAPIS_BLOCK(3.00D), DISPENSER(3.50D), DROPPER(3.50D), SANDSTONE(0.80D),
WOOD(2.00D), NOTE_BLOCK(0.80D), BED(0.20D), RAILS(0.70D), DETECTOR_RAIL(0.70D), POWERED_RAIL(0.70D), ACTIVATOR_RAIL(0.70D),
SAPLING(0.00D), WEB(4.00D), LONG_GRASS(0.00D), DOUBLE_PLANT(0.00D), DEAD_BUSH(0.00D), WOOL(0.80D), YELLOW_FLOWER(0.00D),
WATER(100.00D), RED_ROSE(0.00D), BROWN_MUSHROOM(0.00D), RED_MUSHROOM(0.00D), GOLD_BLOCK(3.00D), IRON_BLOCK(5.00D),
STATIONARY_WATER(100.00D), DOUBLE_STEP(2.00D), STEP(2.00D), BRICK(2.00D), TNT(0.00D), BOOKSHELF(1.50D), MOSSY_COBBLESTONE(2.00D),
LAVA(0.00D), OBSIDIAN(50.00D), TORCH(0.00D), FIRE(0.00D), MOB_SPAWNER(5.00D), CHEST(2.50D), TRAPPED_CHEST(2.50D),
STATIONARY_LAVA(100.00D), REDSTONE_WIRE(0.00D), DIAMOND_ORE(3.00D), DIAMOND_BLOCK(5.00D), WORKBENCH(2.50D), SOIL(0.60D), FURNACE(3.50D),
SAND(0.50D), BURNING_FURNACE(3.50D), WOODEN_DOOR(3.00D), LADDER(0.40D), LEVER(0.50D), IRON_DOOR_BLOCK(5.00D), HOPPER(2.00D),
GRAVEL(0.60D), STONE_PLATE(0.50D), WOOD_PLATE(0.50D), GOLD_PLATE(0.50D), IRON_PLATE(0.50D), QUARTZ_BLOCK(0.80D), QUARTZ_ORE(3.00D),
GOLD_ORE(3.00D), REDSTONE_BLOCK(5.00D), REDSTONE_ORE(3.00D), GLOWING_REDSTONE_ORE(3.00D), REDSTONE_TORCH_OFF(0.00D),
IRON_ORE(3.00D), REDSTONE_TORCH_ON(0.00D), REDSTONE_COMPARATOR_OFF(0.00D), REDSTONE_COMPARATOR_ON(0.00D), DAYLIGHT_DETECTOR(0.20D),
COAL_ORE(3.00D), STONE_BUTTON(0.50D), SNOW(0.10D), ICE(0.50D), PACKED_ICE(0.50D), SNOW_BLOCK(0.20D), CACTUS(0.40D), CLAY(0.60D),
LOG(2.00D), HARD_CLAY(1.25D), STAINED_CLAY(1.25D), SUGAR_CANE_BLOCK(0.00D), JUKEBOX(2.00D), FENCE(2.00D), NETHERRACK(0.40D),
LOG_2(2.00D), SOUL_SAND(0.50D), GLOWSTONE(0.30D), PORTAL(-1.00D), CAKE_BLOCK(0.50D), LOCKED_CHEST(0.00D), TRAP_DOOR(3.00D),
LEAVES(0.20D), MONSTER_EGGS(0.750D), SMOOTH_BRICK(1.50D), IRON_FENCE(5.00D), THIN_GLASS(0.30D), STAINED_GLASS(0.30D),
LEAVES_2(0.20D), STAINED_GLASS_PANE(0.30D), PUMPKIN_STEM(0.00D), MELON_STEM(0.00D), VINE(0.20D), FENCE_GATE(2.00D), MYCEL(0.60D),
SPONGE(0.60D), WATER_LILY(0.00D), NETHER_BRICK(2.00D), NETHER_FENCE(2.00D), ENCHANTMENT_TABLE(5.00D), BREWING_STAND(0.50D),
GLASS(0.30D), CAULDRON(2.00D), ENDER_PORTAL(-1.00D), ENDER_PORTAL_FRAME(-1.00D), DRAGON_EGG(3.00D), REDSTONE_LAMP_OFF(0.30D),
LAPIS_ORE(3.00D), REDSTONE_LAMP_ON(0.30D), WOOD_DOUBLE_STEP(2.00D), WOOD_STEP(2.00D), COCOA(0.20D), EMERALD_ORE(3.00D),
LAPIS_BLOCK(3.00D), ENDER_CHEST(22.50D), EMERALD_BLOCK(5.00D), FLOWER_POT(0.00D), WOOD_BUTTON(0.50D), ANVIL(5.00D),
DISPENSER(3.50D), HUGE_MUSHROOM_1(0.20D), HUGE_MUSHROOM_2(0.20D), BED_BLOCK(0.20D), WOOD_STAIRS(2.00D), COBBLESTONE_STAIRS(2.00D),
DROPPER(3.50D), BRICK_STAIRS(2.00D), SMOOTH_STAIRS(1.50D), NETHER_BRICK_STAIRS(2.00D), SPRUCE_WOOD_STAIRS(2.00D),
SANDSTONE(0.80D), BIRCH_WOOD_STAIRS(2.00D), JUNGLE_WOOD_STAIRS(2.00D), DARK_OAK_STAIRS(2.00D), ACACIA_STAIRS(2.00D),
NOTE_BLOCK(0.80D), QUARTZ_STAIRS(0.80D), SANDSTONE_STAIRS(0.80D), COMMAND(0.00D), BEACON(3.00D), COBBLE_WALL(2.00D), CROPS(0.00D),
BED(0.20D), CARROT(0.00D), POTATO(0.00D), SKULL(1.00D), NETHER_WARTS(0.00D), SIGN_POST(1.00D), WALL_SIGN(1.00D), PUMPKIN(1.00D),
RAILS(0.70D), JACK_O_LANTERN(1.00D), DIODE_BLOCK_ON(0.00D), DIODE_BLOCK_OFF(0.00D), MELON_BLOCK(1.00D), ENDER_STONE(3.00D),
DETECTOR_RAIL(0.70D), TRIPWIRE(0.00D), TRIPWIRE_HOOK(0.00D), HAY_BLOCK(0.50D), CARPET(0.10D), COAL_BLOCK(5.00D), PISTON_BASE(0.70D),
POWERED_RAIL(0.70D), PISTON_EXTENSION(0.70D), PISTON_MOVING_PIECE(0.70D), PISTON_STICKY_BASE(0.70D);
ACTIVATOR_RAIL(0.70D),
WEB(4.00D),
LONG_GRASS(0.00D),
DOUBLE_PLANT(0.00D),
DEAD_BUSH(0.00D),
WOOL(0.80D),
YELLOW_FLOWER(0.00D),
RED_ROSE(0.00D),
BROWN_MUSHROOM(0.00D),
RED_MUSHROOM(0.00D),
GOLD_BLOCK(3.00D),
IRON_BLOCK(5.00D),
DOUBLE_STEP(2.00D),
STEP(2.00D),
BRICK(2.00D),
TNT(0.00D),
BOOKSHELF(1.50D),
MOSSY_COBBLESTONE(2.00D),
OBSIDIAN(50.00D),
TORCH(0.00D),
FIRE(0.00D),
MOB_SPAWNER(5.00D),
CHEST(2.50D),
TRAPPED_CHEST(2.50D),
REDSTONE_WIRE(0.00D),
DIAMOND_ORE(3.00D),
DIAMOND_BLOCK(5.00D),
WORKBENCH(2.50D),
SOIL(0.60D),
FURNACE(3.50D),
BURNING_FURNACE(3.50D),
WOODEN_DOOR(3.00D),
LADDER(0.40D),
LEVER(0.50D),
IRON_DOOR_BLOCK(5.00D),
HOPPER(2.00D),
STONE_PLATE(0.50D),
WOOD_PLATE(0.50D),
GOLD_PLATE(0.50D),
IRON_PLATE(0.50D),
QUARTZ_BLOCK(0.80D),
QUARTZ_ORE(3.00D),
REDSTONE_BLOCK(5.00D),
REDSTONE_ORE(3.00D),
GLOWING_REDSTONE_ORE(3.00D),
REDSTONE_TORCH_OFF(0.00D),
REDSTONE_TORCH_ON(0.00D),
REDSTONE_COMPARATOR_OFF(0.00D),
REDSTONE_COMPARATOR_ON(0.00D),
DAYLIGHT_DETECTOR(0.20D),
STONE_BUTTON(0.50D),
SNOW(0.10D),
ICE(0.50D),
PACKED_ICE(0.50D),
SNOW_BLOCK(0.20D),
CACTUS(0.40D),
CLAY(0.60D),
HARD_CLAY(1.25D),
STAINED_CLAY(1.25D),
SUGAR_CANE_BLOCK(0.00D),
JUKEBOX(2.00D),
FENCE(2.00D),
NETHERRACK(0.40D),
SOUL_SAND(0.50D),
GLOWSTONE(0.30D),
PORTAL(-1.00D),
CAKE_BLOCK(0.50D),
LOCKED_CHEST(0.00D),
TRAP_DOOR(3.00D),
MONSTER_EGGS(0.750D),
SMOOTH_BRICK(1.50D),
IRON_FENCE(5.00D),
THIN_GLASS(0.30D),
STAINED_GLASS(0.30D),
STAINED_GLASS_PANE(0.30D),
PUMPKIN_STEM(0.00D),
MELON_STEM(0.00D),
VINE(0.20D),
FENCE_GATE(2.00D),
MYCEL(0.60D),
WATER_LILY(0.00D),
NETHER_BRICK(2.00D),
NETHER_FENCE(2.00D),
ENCHANTMENT_TABLE(5.00D),
BREWING_STAND(0.50D),
CAULDRON(2.00D),
ENDER_PORTAL(-1.00D),
ENDER_PORTAL_FRAME(-1.00D),
DRAGON_EGG(3.00D),
REDSTONE_LAMP_OFF(0.30D),
REDSTONE_LAMP_ON(0.30D),
WOOD_DOUBLE_STEP(2.00D),
WOOD_STEP(2.00D),
COCOA(0.20D),
EMERALD_ORE(3.00D),
ENDER_CHEST(22.50D),
EMERALD_BLOCK(5.00D),
FLOWER_POT(0.00D),
WOOD_BUTTON(0.50D),
ANVIL(5.00D),
HUGE_MUSHROOM_1(0.20D),
HUGE_MUSHROOM_2(0.20D),
BED_BLOCK(0.20D),
WOOD_STAIRS(2.00D),
COBBLESTONE_STAIRS(2.00D),
BRICK_STAIRS(2.00D),
SMOOTH_STAIRS(1.50D),
NETHER_BRICK_STAIRS(2.00D),
SPRUCE_WOOD_STAIRS(2.00D),
BIRCH_WOOD_STAIRS(2.00D),
JUNGLE_WOOD_STAIRS(2.00D),
DARK_OAK_STAIRS(2.00D),
ACACIA_STAIRS(2.00D),
QUARTZ_STAIRS(0.80D),
SANDSTONE_STAIRS(0.80D),
COMMAND(0.00D),
BEACON(3.00D),
COBBLE_WALL(2.00D),
CROPS(0.00D),
CARROT(0.00D),
POTATO(0.00D),
SKULL(1.00D),
NETHER_WARTS(0.00D),
SIGN_POST(1.00D),
WALL_SIGN(1.00D),
PUMPKIN(1.00D),
JACK_O_LANTERN(1.00D),
DIODE_BLOCK_ON(0.00D),
DIODE_BLOCK_OFF(0.00D),
MELON_BLOCK(1.00D),
ENDER_STONE(3.00D),
TRIPWIRE(0.00D),
TRIPWIRE_HOOK(0.00D),
HAY_BLOCK(0.50D),
CARPET(0.10D),
COAL_BLOCK(5.00D),
PISTON_BASE(0.70D),
PISTON_EXTENSION(0.70D),
PISTON_MOVING_PIECE(0.70D),
PISTON_STICKY_BASE(0.70D);
Material mat; Material mat;
double hardness; double hardness;
BlockHardness(double hard) { BlockHardness(double hard) {
mat = Material.getMaterial(name()); mat = Material.getMaterial(name());
hardness = hard; hardness = hard;
} }
public static double getBlockHardness(Material m) { public static double getBlockHardness(Material m) {
try { try {
BlockHardness h = getHardness(m); BlockHardness h = getHardness(m);
return h == null ? 0D : h.hardness; return h == null ? 0D : h.hardness;
}catch(Exception e) { } catch (Exception e) {
return 0D; return 0D;
} }
} }
public static boolean hasBlockHardness(Material m) { public static boolean hasBlockHardness(Material m) {
return getHardness(m) != null; return getHardness(m) != null;
} }
public static BlockHardness getHardness(Material m) { public static BlockHardness getHardness(Material m) {
for (BlockHardness e : BlockHardness.values()) { for (BlockHardness e : BlockHardness.values()) {
if (e.mat.equals(m)) { if (e.mat.equals(m)) {
return e; return e;
} }
} }
return null; return null;
} }
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -21,39 +22,39 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Location; import org.bukkit.Location;
public class Distance { public class Distance {
private final double l1Y; private final double l1Y;
private final double l2Y; private final double l2Y;
private final double XDiff; private final double XDiff;
private final double YDiff; private final double YDiff;
private final double ZDiff; private final double ZDiff;
public Distance(Location from, Location to) { public Distance(Location from, Location to) {
l1Y = to.getY(); l1Y = to.getY();
l2Y = from.getY(); l2Y = from.getY();
XDiff = Math.abs(to.getX() - from.getX()); XDiff = Math.abs(to.getX() - from.getX());
ZDiff = Math.abs(to.getZ() - from.getZ()); ZDiff = Math.abs(to.getZ() - from.getZ());
YDiff = Math.abs(l1Y - l2Y); YDiff = Math.abs(l1Y - l2Y);
} }
public double fromY() { public double fromY() {
return l2Y; return l2Y;
} }
public double toY() { public double toY() {
return l1Y; return l1Y;
} }
public double getXDifference() { public double getXDifference() {
return XDiff; return XDiff;
} }
public double getZDifference() { public double getZDifference() {
return ZDiff; return ZDiff;
} }
public double getYDifference() { public double getYDifference() {
return YDiff; return YDiff;
} }
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -25,12 +26,14 @@ import java.util.logging.Formatter;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
public class FileFormatter extends Formatter { public class FileFormatter extends Formatter {
private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss"); private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss");
private static final String LINE_SEP = System.getProperty("line.separator"); private static final String LINE_SEP = System.getProperty("line.separator");
@Override @Override
public String format(LogRecord record) { public String format(LogRecord record) {
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP); StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|')
return output.toString(); .append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage())
} .append(' ').append(LINE_SEP);
return output.toString();
}
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -28,62 +29,67 @@ import java.util.List;
public class Group { public class Group {
private String name; private String name;
private int level; private int level;
private ChatColor color = ChatColor.RED; private ChatColor color = ChatColor.RED;
private List<String> actions = new ArrayList<String>(); private List<String> actions = new ArrayList<String>();
public Group(String name, int level, String color, List<String> actions) { public Group(String name, int level, String color, List<String> actions) {
this.name = name; this.name = name;
this.level = level; this.level = level;
this.actions = actions; this.actions = actions;
ChatColor c = ChatColor.valueOf(color); ChatColor c = ChatColor.valueOf(color);
if (c == null) { if (c == null) {
AntiCheatReloaded.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid."); AntiCheatReloaded.getPlugin().getLogger()
AntiCheatReloaded.getPlugin().getLogger().warning("This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors"); .warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
} else { AntiCheatReloaded.getPlugin().getLogger().warning(
this.color = c; "This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
} } else {
} this.color = c;
public String getName() { }
return name; }
}
public int getLevel() { public String getName() {
return level; return name;
} }
public ChatColor getColor() { public int getLevel() {
return color; return level;
} }
public List<String> getActions() { public ChatColor getColor() {
return actions; return color;
} }
public static Group load(String string) { public List<String> getActions() {
try { return actions;
if (string.split(" : ").length == 4) { }
String name = string.split(" : ")[0];
int level = Integer.parseInt(string.split(" : ")[1]);
String color = string.split(" : ")[2];
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
return new Group(name, level, color, actions);
} else {
throw new Exception();
}
} catch (Exception ex) {
AntiCheatReloaded.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheatReloaded.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
return null;
}
}
@Override public static Group load(String string) {
public String toString() { try {
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions); if (string.split(" : ").length == 4) {
} String name = string.split(" : ")[0];
int level = Integer.parseInt(string.split(" : ")[1]);
String color = string.split(" : ")[2];
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
return new Group(name, level, color, actions);
} else {
throw new Exception();
}
} catch (Exception ex) {
AntiCheatReloaded.getPlugin().getLogger()
.warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheatReloaded.getPlugin().getLogger().warning(
"The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
return null;
}
}
@Override
public String toString() {
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions);
}
} }
@@ -1,21 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.EnumSet;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.potion.PotionEffectType;
public class NMS_1_9_PLUS {
static final EnumSet<Material> MOVE_UP_BLOCKS_1_9 = EnumSet.of(Material.ACACIA_STAIRS,
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS,
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS,
Material.RED_SANDSTONE_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS,
Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS, Material.PURPUR_STAIRS);
static final PotionEffectType LEVITATION = PotionEffectType.LEVITATION;
static final Enchantment FROST_WALKER = Enchantment.FROST_WALKER;
}
@@ -1,204 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumItemSlot;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_12_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_12_R1.PlayerConnection;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_12_R1.World;
import net.minecraft.server.v1_12_R1.WorldServer;
public class NPC_1_12 {
private final UUID owner;
private final String name;
private UUID uuid;
private EntityPlayer npc;
private int entityId;
private Location location;
public int getID() {
return this.entityId;
}
public NPC_1_12(Player owner) {
this.owner = owner.getUniqueId();
this.name = NameGenerator.generateName();
Location eyelocation = owner.getEyeLocation();
Vector vec = owner.getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
}
public void spawn() {
final MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
final WorldServer nmsWorld = ((CraftWorld) this.getOwner().getWorld()).getHandle();
this.uuid = UUID.randomUUID();
(this.npc = new EntityPlayer(nmsServer, nmsWorld, new GameProfile(this.uuid, this.name),
new PlayerInteractManager((World) nmsWorld))).setLocation(this.location.getX(), this.location.getY(),
this.location.getZ(), 0.0f, 0.0f);
this.npc.collides = false;
this.npc.setInvisible(true);
this.npc.setEquipment(EnumItemSlot.CHEST, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_CHESTPLATE)) : CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_CHESTPLATE)));
this.npc.setEquipment(EnumItemSlot.FEET, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_BOOTS)) : CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_BOOTS)));
this.entityId = this.npc.getId();
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
new EntityPlayer[] { this.npc }));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn((EntityHuman) this.npc));
}
public boolean up = true;
public void move(PlayerMoveEvent e) {
if (e.getTo().getPitch() <= -32.5) {
if (e.getTo().getPitch() <= -82.5) {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY() - 8.25);
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
if (new Random().nextInt(50) == 25 && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
}
}else {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY());
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
}
} else if (e.getTo().getPitch() >= 22) {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY() - 0.4);
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
} else {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-1.95 * vec.getX());
if (up)
vec.setY(vec.getY() + 0.5);
else
vec.setY(vec.getY() - 0.25);
if (new Random().nextInt(10) == 5)
up = !up;
vec.setZ(-1.95 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection
.sendPacket(new PacketPlayOutEntityTeleport(npc));
if (new Random().nextInt(1000) == 500 && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6);
}
}
}
public Player getOwner() {
return Bukkit.getPlayer(owner);
}
public void damage(EntityDamageByEntityEvent e, Player p) {
if (p != getOwner() || this.npc == null) {
return;
}
if (new Random().nextBoolean() && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(7));
}
}
public void damage() {
if (this.npc == null || this.getOwner() == null) {
return;
}
if (new Random().nextBoolean() && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(8));
}
}
}
@@ -1,3 +1,22 @@
/*
* 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.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays; import java.util.Arrays;
@@ -6,32 +25,12 @@ import java.util.Random;
public class NameGenerator { public class NameGenerator {
private static final List<String> BEGIN = Arrays.asList(new String[]{ private static final List<String> BEGIN = Arrays.asList(new String[] { "Pixel", "Pro", "NoHax", "Just", "That",
"Pixel", "New", "Ultra", "Killer", "Swift", "Anarchy", "Yolo", "Rammel" });
"Pro",
"NoHax", private static final List<String> END = Arrays.asList(new String[] { "Gamer", "PvP", "JustYolo", "Gaming",
"Just", "Minecraft", "Games", "Bawz", "Tech", "Noob", "Extra", "kast", "" + new Random().nextInt(100) });
"That",
"New",
"Ultra",
"Killer",
"Swift",
"Yolo",
"Rammel"
});
private static final List<String> END = Arrays.asList(new String[]{
"Gamer",
"PvP",
"JustYolo",
"Gaming",
"Minecraft",
"Games",
"Bawz",
"kast",
"" + new Random().nextInt(100)
});
public static String generateName() { public static String generateName() {
Random r = new Random(); Random r = new Random();
String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1)); String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1));
@@ -41,5 +40,5 @@ public class NameGenerator {
else else
return begin + end; return begin + end;
} }
} }
@@ -1,37 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Random;
public class NameUtil {
private static String[] firstParts = new String[] {
"Gamer",
"Pixel",
"Derp",
"Random",
"That",
"NoHaxJust",
"Derp",
"Fun",
"Luigi"
};
private static String[] secondParts = new String[] {
"01",
"Boy",
"Guy",
"Mario",
"Plain",
"Simple",
"NotHacking",
"Random",
"11",
"06"
};
private static Random theRandom = new Random();
public static String getRandomName() {
return firstParts[theRandom.nextInt(firstParts.length - 1)] + secondParts[theRandom.nextInt(secondParts.length - 1)];
}
}
@@ -1,228 +0,0 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
*
* 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.util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class PastebinReport {
private static final String DATE = new SimpleDateFormat("yyyy-MM-dd kk:mm Z").format(new Date());
private static final String API_KEY = "d5ac92da966edb97a97860e6a052784f";
private StringBuilder report = new StringBuilder();
private String url = "";
public PastebinReport(CommandSender cs) {
Player player = null;
if (cs instanceof Player) {
player = (Player) cs;
}
createReport(player);
try {
writeReport();
} catch (IOException e) {
}
postReport();
}
public PastebinReport(CommandSender cs, Player tp) {
createReport(tp);
try {
writeReport();
} catch (IOException e) {
}
postReport();
}
public String getURL() {
return url;
}
private void appendPermissionsTester(Player player) {
if (player == null) {
append("No player defined.");
return;
}
for (Permission node : Permission.values()) {
report.append(player.getName() + ": " + node.toString() + " " + node.get(player));
if (node.get(player) && !node.whichPermission(player).equals(node.toString())) {
report.append(" (Applied by " + node.whichPermission(player) + ")");
}
report.append('\n');
}
}
private void createReport(Player player) {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
append("------------ WARNING! ------------");
append("This report was run with NoCheatPlus enabled. Results may be inaccurate." + '\n');
}
append("------------ AntiCheat Report - " + DATE + " ------------");
appendSystemInfo();
append("------------Last 30 logs------------");
appendLogs();
append("------------Permission Tester------------");
appendPermissionsTester(player);
append("------------Event Chains------------");
appendEventHandlers();
append("------------Magic Diff------------");
appendMagicDiff();
append("-----------End Of Report------------");
}
private void appendLogs() {
List<String> logs = AntiCheatReloaded.getManager().getLoggingManager().getLastLogs();
if (logs.size() == 0) {
append("No recent logs.");
return;
}
for (String log : logs) {
append(log);
}
}
private void appendSystemInfo() {
Runtime runtime = Runtime.getRuntime();
Configuration config = AntiCheatReloaded.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheatReloaded.getVersion());
append("Server Version: " + Bukkit.getVersion());
append("Server Implementation: " + Bukkit.getName());
append("Server ID: " + Bukkit.getServerId());
append("NMS Version: " + VersionUtil.getVersion());
append("Java Version: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version"));
append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB");
append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB");
append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB");
append("Online Mode: " + Bukkit.getOnlineMode());
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheatReloaded.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
append("Enterprise: " + config.getConfig().enterprise.getValue());
if (config.getConfig().enterprise.getValue()) {
append("- Server name: " + config.getEnterprise().serverName.getValue());
append("- Database type: " + config.getEnterprise().database.getType());
append("- Groups source: " + (config.getEnterprise().configGroups.getValue() ? "Database" : "Flatfile"));
append("- Rules source: " + (config.getEnterprise().configRules.getValue() ? "Database" : "Flatfile"));
append("- Levels source: " + (config.getEnterprise().syncLevels.getValue() ? "Database" : "Flatfile"));
}
}
private void appendMagicDiff() {
// This is hacky, and I like it
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "magic.yml"));
boolean changed = false;
for (Field field : Magic.class.getFields()) {
Object defaultValue = file.get(field.getName());
try {
Field value = magic.getClass().getDeclaredField(field.getName());
String s1 = value.get(magic).toString();
String s2 = defaultValue.toString();
if (!s1.equals(s2) && !s1.equals(s2 + ".0")) {
changed = true;
append(field.getName() + ": " + s1 + " (Default: " + s2 + ")");
} else {
}
} catch (NoSuchFieldException ex) {
} catch (IllegalAccessException ex) {
}
}
if (!changed) {
append("No changes from default.");
}
}
private void appendEventHandlers() {
report.append(AntiCheatReloaded.getManager().getEventChainReport());
}
private void writeReport() throws IOException {
File f = new File(AntiCheatReloaded.getPlugin().getDataFolder() + "/report.txt");
FileWriter r = new FileWriter(f);
BufferedWriter writer = new BufferedWriter(r);
writer.write(report.toString());
writer.close();
}
private void postReport() {
try {
URL urls = new URL("http://pastebin.com/api/api_post.php");
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setRequestMethod("POST");
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
conn.setInstanceFollowRedirects(false);
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode(API_KEY, "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("1", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1M", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
out.flush();
out.close();
if (conn.getResponseCode() == 200) {
InputStream receive = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
String line;
StringBuffer response = new StringBuffer();
while ((line = reader.readLine()) != null) {
response.append(line);
response.append("\r\n");
}
reader.close();
String result = response.toString().trim();
if (!result.contains("http://")) {
url = "Failed to post. Check report.txt";
} else {
url = result.trim();
}
} else {
url = "Failed to post. Check report.txt";
}
} catch (Exception e) {
url = "Failed to post. Check report.txt";
}
}
private void append(String s) {
report.append(s + '\n');
}
}
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -21,77 +22,46 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public enum Permission { public enum Permission {
/* Check Nodes */ /* Check Nodes */
CHECK_ZOMBE_FLY, CHECK_ZOMBE_FLY, CHECK_ZOMBE_NOCLIP, CHECK_ZOMBE_CHEAT, CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
CHECK_ZOMBE_NOCLIP, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
CHECK_ZOMBE_CHEAT, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_FORCEFIELD, CHECK_LONGREACH,
CHECK_FLY, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_KILLAURA, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_UNICODE,
CHECK_WATERWALK,
CHECK_NOSWING,
CHECK_FASTBREAK,
CHECK_FASTPLACE,
CHECK_CHATSPAM,
CHECK_COMMANDSPAM,
CHECK_SPRINT,
CHECK_SNEAK,
CHECK_SPEED,
CHECK_VCLIP,
CHECK_SPIDER,
CHECK_NOFALL,
CHECK_FASTBOW,
CHECK_FASTEAT,
CHECK_FASTHEAL,
CHECK_FORCEFIELD,
CHECK_LONGREACH,
CHECK_FASTPROJECTILE,
CHECK_ITEMSPAM,
CHECK_VISUAL,
CHECK_FASTINVENTORY,
CHECK_AUTOTOOL,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_UPDATE, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
SYSTEM_RESET, SYSTEM_CALIBRATE, SYSTEM_CHECK, SYSTEM_DEBUG, SYSTEM_RELOAD;
SYSTEM_SPY,
SYSTEM_HELP,
SYSTEM_UPDATE,
SYSTEM_REPORT,
SYSTEM_ALERT,
SYSTEM_NOTICE,
SYSTEM_CALIBRATE,
SYSTEM_CHECK,
SYSTEM_DEBUG,
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK, VELOCITY, CRITICALS;
private static final String PERMISSION_ALL = "anticheat.*"; private static final String PERMISSION_ALL = "anticheat.*";
private static final String PERMISSION_SPAM = "anticheat.check.spam"; private static final String PERMISSION_SPAM = "anticheat.check.spam";
public static boolean getCommandExempt(CommandSender cs, String commandLabel) { public static boolean getCommandExempt(CommandSender cs, String commandLabel) {
// Check permission, base, and all will have already been checked // Check permission, base, and all will have already been checked
return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel); return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel);
} }
public boolean get(CommandSender cs) { public boolean get(CommandSender cs) {
if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM)) return true; if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM))
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL); return true;
} return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
}
public String getBase() { public String getBase() {
return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*"; return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*";
} }
public String whichPermission(CommandSender cs) { public String whichPermission(CommandSender cs) {
for (String s : new String[]{PERMISSION_ALL, getBase(), toString()}) { for (String s : new String[] { PERMISSION_ALL, getBase(), toString() }) {
if (cs.hasPermission(s)) { if (cs.hasPermission(s)) {
return s; return s;
} }
} }
return null; return null;
} }
@Override @Override
public String toString() { public String toString() {
return "anticheat." + this.name().toLowerCase().replace("_", "."); return "anticheat." + this.name().toLowerCase().replace("_", ".");
} }
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -22,27 +23,22 @@ import org.bukkit.Material;
public enum ToolHardness { public enum ToolHardness {
// NOTHING(null, 1.5) // NOTHING(null, 1.5)
WOOD(0.75D), WOOD(0.75D), STONE(0.40D), IRON(0.25D), DIAMOND(0.20D), SHEARS(0.55D), GOLD(0.15D);
STONE(0.40D),
IRON(0.25D),
DIAMOND(0.20D),
SHEARS(0.55D),
GOLD(0.15D);
double hardness; double hardness;
ToolHardness(double hard) { ToolHardness(double hard) {
hardness = hard; hardness = hard;
} }
public static double getToolHardness(Material tool) { public static double getToolHardness(Material tool) {
for (ToolHardness e : ToolHardness.values()) { for (ToolHardness e : ToolHardness.values()) {
if (tool.name().contains(e.name())) { if (tool.name().contains(e.name())) {
return e.hardness; return e.hardness;
} }
} }
return 1.50D; return 1.50D;
} }
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -35,397 +36,401 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class User { public class User {
private final UUID uuid; private final UUID uuid;
private final String name; private final String name;
private final int id; private final int id;
private int level = 0; private int level = 0;
private Location goodLocation; private Location goodLocation;
private List<ItemStack> inventorySnapshot = null; private List<ItemStack> inventorySnapshot = null;
private Configuration config = AntiCheatReloaded.getManager().getConfiguration(); private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
private int toX, toY, toZ; private int toX, toY, toZ;
private String[] messages = new String[2]; private String[] messages = new String[2];
private Long[] messageTimes = new Long[2]; private Long[] messageTimes = new Long[2];
private String[] commands = new String[2]; private String[] commands = new String[2];
private Long[] commandTimes = new Long[2]; private Long[] commandTimes = new Long[2];
private boolean isWaitingOnLevelSync; private boolean isWaitingOnLevelSync;
private Timestamp levelSyncTimestamp; private Timestamp levelSyncTimestamp;
/** /**
* Initialize an AntiCheat user * Initialize an AntiCheat user
* *
* @param uuid Player's UUID * @param uuid Player's UUID
*/ */
public User(UUID uuid) { public User(UUID uuid) {
this.uuid = uuid; this.uuid = uuid;
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : ""; this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1; this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
} }
/** /**
* Initialize an AntiCheat user * Initialize an AntiCheat user
* *
* @param name Player's name * @param name Player's name
*/ */
/* public User(String name) { /*
this.uuid = Bukkit.getPlayer(name).getUniqueId(); * public User(String name) { this.uuid = Bukkit.getPlayer(name).getUniqueId();
this.name = name; * this.name = name; this.id = getPlayer() != null && getPlayer().isOnline() ?
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1; * getPlayer().getEntityId() : -1; }
} */
*/ /**
/** * Get the player's UUID
* Get the player's UUID *
* * @return Player UUID
* @return Player UUID */
*/ public UUID getUUID() {
public UUID getUUID() { return uuid;
return uuid; }
}
/** /**
* Get the player's name * Get the player's name
* *
* @return Player name * @return Player name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* Get the player's entity ID * Get the player's entity ID
* *
* @return Entity id * @return Entity id
*/ */
public int getId() { public int getId() {
return id; return id;
} }
/** /**
* Get the Bukkit player * Get the Bukkit player
* *
* @return Player * @return Player
*/ */
public Player getPlayer() { public Player getPlayer() {
return Bukkit.getPlayer(uuid); return Bukkit.getPlayer(uuid);
} }
/** /**
* Get the user's level value * Get the user's level value
* *
* @return level * @return level
*/ */
public int getLevel() { public int getLevel() {
return level; return level;
} }
/** /**
* Get the user's group * Get the user's group
* *
* @return group * @return group
*/ */
public Group getGroup() { public Group getGroup() {
List<Group> groups = config.getGroups().getGroups(); List<Group> groups = config.getGroups().getGroups();
for (int i = 0; i < groups.size(); i++) { for (int i = 0; i < groups.size(); i++) {
if (i == 0 && level < groups.get(i).getLevel()) break; if (i == 0 && level < groups.get(i).getLevel())
else if (i == groups.size() - 1) return groups.get(i); break;
else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel()) return groups.get(i); else if (i == groups.size() - 1)
} return groups.get(i);
return null; else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel())
} return groups.get(i);
}
return null;
}
/** /**
* Increase the player's level (from failing a check) * Increase the player's level (from failing a check)
* *
* @param type The check failed * @param type The check failed
* @return true if the level was increased * @return true if the level was increased
*/ */
public boolean increaseLevel(CheckType type) { public boolean increaseLevel(CheckType type) {
if (getPlayer() != null && getPlayer().isOnline()) { if (getPlayer() != null && getPlayer().isOnline()) {
if (silentMode() && type.getUses(uuid) % 4 != 0) { if (silentMode() && type.getUses(uuid) % 4 != 0) {
// Prevent silent mode from increasing the level way too fast // Prevent silent mode from increasing the level way too fast
return false; return false;
} else { } else {
if (level < config.getGroups().getHighestLevel()) { if (level < config.getGroups().getHighestLevel()) {
level++; level++;
// Check levels // Check levels
for (Group l : getLevels()) { for (Group l : getLevels()) {
if (l.getLevel() == level) { if (l.getLevel() == level) {
AntiCheatReloaded.getManager().getUserManager().alert(this, l, type); AntiCheatReloaded.getManager().getUserManager().alert(this, l, type);
if (l.getLevel() == config.getGroups().getHighestLevel()) { if (l.getLevel() == config.getGroups().getHighestLevel()) {
level = l.getLevel() - 10; level = l.getLevel() - 10;
} }
} }
} }
// Execute rules // Execute rules
for (Rule rule : config.getRules().getRules()) { for (Rule rule : config.getRules().getRules()) {
rule.check(this, type); rule.check(this, type);
} }
return true; return true;
} }
return false; return false;
} }
} else { } else {
return false; return false;
} }
} }
/** /**
* Decrease the player's level by one value * Decrease the player's level by one value
*/ */
public void decreaseLevel() { public void decreaseLevel() {
level = level != 0 ? level - 1 : 0; level = level != 0 ? level - 1 : 0;
} }
/** /**
* Set the users level to a specific value. Must be 0 < level < config-defined highest level * Set the users level to a specific value. Must be 0 < level < config-defined
* * highest level
* @param level level to set *
* @return true if the level was valid and set properly * @param level level to set
*/ * @return true if the level was valid and set properly
public boolean setLevel(int level) { */
isWaitingOnLevelSync = false; public boolean setLevel(int level) {
if (level >= 0) { isWaitingOnLevelSync = false;
if (level <= config.getGroups().getHighestLevel()) { if (level >= 0) {
this.level = level; if (level <= config.getGroups().getHighestLevel()) {
return true; this.level = level;
} else { return true;
this.level = config.getGroups().getHighestLevel(); } else {
return false; this.level = config.getGroups().getHighestLevel();
} return false;
} else { }
return false; } else {
} return false;
} }
}
/** /**
* Reset the user's level to zero and clear all check failures * Reset the user's level to zero and clear all check failures
*/ */
public void resetLevel() { public void resetLevel() {
level = 0; level = 0;
for (CheckType type : CheckType.values()) { for (CheckType type : CheckType.values()) {
type.clearUse(uuid); type.clearUse(uuid);
} }
} }
/** /**
* Get the last known valid location of the player for use in resetting * Get the last known valid location of the player for use in resetting
* *
* @param location default value to be returned if no known good location exists * @param location default value to be returned if no known good location exists
* @return last known valid location * @return last known valid location
*/ */
public Location getGoodLocation(Location location) { public Location getGoodLocation(Location location) {
if (goodLocation == null) { if (goodLocation == null) {
return location; return location;
} }
return goodLocation; return goodLocation;
} }
/** /**
* Set the last known valid location of the player * Set the last known valid location of the player
* *
* @param location location to be set * @param location location to be set
* @return true if the location was valid and set properly * @return true if the location was valid and set properly
*/ */
public boolean setGoodLocation(Location location) { public boolean setGoodLocation(Location location) {
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) { if (Utilities.cantStandAtExp(location)
return false; || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
} return false;
}
goodLocation = location; goodLocation = location;
return true; return true;
} }
/** /**
* Store a copy of the player's inventory, for use in resetting * Store a copy of the player's inventory, for use in resetting
* *
* @param is ItemStack list to store * @param is ItemStack list to store
*/ */
public void setInventorySnapshot(ItemStack[] is) { public void setInventorySnapshot(ItemStack[] is) {
inventorySnapshot = new ArrayList<ItemStack>(); inventorySnapshot = new ArrayList<ItemStack>();
for (int i = 0; i < is.length; i++) { for (int i = 0; i < is.length; i++) {
if (is[i] != null) { if (is[i] != null) {
inventorySnapshot.add(is[i].clone()); inventorySnapshot.add(is[i].clone());
} }
} }
} }
/** /**
* Remove the current inventory snapshot * Remove the current inventory snapshot
*/ */
public void removeInventorySnapshot() { public void removeInventorySnapshot() {
inventorySnapshot = null; inventorySnapshot = null;
} }
/** /**
* Restore the player's inventory with the current inventory snapshot * Restore the player's inventory with the current inventory snapshot
* *
* @param inventory Player's inventory * @param inventory Player's inventory
*/ */
public void restoreInventory(Inventory inventory) { public void restoreInventory(Inventory inventory) {
if (inventorySnapshot != null) { if (inventorySnapshot != null) {
inventory.clear(); inventory.clear();
for (ItemStack is : inventorySnapshot) { for (ItemStack is : inventorySnapshot) {
if (is != null) { if (is != null) {
inventory.addItem(is); inventory.addItem(is);
} }
} }
} }
} }
/** /**
* Set the player's to location * Set the player's to location
* *
* @param x X value * @param x X value
* @param y Y value * @param y Y value
* @param z Z value * @param z Z value
*/ */
public void setTo(double x, double y, double z) { public void setTo(double x, double y, double z) {
toX = (int) x; toX = (int) x;
toY = (int) y; toY = (int) y;
toZ = (int) z; toZ = (int) z;
} }
/** /**
* Check if a given to value is the same as the stored value * Check if a given to value is the same as the stored value
* *
* @param x X value * @param x X value
* @param y Y value * @param y Y value
* @param z Z value * @param z Z value
* @return true if coordinates are all equal * @return true if coordinates are all equal
*/ */
public boolean checkTo(double x, double y, double z) { public boolean checkTo(double x, double y, double z) {
return (int) x == toX && (int) y == toY && (int) z == toZ; return (int) x == toX && (int) y == toY && (int) z == toZ;
} }
/** /**
* Log a player's chat message * Log a player's chat message
* *
* @param message Message to log * @param message Message to log
*/ */
public void addMessage(String message) { public void addMessage(String message) {
addToSpamLog(message, messages, messageTimes); addToSpamLog(message, messages, messageTimes);
} }
/** /**
* Log a player's command * Log a player's command
* *
* @param command Command to log * @param command Command to log
*/ */
public void addCommand(String command) { public void addCommand(String command) {
addToSpamLog(command, commands, commandTimes); addToSpamLog(command, commands, commandTimes);
} }
private void addToSpamLog(String string, String[] messages, Long[] times) { private void addToSpamLog(String string, String[] messages, Long[] times) {
messages[1] = messages[0]; messages[1] = messages[0];
messages[0] = string; messages[0] = string;
times[1] = times[0]; times[1] = times[0];
times[0] = System.currentTimeMillis(); times[0] = System.currentTimeMillis();
} }
/** /**
* Get a stored chat message * Get a stored chat message
* *
* @param index Index of the chat in storage * @param index Index of the chat in storage
* @return the message * @return the message
*/ */
public String getMessage(int index) { public String getMessage(int index) {
return messages[index]; return messages[index];
} }
/** /**
* Get a stored command * Get a stored command
* *
* @param index Index of the command in storage * @param index Index of the command in storage
* @return the command * @return the command
*/ */
public String getCommand(int index) { public String getCommand(int index) {
return commands[index]; return commands[index];
} }
/** /**
* Get the time a message in storage was sent * Get the time a message in storage was sent
* *
* @param index Index of the chat in storage * @param index Index of the chat in storage
* @return time the message was sent * @return time the message was sent
*/ */
public Long getMessageTime(int index) { public Long getMessageTime(int index) {
return messageTimes[index]; return messageTimes[index];
} }
/** /**
* Get the time a command in storage was sent * Get the time a command in storage was sent
* *
* @param index Index of the command in storage * @param index Index of the command in storage
* @return time the command was sent * @return time the command was sent
*/ */
public Long getCommandTime(int index) { public Long getCommandTime(int index) {
return commandTimes[index]; return commandTimes[index];
} }
/** /**
* Clear all stored messages * Clear all stored messages
*/ */
public void clearMessages() { public void clearMessages() {
messages = new String[2]; messages = new String[2];
messageTimes = new Long[2]; messageTimes = new Long[2];
} }
/** /**
* Clear all stored commands * Clear all stored commands
*/ */
public void clearCommands() { public void clearCommands() {
commands = new String[2]; commands = new String[2];
commandTimes = new Long[2]; commandTimes = new Long[2];
} }
/** /**
* Get the time the very last stored message was sent * Get the time the very last stored message was sent
* *
* @return the last message's time * @return the last message's time
*/ */
public Long getLastMessageTime() { public Long getLastMessageTime() {
return getMessageTime(0) == null ? -1 : getMessageTime(0); return getMessageTime(0) == null ? -1 : getMessageTime(0);
} }
/** /**
* Get the time the very last stored command was sent * Get the time the very last stored command was sent
* *
* @return the last command's time * @return the last command's time
*/ */
public Long getLastCommandTime() { public Long getLastCommandTime() {
return getCommandTime(0) == null ? -1 : getCommandTime(0); return getCommandTime(0) == null ? -1 : getCommandTime(0);
} }
private List<Group> getLevels() { private List<Group> getLevels() {
return config.getGroups().getGroups(); return config.getGroups().getGroups();
} }
private boolean silentMode() { private boolean silentMode() {
return config.getConfig().silentMode.getValue(); return config.getConfig().silentMode.getValue();
} }
public void setIsWaitingOnLevelSync(boolean b) { public void setIsWaitingOnLevelSync(boolean b) {
this.isWaitingOnLevelSync = b; this.isWaitingOnLevelSync = b;
} }
public boolean isWaitingOnLevelSync() { public boolean isWaitingOnLevelSync() {
return isWaitingOnLevelSync; return isWaitingOnLevelSync;
} }
public void setLevelSyncTimestamp(Timestamp timestamp) { public void setLevelSyncTimestamp(Timestamp timestamp) {
levelSyncTimestamp = timestamp; levelSyncTimestamp = timestamp;
} }
public Timestamp getLevelSyncTimestamp() { public Timestamp getLevelSyncTimestamp() {
return levelSyncTimestamp; return levelSyncTimestamp;
} }
@Override @Override
public String toString() { public String toString() {
return "User {name = " + getName() + ", level = " + level + "}"; return "User {name = " + getName() + ", level = " + level + "}";
} }
} }
File diff suppressed because it is too large. Load diff
@@ -1,27 +1,42 @@
/*
* 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.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
public class VersionUtil { public class VersionUtil {
private static final List<String> SUPPORTED_VERSIONS = Arrays.asList(new String[] { private static final List<String> SUPPORTED_VERSIONS = Arrays
"v1_8", .asList(new String[] { "v1_15" });
"v1_9",
"v1_10",
"v1_11",
"v1_12"
});
public static String getVersion() { public static String getVersion() {
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} }
public static boolean isSupported() { public static boolean isSupported() {
for (String versionId : SUPPORTED_VERSIONS) { for (String versionId : SUPPORTED_VERSIONS) {
if (getVersion().startsWith(versionId)) { if (getVersion().startsWith(versionId)) {
@@ -30,54 +45,34 @@ public class VersionUtil {
} }
return false; return false;
} }
private static final EnumSet<Material> MOVE_UP_BLOCKS_1_8 = EnumSet.of(Material.ACACIA_STAIRS,
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS,
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS,
Material.RED_SANDSTONE_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS,
Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS);
public static boolean isFlying(Player p) { public static boolean isFlying(Player p) {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) { return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
return p.isFlying() || p.isGliding() || p.hasPotionEffect(NMS_1_9_PLUS.LEVITATION);
} else {
return p.isFlying();
}
}
public static EnumSet<Material> getMoveUpBlocks() {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) {
return NMS_1_9_PLUS.MOVE_UP_BLOCKS_1_9;
} else {
return MOVE_UP_BLOCKS_1_8;
}
}
public static boolean isNewYSpeed() {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) {
return true;
} else {
return false;
}
} }
public static long getHealTime() { public static long getHealTime() {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) { return 495;
return 495;
} else {
return 1995;
}
} }
public static boolean isFrostWalk(Player player) { public static boolean isFrostWalk(Player player) {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) { if (player.getInventory().getBoots() == null) {
if (player.getInventory().getBoots() == null) {
return false;
}
return player.getInventory().getBoots().containsEnchantment(NMS_1_9_PLUS.FROST_WALKER);
} else {
return false; return false;
} }
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
}
public static ItemStack getItemInHand(Player player) {
return player.getInventory().getItemInMainHand();
} }
public static int getPlayerPing(Player player) {
try {
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
return ping;
} catch (Exception e) {
return -1;
}
}
} }
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1,6 +1,7 @@
/* /*
* AntiCheat for Bukkit. * AntiCheatReloaded for Bukkit and Spigot.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net * Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -87,7 +88,7 @@ public class Rule {
private Type type; private Type type;
public enum Type { public enum Type {
CONDITIONAL(".*[?]*.*:.*", "net.gravitydevelopment.anticheat.util.rule.ConditionalRule"); CONDITIONAL(".*[?]*.*:.*", "com.rammelkast.anticheatreloaded.util.rule.ConditionalRule");
private String regex; private String regex;
private String c; private String c;
-2
View File
@@ -15,8 +15,6 @@ spam:
action-one: KICK action-one: KICK
action-two: BAN action-two: BAN
system: system:
# Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.
auto-update: true
# Should AntiCheatReloaded log ALL failed checks to console? # Should AntiCheatReloaded log ALL failed checks to console?
log-to-console: false log-to-console: false
# Should AntiCheatReloaded log to file? # Should AntiCheatReloaded log to file?
+1 -1
View File
@@ -17,7 +17,7 @@ database:
# Password for the user # Password for the user
password: '' password: ''
# Prefix for the tables # Prefix for the tables
prefix: 'ac_' prefix: 'acr_'
# Database/Schema to use # Database/Schema to use
database: 'anticheat' database: 'anticheat'
# Logging settings # Logging settings
+13 -3
View File
@@ -1,4 +1,9 @@
# AntiCheatReloaded configuration file # AntiCheatReloaded configuration file
#
# This file is not yet fully documented
# For more information on the undocumented values visit:
# https://github.com/Rammelkast/AntiCheatReloaded/blob/master/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java#L39-L380
#
ANIMATION_INTERACT_MAX: 3 ANIMATION_INTERACT_MAX: 3
ANIMATION_MIN: 200 ANIMATION_MIN: 200
ASCENSION_COUNT_MAX: 8 ASCENSION_COUNT_MAX: 8
@@ -80,9 +85,14 @@ XZ_SPEED_MAX_WATER_SPRINT: 0.3
Y_MAXDIFF: 5.0 Y_MAXDIFF: 5.0
Y_MAXVIOLATIONS: 1 Y_MAXVIOLATIONS: 1
Y_MAXVIOTIME: 5500 Y_MAXVIOTIME: 5500
Y_SPEED_MAX: 0.5125 Y_SPEED_MAX: 0.5175
Y_TIME: 800 Y_TIME: 800
# Amount of suspicious mid-air movements before a player is suspected of glide
# Increase this in case of false positives
GLIDE_LIMIT: 10 GLIDE_LIMIT: 10
KILLAURA_BOTHITS: 4 # Maximum amount of movement packets allowed per second
BLINK_PACKET: 74 # Increase this in case of false positives
BLINK_PACKET: 25
# Maximum amount zero-velocity moments before a player is suspected
# Increase this in case of false positives
VELOCITY_AMT: 5 VELOCITY_AMT: 5
+21 -5
View File
@@ -2,14 +2,15 @@ name: AntiCheatReloaded
author: Rammelkast author: Rammelkast
description: AntiCheatReloaded helps easily identify and block malicious users on your server. description: AntiCheatReloaded helps easily identify and block malicious users on your server.
main: com.rammelkast.anticheatreloaded.AntiCheatReloaded main: com.rammelkast.anticheatreloaded.AntiCheatReloaded
api-version: 1.13
depend: [ProtocolLib] depend: [ProtocolLib]
startup: postworld startup: postworld
version: ${project.build.version} version: ${project.build.version}
commands: commands:
anticheat: anticheat:
description: Control and view info about AntiCheat description: Control and view info about AntiCheatReloaded
usage: /anticheat help usage: /anticheat help
aliases: anti aliases: acr
permissions: permissions:
anticheat.system.notice: anticheat.system.notice:
description: See broadcasts when a player is kicked or banned for hacking description: See broadcasts when a player is kicked or banned for hacking
@@ -60,9 +61,12 @@ permissions:
anticheat.check.zombe.cheat: anticheat.check.zombe.cheat:
description: Allow players to use zombe cheat hack description: Allow players to use zombe cheat hack
default: false default: false
anticheat.check.fly: anticheat.check.flight:
description: Allow players to fly description: Allow players to fly
default: false default: false
anticheat.check.elytra:
description: Allow players to fly when using elytra
default: false
anticheat.check.waterwalk: anticheat.check.waterwalk:
description: Allow players to walk on water description: Allow players to walk on water
default: false default: false
@@ -126,8 +130,20 @@ permissions:
anticheat.check.autotool: anticheat.check.autotool:
description: Allow players to use autotool to switch tools quickly description: Allow players to use autotool to switch tools quickly
default: false default: false
anticheat.check.fastanimation: anticheat.check.killaura:
description: Allow players to attack or interact very quickly description: Allow players to use killaura
default: false
anticheat.check.blink:
description: Allow players to send lots of movement packets
default: false
anticheat.check.velocity:
description: Allow players to use knockback prevention
default: false
anticheat.check.criticals:
description: Allow players to use criticals
default: false
anticheat.check.unicode:
description: Allow players to use unicode in chat
default: false default: false
anticheat.check.exempt: anticheat.check.exempt:
description: Total exemption from checks description: Total exemption from checks