Compare commits

..
20 Commits
Author SHA1 Message Date
marcomoesman 06c1eab2e6 Fixed a lot of things. Plugin should work a lot better on 1.12 now. 2018-08-13 14:36:05 +02:00
Rammelkast f609758d28 Ready for Minecraft 1.12 2017-11-20 19:34:51 +01:00
Rammelkast 2d064ee849 1.12 fixes 2017-11-18 17:04:03 +01:00
Rammelkast 717b7acb67 Quick metrics fix 2017-11-18 16:55:20 +01:00
Rammelkast 2617aa1225 Cleanup 2017-05-06 16:00:08 +02:00
Rammelkast dd8c495ee6 Modify Metrics data & fix 2017-03-03 12:40:30 +01:00
Rammelkast 09ddbfba8f Fixed stuff, added new metrics graphs 2017-03-02 15:08:45 +01:00
Rammelkast 7f13a0ad4c Renamed package and groupId 2017-02-05 13:47:13 +01:00
Rammelkast 21d0108c16 Added extra strings to NameGenerator for more randomization 2017-02-05 13:42:31 +01:00
Rammelkast 15181ab6ad Cleanup 2017-02-05 13:34:51 +01:00
Rammelkast 347eec8ff0 Added glide check 2017-02-05 13:34:26 +01:00
Rammelkast 518e4c32e7 Fix #32 2017-02-04 20:45:55 +01:00
Rammelkast 583d2de244 Fix #33 2017-02-04 20:44:34 +01:00
Rammelkast 792a4ae0a5 Replace mcstats metrics with bStats metrics 2017-02-04 20:43:28 +01:00
Rammelkast 406ba01523 Fix #27 2017-01-15 16:44:42 +01:00
Rammelkast b2571a32f1 Fix #29 2017-01-15 16:27:24 +01:00
Rammelkast 52b96bedc4 Add metrics 2017-01-15 16:12:41 +01:00
Rammelkast 01602e187c Update Readme 2017-01-03 16:23:27 +01:00
Rammelkast db13527498 Fix #26 2017-01-03 16:14:29 +01:00
Rammelkast 1e4aaab2c0 Fix #21 2016-12-01 15:30:24 +01:00
84 changed files with 2240 additions and 1003 deletions

No files matched your search

+19 -15
View File
@@ -3,11 +3,26 @@ AntiCheatReloaded
AntiCheatReloaded is a fork of the old 'AntiCheat' project. AntiCheatReloaded is a fork of the old 'AntiCheat' project.
AntiCheat helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players. AntiCheat helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players.
###Want to help me out? ### BTC donations: 1DwUKboRQKrgR9o1oZC4VutkCUwdZStHtk
First of all, i've put a lot of time and work in this project, so donations (especially in (m)BTC) are appreciated! ### LTC donations: LTXzGnVLXmiH5XJch1bKrcZtzQjaF9rd8V
My BTC address is 1JfyX6hvGUazHTtKVLaNcYaUxnyjR5HtMY
###Hacks blocked Bug Reporting
------------
Issues should be filed by hitting the [issues](https://github.com/Rammelkast/AntiCheatReloaded/issues?state=open) tab above. Please make sure you search your issue before opening a new ticket.
Please include the following information with your issue, this allows me to fix it quicker;
* The `/anticheat debug` log
* Your AntiCheatReloaded version
* Your server software (Bukkit/Spigot/Other) and it's version
* If you use ProtocolLib, your ProtocolLib version
* Whether or not you are using protocol hacks (ViaVersion etc.)
Usage
-------
Simply drag and drop the plugin file and the ProtocolLib jar into your Plugins folder.
Hacks blocked
------- -------
* Blink * Blink
* Flight * Flight
@@ -30,14 +45,3 @@ My BTC address is 1JfyX6hvGUazHTtKVLaNcYaUxnyjR5HtMY
* FastPlace * FastPlace
* Spam * Spam
* FastEat * FastEat
Usage
-------
Simply drag and drop the plugin and the ProtoclLib into your Plugins folder.
Bug Reporting/Support/Questions
------------
Issues should be filed by hitting the [issues](https://github.com/Rammelkast/AntiCheatReloaded/issues?state=open) tab above. Please make sure you search your issue before opening a new ticket.
All opened tickets that are bug reports require a debug log that includes logs of the issue in question. To obtain this, type `/anticheat debug` on your server. Note that for the debug output to contain valid information and help us diagnose your issue, you need to issue this command AFTER the issue occurs at least once and BEFORE you reload or restart it.
+13 -17
View File
@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.gravitydevelopment.anticheat</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheat</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.5.4-ALPHA</version> <version>1.6.3-ALPHA</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://rammelkast.com</url> <url>https://rammelkast.com</url>
<properties> <properties>
@@ -14,10 +14,6 @@
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url> <url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>http://maven.elmakers.com/repository/</url>
</repository> </repository>
</repositories> </repositories>
<build> <build>
@@ -26,16 +22,16 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.5</version>
<configuration> <configuration>
<source>1.6</source> <source>1.8</source>
<target>1.6</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>1.3</version> <version>3.1.1</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -47,7 +43,7 @@
<configuration> <configuration>
<artifactSet> <artifactSet>
<includes> <includes>
<include>net.gravitydevelopment.*</include> <include>com.rammelkast.*</include>
</includes> </includes>
</artifactSet> </artifactSet>
</configuration> </configuration>
@@ -84,8 +80,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib-API</artifactId>
<version>4.1.0-SNAPSHOT</version> <version>4.3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@@ -97,7 +93,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -0,0 +1,325 @@
/*
* 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;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
import com.rammelkast.anticheatreloaded.command.CommandHandler;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.event.BlockListener;
import com.rammelkast.anticheatreloaded.event.EntityListener;
import com.rammelkast.anticheatreloaded.event.InventoryListener;
import com.rammelkast.anticheatreloaded.event.PlayerListener;
import com.rammelkast.anticheatreloaded.event.VehicleListener;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import com.rammelkast.anticheatreloaded.metrics.Metrics;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class AntiCheatReloaded extends JavaPlugin {
private static AntiCheatManager manager;
private static AntiCheatReloaded plugin;
private static List<Listener> eventList = new ArrayList<Listener>();
private static Configuration config;
private static boolean verbose;
private static boolean developer;
private static ProtocolManager protocolManager;
private static SecureRandom random;
private static Long loadTime;
@Override
public void onEnable() {
plugin = this;
random = new SecureRandom();
loadTime = System.currentTimeMillis();
manager = new AntiCheatManager(this, getLogger());
eventList.add(new PlayerListener());
eventList.add(new BlockListener());
eventList.add(new EntityListener());
eventList.add(new VehicleListener());
eventList.add(new InventoryListener());
// Order is important in some cases, don't screw with these unless
// needed, especially config
setupConfig();
setupEvents();
setupCommands();
// Enterprise must come before levels
setupEnterprise();
restoreLevels();
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
setupProtocol();
} else {
getLogger().severe("Shutting down, ProtocolLib not found!");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
getLogger().info("NMS version is " + VersionUtil.getVersion());
if (!VersionUtil.isSupported()) {
Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.RED + "The version of this server is NOT supported by ACR! The plugin will be buggy!");
}
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
// Enable packetlisteners
KillAuraCheck.listenPackets();
BlinkCheck.startTimer();
BlinkCheck.listenPackets();
// Check if other AC's are installed
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
public void run() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running NoCheatPlus!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running AAC!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AAC to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("Spartan") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running Spartan!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AAC to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("NoAura") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running NoAura!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AAC to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("AntiCheat") != null || Bukkit.getPluginManager().getPlugin("AntiCheatPlus") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running AntiCheat!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AntiCheat to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
}
}, 90L);
// End tests
verboseLog("Finished loading.");
// Metrics
try {
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked") {
@Override
public int getValue() {
int kicked = playersKicked;
// Reset so we don't keep sending the same value
playersKicked = 0;
return kicked;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("killaura_violations") {
@Override
public int getValue() {
int violations = killauraViolations;
// Reset so we don't keep sending the same value
killauraViolations = 0;
return violations;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations") {
@Override
public int getValue() {
int violations = glideViolations;
// Reset so we don't keep sending the same value
glideViolations = 0;
return violations;
}
});
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version") {
@Override
public String getValue() {
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
}
});
metrics.addCustomChart(new Metrics.SimplePie("nms_version") {
@Override
public String getValue() {
return VersionUtil.getVersion();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onDisable() {
verboseLog("Saving user levels...");
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
AntiCheatManager.close();
getServer().getScheduler().cancelTasks(this);
cleanup();
}
private void setupProtocol() {
protocolManager = ProtocolLibrary.getProtocolManager();
verboseLog("Hooked into ProtocolLib");
}
private void setupEvents() {
for (Listener listener : eventList) {
getServer().getPluginManager().registerEvents(listener, this);
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
}
}
private void setupCommands() {
getCommand("anticheat").setExecutor(new CommandHandler());
verboseLog("Registered commands.");
}
private void setupConfig() {
config = manager.getConfiguration();
verboseLog("Setup the config.");
}
private void setupEnterprise() {
if (config.getConfig().enterprise.getValue()) {
if (config.getEnterprise().loggingEnabled.getValue()) {
config.getEnterprise().database.cleanEvents();
}
}
}
private void restoreLevels() {
for (Player player : getServer().getOnlinePlayers()) {
UUID uuid = player.getUniqueId();
User user = new User(uuid);
user.setIsWaitingOnLevelSync(true);
config.getLevels().loadLevelToUser(user);
manager.getUserManager().addUser(user);
verboseLog("Data for " + uuid + " loaded");
}
}
public static AntiCheatReloaded getPlugin() {
return plugin;
}
public static AntiCheatManager getManager() {
return manager;
}
public static SecureRandom getRandom() {
return random;
}
public static String getVersion() {
return manager.getPlugin().getDescription().getVersion();
}
private void cleanup() {
eventList = null;
manager = null;
config = null;
}
public static boolean developerMode() {
return developer;
}
public static void setDeveloperMode(boolean b) {
developer = b;
}
public static void debugLog(final String string) {
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
public void run() {
if (developer) {
manager.debugLog("[DEBUG] " + string);
}
}
});
}
public void verboseLog(final String string) {
if (verbose) {
getLogger().info(string);
}
}
public void setVerbose(boolean b) {
verbose = b;
}
public Long getLoadTime() {
return loadTime;
}
public static ProtocolManager getProtocolManager() {
return protocolManager;
}
/**
* Amount of players kicked since start
*/
private int playersKicked = 0;
/**
* Amount of killaura violations since start
*/
private int killauraViolations = 0;
/**
* Amount of glide violations since start
*/
private int glideViolations = 0;
public void onPlayerKicked() {
this.playersKicked++;
}
public void onKillAuraViolation() {
this.killauraViolations++;
}
public void onGlideViolation() {
this.glideViolations++;
}
}
@@ -16,26 +16,26 @@
* 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 net.gravitydevelopment.anticheat.api; package com.rammelkast.anticheatreloaded.api;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.manage.CheckManager; import com.rammelkast.anticheatreloaded.manage.CheckManager;
import net.gravitydevelopment.anticheat.manage.UserManager; import com.rammelkast.anticheatreloaded.manage.UserManager;
import net.gravitydevelopment.anticheat.util.Group; import com.rammelkast.anticheatreloaded.util.Group;
/** /**
* Developer's interface for all things AntiCheat. * Developer's interface for all things AntiCheat.
*/ */
public class AntiCheatAPI { public class AntiCheatAPI {
private static CheckManager chk = AntiCheat.getManager().getCheckManager(); private static CheckManager chk = AntiCheatReloaded.getManager().getCheckManager();
private static UserManager umr = AntiCheat.getManager().getUserManager(); private static UserManager umr = AntiCheatReloaded.getManager().getUserManager();
// CheckManager API // CheckManager API
@@ -146,7 +146,7 @@ public class AntiCheatAPI {
} }
/** /**
* Get a user's {@link net.gravitydevelopment.anticheat.util.Group} * Get a user's {@link com.rammelkast.anticheatreloaded.util.Group}
* *
* @param player Player whose group to find * @param player Player whose group to find
* @return The player's group * @return The player's group
@@ -159,7 +159,7 @@ public class AntiCheatAPI {
* Get all configured Groups * Get all configured Groups
* *
* @return List of all groups * @return List of all groups
* @see net.gravitydevelopment.anticheat.util.Group * @see com.rammelkast.anticheatreloaded.util.Group
*/ */
public static List<Group> getGroups() { public static List<Group> getGroups() {
return getManager().getConfiguration().getGroups().getGroups(); return getManager().getConfiguration().getGroups().getGroups();
@@ -173,7 +173,7 @@ public class AntiCheatAPI {
* @return the AntiCheat Manager * @return the AntiCheat Manager
*/ */
public static AntiCheatManager getManager() { public static AntiCheatManager getManager() {
return AntiCheat.getManager(); return AntiCheatReloaded.getManager();
} }
@@ -16,13 +16,14 @@
* 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 net.gravitydevelopment.anticheat.api; package com.rammelkast.anticheatreloaded.api;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
/** /**
* Fired when a player fails an AntiCheat check * Fired when a player fails an AntiCheat check
*/ */
@@ -40,18 +41,18 @@ public class CheckFailEvent extends Event {
} }
/** /**
* Get the {@link net.gravitydevelopment.anticheat.util.User} who failed the check * Get the {@link com.rammelkast.anticheatreloaded.util.User} who failed the check
* *
* @return a {@link net.gravitydevelopment.anticheat.util.User} * @return a {@link com.rammelkast.anticheatreloaded.util.User}
*/ */
public User getUser() { public User getUser() {
return user; return user;
} }
/** /**
* Get the {@link net.gravitydevelopment.anticheat.check.CheckType} failed * Get the {@link com.rammelkast.anticheatreloaded.check.CheckType} failed
* *
* @return a {@link net.gravitydevelopment.anticheat.check.CheckType} * @return a {@link com.rammelkast.anticheatreloaded.check.CheckType}
*/ */
public CheckType getCheck() { public CheckType getCheck() {
return type; return type;
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.check; package com.rammelkast.anticheatreloaded.check;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@@ -37,23 +36,23 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck; import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck; import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
import net.gravitydevelopment.anticheat.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import net.gravitydevelopment.anticheat.check.movement.GlideCheck; import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck; import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
import net.gravitydevelopment.anticheat.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import net.gravitydevelopment.anticheat.config.providers.Lang; import com.rammelkast.anticheatreloaded.config.providers.Lang;
import net.gravitydevelopment.anticheat.config.providers.Magic; import com.rammelkast.anticheatreloaded.config.providers.Magic;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import net.gravitydevelopment.anticheat.util.User; import com.rammelkast.anticheatreloaded.util.User;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class Backend { public class Backend {
private List<UUID> isAscending = new ArrayList<UUID>(); private List<UUID> isAscending = new ArrayList<UUID>();
@@ -170,13 +169,17 @@ public class Backend {
inventoryTime.remove(pU); inventoryTime.remove(pU);
inventoryClicks.remove(pU); inventoryClicks.remove(pU);
lastFallPacket.remove(pU); lastFallPacket.remove(pU);
GlideCheck.lastToFall.remove(pU); GlideCheck.lastDiff.remove(pU);
GlideCheck.glideBuffer.remove(pU); GlideCheck.lastFallDistance.remove(pU);
GlideCheck.violations.remove(pU);
SpeedCheck.speedViolation.remove(player.getUniqueId()); SpeedCheck.speedViolation.remove(player.getUniqueId());
} }
public CheckResult checkFastBow(Player player, float force) { public CheckResult checkFastBow(Player player, float force) {
// Ignore magic numbers here, they are minecrafty vanilla stuff. // Ignore magic numbers here, they are minecrafty vanilla stuff.
if (!bowWindUp.containsKey(player.getUniqueId())) {
return PASS;
}
int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3); int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3);
bowWindUp.remove(player.getUniqueId()); bowWindUp.remove(player.getUniqueId());
float f = (float) ticks / 20.0F; float f = (float) ticks / 20.0F;
@@ -258,7 +261,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)) { 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)) {
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;
@@ -291,7 +294,7 @@ public class Backend {
} }
public CheckResult checkSneak(Player player, double x, double z) { public CheckResult checkSneak(Player player, double x, double z) {
if (player.isSneaking() && !player.isFlying() && !isMovingExempt(player) && !player.isInsideVehicle()) { if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle()) {
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1; double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
if (i != -1) { if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); return new CheckResult(CheckResult.Result.FAILED, player.getName() + " was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
@@ -513,14 +516,14 @@ public class Backend {
fastPlaceViolation.put(uuid, 0); fastPlaceViolation.put(uuid, 0);
} }
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) { } else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
AntiCheat.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid)); AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid));
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid); Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
AntiCheat.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math); AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) { if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
lastBlockPlaced.put(uuid, time); lastBlockPlaced.put(uuid, time);
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")"); return new CheckResult(CheckResult.Result.FAILED, player.getName() + " placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) { } else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
AntiCheat.debugLog("Reset facePlaceViolation for " + uuid); AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid);
fastPlaceViolation.put(uuid, 0); fastPlaceViolation.put(uuid, 0);
} }
} else if (lastBlockPlaced.containsKey(uuid)) { } else if (lastBlockPlaced.containsKey(uuid)) {
@@ -649,10 +652,11 @@ public class Backend {
public CheckResult checkFastHeal(Player player) { public CheckResult checkFastHeal(Player player) {
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{ {
long healTime = VersionUtil.getHealTime();
long l = lastHeal.get(player.getUniqueId()); long l = lastHeal.get(player.getUniqueId());
lastHeal.remove(player.getUniqueId()); lastHeal.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < magic.HEAL_TIME_MIN()) { if ((System.currentTimeMillis() - l) < healTime) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.HEAL_TIME_MIN() + " ms)"); return new CheckResult(CheckResult.Result.FAILED, player.getName() + " healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)");
} }
} }
return PASS; return PASS;
@@ -773,8 +777,9 @@ public class Backend {
YAxisCheck.yAxisLastViolation.remove(player.getUniqueId()); YAxisCheck.yAxisLastViolation.remove(player.getUniqueId());
YAxisCheck.lastYcoord.remove(player.getUniqueId()); YAxisCheck.lastYcoord.remove(player.getUniqueId());
YAxisCheck.lastYtime.remove(player.getUniqueId()); YAxisCheck.lastYtime.remove(player.getUniqueId());
GlideCheck.lastToFall.remove(player.getUniqueId()); GlideCheck.lastFallDistance.remove(player.getUniqueId());
GlideCheck.glideBuffer.remove(player.getUniqueId()); GlideCheck.lastDiff.remove(player.getUniqueId());
GlideCheck.violations.remove(player.getUniqueId());
} }
public void logExitFly(final Player player) { public void logExitFly(final Player player) {
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.check; package com.rammelkast.anticheatreloaded.check;
public class CheckResult { public class CheckResult {
@@ -16,14 +16,15 @@
* 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 net.gravitydevelopment.anticheat.check; package com.rammelkast.anticheatreloaded.check;
import net.gravitydevelopment.anticheat.api.CheckFailEvent;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -6,10 +6,10 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
public class CriticalsCheck { public class CriticalsCheck {
@@ -1,10 +1,9 @@
package net.gravitydevelopment.anticheat.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
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.Location;
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;
@@ -13,20 +12,19 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.event.EventListener;
import net.gravitydevelopment.anticheat.event.EventListener; import com.rammelkast.anticheatreloaded.util.NPC_1_12;
import net.gravitydevelopment.anticheat.util.NPC_1_11; import com.rammelkast.anticheatreloaded.util.VersionUtil;
import net.gravitydevelopment.anticheat.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast
*/ */
public class KillAuraCheck { public class KillAuraCheck {
private static final Map<UUID, NPC_1_11> NPC_LIST = new HashMap<UUID, NPC_1_11>(); 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) {
@@ -40,7 +38,7 @@ public class KillAuraCheck {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { if (!VersionUtil.getVersion().equals("v1_11_R1")) {
return; return;
} }
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.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();
@@ -58,7 +56,8 @@ public class KillAuraCheck {
}else { }else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1); VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) >= 5) { if (VL_COUNT.get(p.getUniqueId()) >= 5) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.BLINK); EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.KILLAURA);
AntiCheatReloaded.getPlugin().onKillAuraViolation();
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
} }
@@ -73,7 +72,7 @@ public class KillAuraCheck {
if (NPC_LIST.containsKey(p.getUniqueId())) if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p); NPC_LIST.get(p.getUniqueId()).damage(e, p);
else { else {
NPC_1_11 npc = new NPC_1_11(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();
} }
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -9,10 +9,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
public class VelocityCheck { public class VelocityCheck {
@@ -23,7 +23,7 @@ public class VelocityCheck {
} }
public static void runCheck(EntityDamageByEntityEvent e, final Player p) { public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.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,8 +36,8 @@ 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()) > AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT()) { if (VL_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_AMT()) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Velocity, had zero/low velocity " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT() + ")").getMessage(), p, CheckType.VELOCITY); 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());
} }
} }
@@ -45,7 +45,7 @@ public class VelocityCheck {
VL_COUNT.remove(p.getUniqueId()); VL_COUNT.remove(p.getUniqueId());
} }
} }
}.runTaskLater(AntiCheat.getPlugin(), 4); }.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
} }
} }
@@ -1,10 +1,9 @@
package net.gravitydevelopment.anticheat.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;
@@ -13,11 +12,10 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.event.EventListener;
import net.gravitydevelopment.anticheat.event.EventListener;
/** /**
* @author Rammelkast * @author Rammelkast
@@ -32,22 +30,22 @@ public class BlinkCheck {
public void run() { public void run() {
MOVE_COUNT.clear(); MOVE_COUNT.clear();
} }
}.runTaskTimer(AntiCheat.getPlugin(), 0, 20); }.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
} }
public static void listenPackets() { public static void listenPackets() {
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) { AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
Location cur = e.getPlayer().getLocation(); Location cur = e.getPlayer().getLocation();
if (!MOVE_COUNT.containsKey(p.getUniqueId())) if (!MOVE_COUNT.containsKey(p.getUniqueId())) {
MOVE_COUNT.put(p.getUniqueId(), 1); MOVE_COUNT.put(p.getUniqueId(), 1);
else { } else {
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1); MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
if (AntiCheat.getManager().getCheckManager().checkInWorld(p) && !AntiCheat.getManager().getCheckManager().isOpExempt(p) && !AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) { if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p) && !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p) && !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET()) { if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET()) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId()) + " packets in one second (max=" + AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.BLINK); 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);
MOVE_COUNT.remove(p.getUniqueId()); MOVE_COUNT.remove(p.getUniqueId());
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().teleport(cur); e.getPlayer().teleport(cur);
@@ -0,0 +1,19 @@
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,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -8,15 +8,15 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* * @author Rammelkast
* @author Marco TODO rewrite this check * TODO rewrite this check
*/ */
public class FlightCheck { public class FlightCheck {
@@ -26,9 +26,9 @@ public class FlightCheck {
public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>(); public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>();
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN() if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) { || VersionUtil.isFlying(player)) {
// This was a teleport or user is flying/elyta'ing, so we don't care // This was a teleport or user is flying/using elytra, so we don't care
// about it. // about it.
return PASS; return PASS;
} }
@@ -51,11 +51,11 @@ public class FlightCheck {
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference())); blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference()));
} }
if (blocksOverFlight.get(uuid) > AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() if (blocksOverFlight.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT()
&& (y1 <= y2)) { && (y1 <= y2)) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max=" player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max="
+ AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")"); + AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
} }
} else { } else {
blocksOverFlight.put(uuid, 0D); blocksOverFlight.put(uuid, 0D);
@@ -0,0 +1,74 @@
package com.rammelkast.anticheatreloaded.check.movement;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class GlideCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastDiff = new HashMap<UUID, Double>();
public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>();
public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>();
public static CheckResult runCheck(Player player, Distance distance) {
if (VersionUtil.isFlying(player)) {
return PASS;
}
if (!lastDiff.containsKey(player.getUniqueId())) {
lastDiff.put(player.getUniqueId(), distance.getYDifference());
return PASS;
}
if (!lastFallDistance.containsKey(player.getUniqueId())) {
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
double yDiff = distance.getYDifference();
float fallDistance = player.getFallDistance();
if (yDiff == lastDiff.get(player.getUniqueId()) && fallDistance > lastFallDistance.get(player.getUniqueId())) {
if (!violations.containsKey(player.getUniqueId())) {
violations.put(player.getUniqueId(), 1);
} else {
if (violations.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
violations.remove(player.getUniqueId());
Location to = player.getLocation();
to.setY(to.getY() - distanceToFall(to));
player.teleport(to);
// Report glide violation to statistics, just for the lulz jk
AntiCheatReloaded.getPlugin().onGlideViolation();
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " was set back for gliding (yDiff=" + new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")");
} else {
violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1);
}
}
}
lastDiff.put(player.getUniqueId(), distance.getYDifference());
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
private static double distanceToFall(Location location) {
location = location.clone();
double firstY = location.getY();
while (location.clone().add(0, -0.1, 0).getBlock().getType() == Material.AIR)
location.add(0, -0.1, 0);
return firstY - location.getY();
}
}
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -8,9 +8,9 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class SpeedCheck { public class SpeedCheck {
@@ -18,51 +18,51 @@ public class SpeedCheck {
public static Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>(); public static Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>();
public static boolean isSpeedExempt(Player player) { public static boolean isSpeedExempt(Player player) {
return AntiCheat.getManager().getBackend().isMovingExempt(player) return AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|| AntiCheat.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player); || AntiCheatReloaded.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
} }
public static CheckResult checkXZSpeed(Player player, double x, double z) { public static CheckResult checkXZSpeed(Player player, double x, double z) {
if (!isSpeedExempt(player) && player.getVehicle() == null) { if (!isSpeedExempt(player) && player.getVehicle() == null) {
String reason = ""; String reason = "";
double max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX(); double max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX();
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) { if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
if (player.isSprinting()) { if (player.isSprinting()) {
reason = "on soulsand while sprinting "; reason = "on soulsand while sprinting ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) { } else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
reason = "on soulsand with speed potion "; reason = "on soulsand with speed potion ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
} else { } else {
reason = "on soulsand "; reason = "on soulsand ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND();
} }
} else if (VersionUtil.isFlying(player)) { } else if (VersionUtil.isFlying(player)) {
reason = "while flying "; reason = "while flying ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY();
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) { } else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
if (player.isSprinting()) { if (player.isSprinting()) {
reason = "with speed potion while sprinting "; reason = "with speed potion while sprinting ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT();
} else { } else {
reason = "with speed potion "; reason = "with speed potion ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
} }
} else if (player.isSprinting()) { } else if (player.isSprinting()) {
reason = "while sprinting "; reason = "while sprinting ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT(); max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
} }
float speed = player.getWalkSpeed(); float speed = player.getWalkSpeed();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0; max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if (x > max || z > max) { if (x > max || z > max) {
int num = AntiCheat.getManager().getBackend().increment(player, speedViolation, int num = AntiCheatReloaded.getManager().getBackend().increment(player, speedViolation,
AntiCheat.getManager().getBackend().getMagic().SPEED_MAX()); AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX());
if (num >= AntiCheat.getManager().getBackend().getMagic().SPEED_MAX()) { if (num >= AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX()) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
player.getName() + "'s speed was too high " + reason + num + " times in a row (max=" player.getName() + "'s speed was too high " + reason + num + " times in a row (max="
+ AntiCheat.getManager().getBackend().getMagic().SPEED_MAX() + ", speed=" + AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX() + ", speed="
+ (x > z ? x : z) + ", max speed=" + max + ")"); + (x > z ? x : z) + ", max speed=" + max + ")");
} else { } else {
return PASS; return PASS;
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -11,9 +11,10 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* This check seems to be broken/outdated * This check seems to be broken/outdated
@@ -31,18 +32,18 @@ public class WaterWalkCheck {
Block block = player.getLocation().getBlock(); Block block = player.getLocation().getBlock();
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (player.getVehicle() == null && !player.isFlying()) { if (player.getVehicle() == null && !player.isFlying() && !VersionUtil.isFrostWalk(player)) {
if (block.isLiquid()) { if (block.isLiquid()) {
if (isInWater.contains(uuid)) { if (isInWater.contains(uuid)) {
if (isInWaterCache.contains(uuid)) { if (isInWaterCache.contains(uuid)) {
if (player.getNearbyEntities(1, 1, 1).isEmpty()) { if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
boolean b; boolean b;
if (!Utilities.sprintFly(player)) { if (!Utilities.sprintFly(player)) {
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER() b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER()
|| z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER(); || z > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
} else { } else {
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT() b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|| z > AntiCheat.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())
@@ -53,7 +54,7 @@ public class WaterWalkCheck {
if (b) { if (b) {
if (waterSpeedViolation.containsKey(uuid)) { if (waterSpeedViolation.containsKey(uuid)) {
int v = waterSpeedViolation.get(uuid); int v = waterSpeedViolation.get(uuid);
if (v >= AntiCheat.getManager().getBackend().getMagic() if (v >= AntiCheatReloaded.getManager().getBackend().getMagic()
.WATER_SPEED_VIOLATION_MAX()) { .WATER_SPEED_VIOLATION_MAX()) {
waterSpeedViolation.put(uuid, 0); waterSpeedViolation.put(uuid, 0);
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
@@ -77,11 +78,11 @@ public class WaterWalkCheck {
return PASS; return PASS;
} }
} else if (block.getRelative(BlockFace.DOWN).isLiquid() } else if (block.getRelative(BlockFace.DOWN).isLiquid()
&& !AntiCheat.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block) && !AntiCheatReloaded.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block)
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) { && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
if (waterAscensionViolation.containsKey(uuid)) { if (waterAscensionViolation.containsKey(uuid)) {
int v = waterAscensionViolation.get(uuid); int v = waterAscensionViolation.get(uuid);
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) { if (v >= AntiCheatReloaded.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
waterAscensionViolation.put(uuid, 0); waterAscensionViolation.put(uuid, 0);
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() player.getName() + " stood on water " + v + " times (can't stand on " + block.getType()
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
@@ -12,11 +12,11 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class YAxisCheck { public class YAxisCheck {
@@ -32,7 +32,7 @@ public class YAxisCheck {
} }
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN() if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| distance.getYDifference() < 0 || VersionUtil.isFlying(player)) { || distance.getYDifference() < 0 || VersionUtil.isFlying(player)) {
return PASS; return PASS;
} }
@@ -52,13 +52,13 @@ 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) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() && yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheat.getManager() && (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) { .getBackend().getMagic().Y_MAXVIOTIME()) {
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());
if (!AntiCheat.getManager().getBackend().silentMode()) { if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid)); g.setY(lastYcoord.get(uuid));
if (g.getBlock().getType() == Material.AIR) { if (g.getBlock().getType() == Material.AIR) {
player.teleport(g); player.teleport(g);
@@ -66,33 +66,33 @@ public class YAxisCheck {
} }
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
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 ="
+ AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")"); + AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
} else { } else {
if (yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() if (yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheat.getManager() && (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) { .getBackend().getMagic().Y_MAXVIOTIME()) {
yAxisViolations.put(uuid, 0); yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L); yAxisLastViolation.put(uuid, 0L);
} }
} }
long i = System.currentTimeMillis() - lastYtime.get(uuid); long i = System.currentTimeMillis() - lastYtime.get(uuid);
double diff = AntiCheat.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 < AntiCheat.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());
if (!AntiCheat.getManager().getBackend().silentMode()) { if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid)); g.setY(lastYcoord.get(uuid));
if (g.getBlock().getType() == Material.AIR) { if (g.getBlock().getType() == Material.AIR) {
player.teleport(g); player.teleport(g);
} }
} }
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 =" + AntiCheat.getManager().getBackend().getMagic().Y_TIME() + ")"); + i + " ms (min =" + AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME() + ")");
} else { } else {
if ((y1 - lastYcoord.get(uuid)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + 1 if ((y1 - lastYcoord.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF() + 1
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheat.getManager().getBackend() || (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheatReloaded.getManager().getBackend()
.getMagic().Y_TIME()) { .getMagic().Y_TIME()) {
lastYtime.put(uuid, System.currentTimeMillis()); lastYtime.put(uuid, System.currentTimeMillis());
lastYcoord.put(uuid, y1); lastYcoord.put(uuid, y1);
@@ -0,0 +1,17 @@
package com.rammelkast.anticheatreloaded.check.player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author Rammelkast
*
*/
public class GhosthandCheck {
public static final Map<UUID, Integer> FLAG_COUNT = new HashMap<UUID, Integer>();
public static final int MAX_FLAGS = 3; // TODO config?
}
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.command; package com.rammelkast.anticheatreloaded.command;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -24,17 +24,17 @@ import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import net.gravitydevelopment.anticheat.manage.CheckManager; import com.rammelkast.anticheatreloaded.manage.CheckManager;
import net.gravitydevelopment.anticheat.manage.UserManager; import com.rammelkast.anticheatreloaded.manage.UserManager;
import net.gravitydevelopment.anticheat.util.Permission; import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandBase { public class CommandBase {
public static final Configuration CONFIG = AntiCheat.getManager().getConfiguration(); public static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
public static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager(); public static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
public static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager(); public static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
public static final ChatColor RED = ChatColor.RED; public static final ChatColor RED = ChatColor.RED;
public static final ChatColor YELLOW = ChatColor.YELLOW; public static final ChatColor YELLOW = ChatColor.YELLOW;
public static final ChatColor GREEN = ChatColor.GREEN; public static final ChatColor GREEN = ChatColor.GREEN;
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.command; package com.rammelkast.anticheatreloaded.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -25,14 +25,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import net.gravitydevelopment.anticheat.command.executors.CommandCheck; import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
import net.gravitydevelopment.anticheat.command.executors.CommandDebug; import com.rammelkast.anticheatreloaded.command.executors.CommandDebug;
import net.gravitydevelopment.anticheat.command.executors.CommandDeveloper; import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
import net.gravitydevelopment.anticheat.command.executors.CommandHelp; import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
import net.gravitydevelopment.anticheat.command.executors.CommandLog; import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
import net.gravitydevelopment.anticheat.command.executors.CommandReload; import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
import net.gravitydevelopment.anticheat.command.executors.CommandReport; import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
import net.gravitydevelopment.anticheat.command.executors.CommandReset; import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
public class CommandHandler implements CommandExecutor { public class CommandHandler implements CommandExecutor {
@@ -16,13 +16,14 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
import java.util.List; import java.util.List;
public class CommandCheck extends CommandBase { public class CommandCheck extends CommandBase {
@@ -16,15 +16,16 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.PastebinReport;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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 { public class CommandDebug extends CommandBase {
private static final String NAME = "AntiCheat Debug Reporting"; private static final String NAME = "AntiCheat Debug Reporting";
@@ -16,13 +16,14 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandDeveloper extends CommandBase { public class CommandDeveloper extends CommandBase {
private static final String NAME = "AntiCheat Developer Mode"; private static final String NAME = "AntiCheat Developer Mode";
@@ -39,7 +40,7 @@ public class CommandDeveloper extends CommandBase {
@Override @Override
protected void execute(CommandSender cs, String[] args) { protected void execute(CommandSender cs, String[] args) {
AntiCheat.setDeveloperMode(!AntiCheat.developerMode()); AntiCheatReloaded.setDeveloperMode(!AntiCheatReloaded.developerMode());
cs.sendMessage(GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF")); cs.sendMessage(GREEN + "Developer mode " + (AntiCheatReloaded.developerMode() ? "ON" : "OFF"));
} }
} }
@@ -16,12 +16,13 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandHelp extends CommandBase { public class CommandHelp extends CommandBase {
private static final String NAME = "AntiCheatReloaded Help"; private static final String NAME = "AntiCheatReloaded Help";
@@ -16,13 +16,14 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandLog extends CommandBase { public class CommandLog extends CommandBase {
private static final String NAME = "AntiCheat Logging"; private static final String NAME = "AntiCheat Logging";
@@ -16,12 +16,13 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandReload extends CommandBase { public class CommandReload extends CommandBase {
private static final String NAME = "AntiCheat Reload"; private static final String NAME = "AntiCheat Reload";
@@ -16,18 +16,19 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.manage.CheckManager;
import net.gravitydevelopment.anticheat.util.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.util.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -82,7 +83,7 @@ public class CommandReport extends CommandBase {
// Test users // Test users
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) { if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) {
User user = AntiCheat.getManager().getUserManager().getUser(player.getUniqueId()); User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
playerReport(cs, user, page); playerReport(cs, user, page);
return; return;
} }
@@ -175,13 +176,13 @@ public class CommandReport extends CommandBase {
} }
} }
if (AntiCheat.developerMode()) { if (AntiCheatReloaded.developerMode()) {
int permission = 0; int permission = 0;
int check = 0; int check = 0;
for (Permission perm : Permission.values()) { for (Permission perm : Permission.values()) {
if (perm.get(user.getPlayer())) permission++; if (perm.get(user.getPlayer())) permission++;
} }
CheckManager manager = AntiCheat.getManager().getCheckManager(); CheckManager manager = AntiCheatReloaded.getManager().getCheckManager();
for (CheckType type : CheckType.values()) { for (CheckType type : CheckType.values()) {
if (manager.willCheck(user.getPlayer(), type)) check++; if (manager.willCheck(user.getPlayer(), type)) check++;
} }
@@ -16,17 +16,17 @@
* 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 net.gravitydevelopment.anticheat.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import net.gravitydevelopment.anticheat.util.User;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
public class CommandReset extends CommandBase { public class CommandReset extends CommandBase {
private static final String NAME = "AntiCheat Resetting"; private static final String NAME = "AntiCheat Resetting";
@@ -53,7 +53,7 @@ public class CommandReset extends CommandBase {
if (user != null) { if (user != null) {
user.resetLevel(); user.resetLevel();
user.clearMessages(); user.clearMessages();
AntiCheat.getManager().getBackend().resetChatLevel(user); AntiCheatReloaded.getManager().getBackend().resetChatLevel(user);
cs.sendMessage(args[0] + GREEN + " has been reset."); cs.sendMessage(args[0] + GREEN + " has been reset.");
} else { } else {
cs.sendMessage(RED + "Player: " +args[0] + " not found."); cs.sendMessage(RED + "Player: " +args[0] + " not found.");
@@ -16,17 +16,18 @@
* 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 net.gravitydevelopment.anticheat.config; package com.rammelkast.anticheatreloaded.config;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.files.Config;
import net.gravitydevelopment.anticheat.config.files.Enterprise;
import net.gravitydevelopment.anticheat.config.holders.mysql.*;
import net.gravitydevelopment.anticheat.config.holders.yaml.*;
import net.gravitydevelopment.anticheat.config.providers.*;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.files.Config;
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
import com.rammelkast.anticheatreloaded.config.holders.mysql.*;
import com.rammelkast.anticheatreloaded.config.holders.yaml.*;
import com.rammelkast.anticheatreloaded.config.providers.*;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
@@ -47,7 +48,7 @@ public class Configuration {
private ArrayList<ConfigurationFile> flatfiles; private ArrayList<ConfigurationFile> flatfiles;
private ArrayList<ConfigurationTable> dbfiles; private ArrayList<ConfigurationTable> dbfiles;
public Configuration(AntiCheat plugin, AntiCheatManager manager) { public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
removeOldFiles(); removeOldFiles();
this.manager = manager; this.manager = manager;
config = new Config(plugin, this); config = new Config(plugin, this);
@@ -145,20 +146,20 @@ public class Configuration {
private void removeOldFiles() { private void removeOldFiles() {
ArrayList<String> removed = new ArrayList<String>(); ArrayList<String> removed = new ArrayList<String>();
File configFile = new File(AntiCheat.getPlugin().getDataFolder(), "config.yml"); File configFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.yml");
if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) { if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
configFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "config.old")); configFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.old"));
removed.add("config.yml has been renamed to config.old and replaced with the new config.yml"); removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
} }
File eventsFile = new File(AntiCheat.getPlugin().getDataFolder(), "events.yml"); File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
if (eventsFile.exists()) { if (eventsFile.exists()) {
eventsFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "events.old")); eventsFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.old"));
removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml"); removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
} }
if (removed.size() > 0) { if (removed.size() > 0) {
AntiCheat.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:"); AntiCheatReloaded.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
for (String s : removed) { for (String s : removed) {
AntiCheat.getPlugin().getLogger().info(s); AntiCheatReloaded.getPlugin().getLogger().info(s);
} }
} }
} }
@@ -16,15 +16,17 @@
* 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 net.gravitydevelopment.anticheat.config; package com.rammelkast.anticheatreloaded.config;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.yaml.CommentedConfiguration;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
public class ConfigurationFile { public class ConfigurationFile {
@@ -35,21 +37,21 @@ public class ConfigurationFile {
private FileConfiguration defaultConfigFile; private FileConfiguration defaultConfigFile;
private Configuration config; private Configuration config;
private AntiCheat plugin; private AntiCheatReloaded plugin;
private boolean saveDefault; private boolean saveDefault;
protected boolean needsReload; protected boolean needsReload;
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName) { public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
this(plugin, config, fileName, true); this(plugin, config, fileName, true);
} }
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault) { public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault) {
this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName)); this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
} }
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) { public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
// Can't change with user editing // Can't change with user editing
this.plugin = plugin; this.plugin = plugin;
this.config = config; this.config = config;
@@ -58,7 +60,13 @@ public class ConfigurationFile {
this.saveDefault = saveDefault; this.saveDefault = saveDefault;
if (saveDefault) { if (saveDefault) {
defaultConfigFile = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); InputStreamReader reader = new InputStreamReader(plugin.getResource(fileName));
defaultConfigFile = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
load(); load();
} }
@@ -16,12 +16,13 @@
* 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 net.gravitydevelopment.anticheat.config; package com.rammelkast.anticheatreloaded.config;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.util.enterprise.Database;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -58,7 +59,7 @@ public class ConfigurationTable {
public void reload() { public void reload() {
// For after sql inserts have been made // For after sql inserts have been made
Bukkit.getScheduler().runTask(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
load(); load();
@@ -16,14 +16,14 @@
* 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 net.gravitydevelopment.anticheat.config.files; package com.rammelkast.anticheatreloaded.config.files;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class Config extends ConfigurationFile { public class Config extends ConfigurationFile {
public static final String FILENAME = "config.yml"; public static final String FILENAME = "config.yml";
@@ -51,7 +51,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds; public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<List<String>> disabledChecks; public ConfigValue<List<String>> disabledChecks;
public Config(AntiCheat plugin, Configuration config) { public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -16,12 +16,12 @@
* 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 net.gravitydevelopment.anticheat.config.files; package com.rammelkast.anticheatreloaded.config.files;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import net.gravitydevelopment.anticheat.util.enterprise.Database; import com.rammelkast.anticheatreloaded.util.enterprise.Database;
public class Enterprise extends ConfigurationFile { public class Enterprise extends ConfigurationFile {
@@ -43,7 +43,7 @@ public class Enterprise extends ConfigurationFile {
public Database database; public Database database;
public Enterprise(AntiCheat plugin, Configuration config) { public Enterprise(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -16,12 +16,7 @@
* 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 net.gravitydevelopment.anticheat.config.holders.mysql; package com.rammelkast.anticheatreloaded.config.holders.mysql;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Groups;
import net.gravitydevelopment.anticheat.util.Group;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@@ -29,6 +24,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Groups;
import com.rammelkast.anticheatreloaded.util.Group;
public class MySQLGroupsHolder extends ConfigurationTable implements Groups { public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
private static final String TABLE = "groups"; private static final String TABLE = "groups";
@@ -16,15 +16,18 @@
* 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 net.gravitydevelopment.anticheat.config.holders.mysql; package com.rammelkast.anticheatreloaded.config.holders.mysql;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Lang;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -49,7 +52,13 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
@Override @Override
public void open() { public void open() {
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("lang.yml")); InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("lang.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
stringValues = new HashMap<String, String>(); stringValues = new HashMap<String, String>();
listValues = new HashMap<String, List<String>>(); listValues = new HashMap<String, List<String>>();
@@ -141,7 +150,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
return value; return value;
} }
} }
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found."); AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
return "Language error. See console for details."; return "Language error. See console for details.";
} }
@@ -16,15 +16,16 @@
* 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 net.gravitydevelopment.anticheat.config.holders.mysql; package com.rammelkast.anticheatreloaded.config.holders.mysql;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Levels;
import net.gravitydevelopment.anticheat.util.User;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
import com.rammelkast.anticheatreloaded.util.User;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@@ -80,11 +81,11 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override @Override
public void saveLevelFromUser(final User user) { public void saveLevelFromUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (!user.isWaitingOnLevelSync()) { if (!user.isWaitingOnLevelSync()) {
AntiCheat.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel()); AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
try { try {
PreparedStatement statement = getConnection().prepareStatement(sqlSave); PreparedStatement statement = getConnection().prepareStatement(sqlSave);
statement.setString(1, user.getUUID().toString()); statement.setString(1, user.getUUID().toString());
@@ -100,14 +101,14 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
e.printStackTrace(); e.printStackTrace();
} }
} }
AntiCheat.getManager().getUserManager().remove(user); AntiCheatReloaded.getManager().getUserManager().remove(user);
} }
}); });
} }
@Override @Override
public void loadLevelToUser(final User user) { public void loadLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@@ -119,7 +120,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
boolean has = false; boolean has = false;
while (set.next()) { while (set.next()) {
has = true; has = true;
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level")); AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
user.setLevel(set.getInt("level")); user.setLevel(set.getInt("level"));
user.setLevelSyncTimestamp(set.getTimestamp("last_update")); user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
} }
@@ -161,7 +162,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override @Override
public void updateLevelToUser(final User user) { public void updateLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@@ -173,7 +174,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
ResultSet set = statement.executeQuery(); ResultSet set = statement.executeQuery();
while (set.next()) { while (set.next()) {
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level")); AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
user.setLevel(set.getInt("level")); user.setLevel(set.getInt("level"));
user.setLevelSyncTimestamp(set.getTimestamp("last_update")); user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
} }
@@ -16,15 +16,18 @@
* 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 net.gravitydevelopment.anticheat.config.holders.mysql; package com.rammelkast.anticheatreloaded.config.holders.mysql;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -46,7 +49,13 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
@Override @Override
public void open() { public void open() {
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("magic.yml")); InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("magic.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
ints = new HashMap<String, Integer>(); ints = new HashMap<String, Integer>();
doubles = new HashMap<String, Double>(); doubles = new HashMap<String, Double>();
@@ -93,7 +102,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
} else if (set.getObject("value_double") != null) { } else if (set.getObject("value_double") != null) {
doubles.put(key, set.getDouble("value_double")); doubles.put(key, set.getDouble("value_double"));
} else { } else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value."); AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
for (int i=1;i<=methods.length;i++) { for (int i=1;i<=methods.length;i++) {
String name = methods[i-1].getName(); String name = methods[i-1].getName();
if (name.equalsIgnoreCase(key)) { if (name.equalsIgnoreCase(key)) {
@@ -140,7 +149,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
return value; return value;
} }
} }
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found."); AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return 0; return 0;
} }
} }
@@ -16,19 +16,19 @@
* 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 net.gravitydevelopment.anticheat.config.holders.mysql; package com.rammelkast.anticheatreloaded.config.holders.mysql;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Rules;
import net.gravitydevelopment.anticheat.util.rule.Rule;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public class MySQLRulesHolder extends ConfigurationTable implements Rules { public class MySQLRulesHolder extends ConfigurationTable implements Rules {
private static final String TABLE = "rules"; private static final String TABLE = "rules";
@@ -65,7 +65,7 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
if (rule != null) { if (rule != null) {
this.rules.add(rule); this.rules.add(rule);
} else { } else {
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used."); AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@@ -16,16 +16,16 @@
* 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 net.gravitydevelopment.anticheat.config.holders.yaml; package com.rammelkast.anticheatreloaded.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import net.gravitydevelopment.anticheat.config.providers.Groups;
import net.gravitydevelopment.anticheat.util.Group;
import java.util.*; import java.util.*;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Groups;
import com.rammelkast.anticheatreloaded.util.Group;
public class YamlGroupsHolder extends ConfigurationFile implements Groups { public class YamlGroupsHolder extends ConfigurationFile implements Groups {
public static final String FILENAME = "groups.yml"; public static final String FILENAME = "groups.yml";
@@ -34,7 +34,7 @@ public class YamlGroupsHolder extends ConfigurationFile implements Groups {
private int highestLevel; private int highestLevel;
public YamlGroupsHolder(AntiCheat plugin, Configuration config) { public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -16,21 +16,21 @@
* 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 net.gravitydevelopment.anticheat.config.holders.yaml; package com.rammelkast.anticheatreloaded.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class YamlLangHolder extends ConfigurationFile implements InvocationHandler { public class YamlLangHolder extends ConfigurationFile implements InvocationHandler {
public static final String FILENAME = "lang.yml"; public static final String FILENAME = "lang.yml";
public YamlLangHolder(AntiCheat plugin, Configuration config) { public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -76,7 +76,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
return value.getValue(); return value.getValue();
} }
} }
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found."); AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
return "Language error. See console for details."; return "Language error. See console for details.";
} }
} }
@@ -16,22 +16,22 @@
* 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 net.gravitydevelopment.anticheat.config.holders.yaml; package com.rammelkast.anticheatreloaded.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import net.gravitydevelopment.anticheat.config.providers.Levels;
import net.gravitydevelopment.anticheat.util.User;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
import com.rammelkast.anticheatreloaded.util.User;
public class YamlLevelsHolder extends ConfigurationFile implements Levels { public class YamlLevelsHolder extends ConfigurationFile implements Levels {
public static final String FILENAME = "data/levels.yml"; public static final String FILENAME = "data/levels.yml";
public YamlLevelsHolder(AntiCheat plugin, Configuration config) { public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME, false); super(plugin, config, FILENAME, false);
} }
@@ -47,7 +47,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
private void saveLevelFromUser(User user, boolean remove) { private void saveLevelFromUser(User user, boolean remove) {
saveLevel(user.getUUID(), user.getLevel()); saveLevel(user.getUUID(), user.getLevel());
if (remove) AntiCheat.getManager().getUserManager().remove(user); if (remove) AntiCheatReloaded.getManager().getUserManager().remove(user);
} }
@Override @Override
@@ -16,20 +16,20 @@
* 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 net.gravitydevelopment.anticheat.config.holders.yaml; package com.rammelkast.anticheatreloaded.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler { public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
public static final String FILENAME = "magic.yml"; public static final String FILENAME = "magic.yml";
public YamlMagicHolder(AntiCheat plugin, Configuration config) { public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -41,7 +41,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
} else if (method.getReturnType().getSimpleName().equals("double")) { } else if (method.getReturnType().getSimpleName().equals("double")) {
return new ConfigValue<Double>(key).getValue(); return new ConfigValue<Double>(key).getValue();
} else { } else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found."); AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return -1; return -1;
} }
} }
@@ -16,24 +16,24 @@
* 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 net.gravitydevelopment.anticheat.config.holders.yaml; package com.rammelkast.anticheatreloaded.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import net.gravitydevelopment.anticheat.config.providers.Rules;
import net.gravitydevelopment.anticheat.util.rule.Rule;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public class YamlRulesHolder extends ConfigurationFile implements Rules { public class YamlRulesHolder extends ConfigurationFile implements Rules {
public static final String FILENAME = "rules.yml"; public static final String FILENAME = "rules.yml";
private List<Rule> rules; private List<Rule> rules;
public YamlRulesHolder(AntiCheat plugin, Configuration config) { public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -61,7 +61,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
if (rule != null) { if (rule != null) {
this.rules.add(rule); this.rules.add(rule);
} else { } else {
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used."); AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
} }
} }
} }
@@ -16,12 +16,12 @@
* 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 net.gravitydevelopment.anticheat.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import net.gravitydevelopment.anticheat.util.Group;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.util.Group;
public interface Groups { public interface Groups {
/** /**
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List; import java.util.List;
@@ -16,12 +16,12 @@
* 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 net.gravitydevelopment.anticheat.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import net.gravitydevelopment.anticheat.util.User;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.util.User;
public interface Levels { public interface Levels {
/** /**
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
/** /**
* Magic number class. Modifications to values in magic.yml will be accepted here. * Magic number class. Modifications to values in magic.yml will be accepted here.
@@ -161,10 +161,6 @@ public interface Magic {
* Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE. * Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE.
*/ */
public int GLIDE_LIMIT(); public int GLIDE_LIMIT();
/**
* The max fallspeed after which glide check is disabled; Type=DOUBLE
*/
public double GLIDE_MAX();
/** /**
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE. * How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
*/ */
@@ -257,10 +253,6 @@ public interface Magic {
* Minimum time in between block placing; Type=INTEGER, Leniency=DECREASE. * Minimum time in between block placing; Type=INTEGER, Leniency=DECREASE.
*/ */
public double BLOCK_PLACE_MIN(); public double BLOCK_PLACE_MIN();
/**
* Minimum time in between healing; Type=SYSTEM, Leniency=DECREASE.
*/
public int HEAL_TIME_MIN();
/** /**
* Minimum time in between eating; Type=SYSTEM, Leniency=DECREASE. * Minimum time in between eating; Type=SYSTEM, Leniency=DECREASE.
*/ */
@@ -17,12 +17,12 @@
*/ */
package net.gravitydevelopment.anticheat.config.providers; package com.rammelkast.anticheatreloaded.config.providers;
import net.gravitydevelopment.anticheat.util.rule.Rule;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public interface Rules { public interface Rules {
/** /**
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.config.yaml; package com.rammelkast.anticheatreloaded.config.yaml;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -33,6 +33,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -188,7 +189,9 @@ public class CommentedConfiguration extends YamlConfiguration {
CommentedConfiguration config = new CommentedConfiguration(); CommentedConfiguration config = new CommentedConfiguration();
try { try {
config.load(stream); InputStreamReader reader = new InputStreamReader(stream);
config.load(reader);
reader.close();
} catch (IOException ex) { } catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) { } catch (InvalidConfigurationException ex) {
@@ -16,13 +16,8 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -31,6 +26,12 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class BlockListener extends EventListener { public class BlockListener extends EventListener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
@@ -47,7 +48,7 @@ public class BlockListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -64,7 +65,7 @@ public class BlockListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
@@ -28,17 +28,18 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.util.Distance;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.check.combat.CriticalsCheck;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
import net.gravitydevelopment.anticheat.util.Distance;
public class EntityListener extends EventListener { public class EntityListener extends EventListener {
@EventHandler @EventHandler
@@ -56,7 +57,7 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -75,7 +76,7 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -94,7 +95,7 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
@@ -168,6 +169,6 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
} }
@@ -16,17 +16,18 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.Backend;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.manage.*;
import net.gravitydevelopment.anticheat.util.User;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.manage.*;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -35,18 +36,18 @@ import java.util.UUID;
public class EventListener implements Listener { public class EventListener implements Listener {
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class); private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>(); private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager(); private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
private static final Backend BACKEND = AntiCheat.getManager().getBackend(); private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin(); private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager(); private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration(); private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
public static void log(String message, Player player, CheckType type) { public static void log(String message, Player player, CheckType type) {
User user = getUserManager().getUser(player.getUniqueId()); User user = getUserManager().getUser(player.getUniqueId());
if (user != null) { // npc if (user != null) { // npc
logCheat(type, user); logCheat(type, user);
if (user.increaseLevel(type) && message != null) { if (user.increaseLevel(type) && message != null) {
AntiCheat.getManager().log(message); AntiCheatReloaded.getManager().log(message);
} }
removeDecrease(user); removeDecrease(user);
} }
@@ -115,7 +116,7 @@ public class EventListener implements Listener {
} }
public static AntiCheatManager getManager() { public static AntiCheatManager getManager() {
return AntiCheat.getManager(); return AntiCheatReloaded.getManager();
} }
public static Backend getBackend() { public static Backend getBackend() {
@@ -126,7 +127,7 @@ public class EventListener implements Listener {
return USER_MANAGER; return USER_MANAGER;
} }
public static AntiCheat getPlugin() { public static AntiCheatReloaded getPlugin() {
return PLUGIN; return PLUGIN;
} }
@@ -16,12 +16,8 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.check.CheckResult;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@@ -29,6 +25,11 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
public class InventoryListener extends EventListener { public class InventoryListener extends EventListener {
@EventHandler @EventHandler
@@ -50,7 +51,7 @@ public class InventoryListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@@ -51,20 +51,21 @@ import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.ElytraFly;
import net.gravitydevelopment.anticheat.check.movement.GlideCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import net.gravitydevelopment.anticheat.util.Distance; import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
import net.gravitydevelopment.anticheat.util.Permission; import com.rammelkast.anticheatreloaded.util.Distance;
import net.gravitydevelopment.anticheat.util.User; import com.rammelkast.anticheatreloaded.util.Permission;
import net.gravitydevelopment.anticheat.util.Utilities; import com.rammelkast.anticheatreloaded.util.User;
import net.gravitydevelopment.anticheat.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class PlayerListener extends EventListener { public class PlayerListener extends EventListener {
@@ -81,7 +82,7 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -90,7 +91,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -99,7 +100,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -120,7 +121,7 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -129,14 +130,14 @@ public class PlayerListener extends EventListener {
getBackend().logTeleport(event.getPlayer()); getBackend().logTeleport(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) { public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
getBackend().logTeleport(event.getPlayer()); getBackend().logTeleport(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -145,7 +146,7 @@ public class PlayerListener extends EventListener {
getBackend().logToggleSneak(event.getPlayer()); getBackend().logToggleSneak(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -159,7 +160,7 @@ public class PlayerListener extends EventListener {
getBackend().logVelocity(player); getBackend().logVelocity(player);
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -178,14 +179,14 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerKick(PlayerKickEvent event) { public void onPlayerKick(PlayerKickEvent event) {
getBackend().garbageClean(event.getPlayer()); getBackend().garbageClean(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -196,7 +197,7 @@ public class PlayerListener extends EventListener {
getConfig().getLevels().saveLevelFromUser(user); getConfig().getLevels().saveLevelFromUser(user);
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -215,7 +216,7 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -237,7 +238,7 @@ public class PlayerListener extends EventListener {
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference()); getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -251,7 +252,7 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -259,7 +260,7 @@ public class PlayerListener extends EventListener {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType() != Material.BED) return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -267,12 +268,12 @@ public class PlayerListener extends EventListener {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType() != Material.BED) return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerAnimation(PlayerAnimationEvent event) { public void onPlayerAnimation(PlayerAnimationEvent event) {
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -304,7 +305,7 @@ public class PlayerListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@@ -346,6 +347,12 @@ public class PlayerListener extends EventListener {
log(result.getMessage(), player, CheckType.FLY); log(result.getMessage(), player, CheckType.FLY);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY)) {
CheckResult result = ElytraFly.runCheck(player, distance);
if (result.failed()) {
log(result.getMessage(), player, CheckType.FLY);
}
}
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) { if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo())); CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
if (result.failed()) { if (result.failed()) {
@@ -433,7 +440,7 @@ public class PlayerListener extends EventListener {
} }
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(priority=EventPriority.HIGHEST) @EventHandler(priority=EventPriority.HIGHEST)
@@ -16,15 +16,16 @@
* 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 net.gravitydevelopment.anticheat.event; package com.rammelkast.anticheatreloaded.event;
import net.gravitydevelopment.anticheat.AntiCheat;
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;
import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.vehicle.VehicleExitEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class VehicleListener extends EventListener { public class VehicleListener extends EventListener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -33,7 +34,7 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getEntered()); getBackend().logEnterExit((Player) event.getEntered());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -42,7 +43,7 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getExited()); getBackend().logEnterExit((Player) event.getExited());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@@ -52,6 +53,6 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getVehicle().getPassenger()); getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
} }
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.manage; package com.rammelkast.anticheatreloaded.manage;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -25,16 +25,16 @@ import java.util.logging.Logger;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.check.Backend; import com.rammelkast.anticheatreloaded.check.Backend;
import net.gravitydevelopment.anticheat.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
/** /**
* The internal hub for all managers. * The internal hub for all managers.
*/ */
public class AntiCheatManager { public class AntiCheatManager {
private static AntiCheat plugin = null; private static AntiCheatReloaded plugin = null;
private static Configuration configuration; private static Configuration configuration;
private static UserManager userManager = null; private static UserManager userManager = null;
private static CheckManager checkManager = null; private static CheckManager checkManager = null;
@@ -43,7 +43,7 @@ public class AntiCheatManager {
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>(); private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>(); private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
public AntiCheatManager(AntiCheat instance, Logger logger) { public AntiCheatManager(AntiCheatReloaded instance, Logger logger) {
plugin = instance; plugin = instance;
configuration = new Configuration(plugin, this); configuration = new Configuration(plugin, this);
loggingManager = new LoggingManager(plugin, logger, configuration); loggingManager = new LoggingManager(plugin, logger, configuration);
@@ -104,7 +104,7 @@ public class AntiCheatManager {
return gen; return gen;
} }
public AntiCheat getPlugin() { public AntiCheatReloaded getPlugin() {
return plugin; return plugin;
} }
@@ -16,14 +16,15 @@
* 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 net.gravitydevelopment.anticheat.manage; package com.rammelkast.anticheatreloaded.manage;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.config.Configuration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -174,7 +175,7 @@ public class CheckManager {
&& !isExempt(player, type) && !isExempt(player, type)
&& !type.checkPermission(player) && !type.checkPermission(player)
&& !isOpExempt(player); && !isOpExempt(player);
AntiCheat.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName()); AntiCheatReloaded.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
// TODO temp fix // TODO temp fix
if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying()) if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying())
return false; return false;
@@ -16,16 +16,17 @@
* 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 net.gravitydevelopment.anticheat.manage; package com.rammelkast.anticheatreloaded.manage;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.util.FileFormatter;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.FileFormatter;
import com.rammelkast.anticheatreloaded.util.Permission;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@@ -41,7 +42,7 @@ public class LoggingManager {
private static List<String> logs = new CopyOnWriteArrayList<String>(); private static List<String> logs = new CopyOnWriteArrayList<String>();
private final Configuration config; private final Configuration config;
public LoggingManager(AntiCheat 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("net.gravitydevelopment.anticheat.AntiCheat");
this.config = config; this.config = config;
try { try {
@@ -69,12 +70,12 @@ public class LoggingManager {
} }
public void debugLog(String message) { public void debugLog(String message) {
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.GRAY + message); Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.GRAY + message);
logToLogs(message); logToLogs(message);
} }
public void logToConsole(String message) { public void logToConsole(String message) {
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message); Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.RED + message);
} }
public void logToFile(String message) { public void logToFile(String message) {
@@ -1,17 +1,17 @@
package net.gravitydevelopment.anticheat.manage; package com.rammelkast.anticheatreloaded.manage;
import com.comphenix.protocol.Packets; import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.*; import com.comphenix.protocol.events.*;
import net.gravitydevelopment.anticheat.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class PacketManager { public class PacketManager {
private ProtocolManager protocolManager; private ProtocolManager protocolManager;
private AntiCheat plugin; private AntiCheatReloaded plugin;
private AntiCheatManager manager; private AntiCheatManager manager;
public PacketManager(ProtocolManager protocolManager, AntiCheat plugin, AntiCheatManager manager) { public PacketManager(ProtocolManager protocolManager, AntiCheatReloaded plugin, AntiCheatManager manager) {
this.protocolManager = protocolManager; this.protocolManager = protocolManager;
this.plugin = plugin; this.plugin = plugin;
this.manager = manager; this.manager = manager;
@@ -16,21 +16,23 @@
* 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 net.gravitydevelopment.anticheat.manage; package com.rammelkast.anticheatreloaded.manage;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.util.Group;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Utilities;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.BanList.Type;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class UserManager { public class UserManager {
private List<User> users = new ArrayList<User>(); private List<User> users = new ArrayList<User>();
private static AntiCheatManager manager; private static AntiCheatManager manager;
@@ -215,9 +217,12 @@ public class UserManager {
*/ */
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) { public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent // Execute synchronously for thread safety when called from AsyncPlayerChatEvent
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (user.getPlayer() == null) {
return;
}
final String name = user.getName(); final String name = user.getName();
for (String event : actions) { for (String event : actions) {
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name()); event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
@@ -228,6 +233,7 @@ public class UserManager {
} }
} else if (event.equalsIgnoreCase("KICK")) { } else if (event.equalsIgnoreCase("KICK")) {
user.getPlayer().kickPlayer(RED + kickReason); user.getPlayer().kickPlayer(RED + kickReason);
AntiCheatReloaded.getPlugin().onPlayerKicked();
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")"; String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
if (!msg.equals("")) { if (!msg.equals("")) {
manager.log(msg); manager.log(msg);
@@ -241,7 +247,7 @@ public class UserManager {
} }
} }
} else if (event.equalsIgnoreCase("BAN")) { } else if (event.equalsIgnoreCase("BAN")) {
user.getPlayer().setBanned(true); Bukkit.getBanList(Type.NAME).addBan(user.getPlayer().getName(), RED + banReason, null, null);
user.getPlayer().kickPlayer(RED + banReason); user.getPlayer().kickPlayer(RED + banReason);
String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")"; String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
if (!msg.equals("")) { if (!msg.equals("")) {
File diff suppressed because it is too large. Load diff
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Material; import org.bukkit.Material;
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Location; import org.bukkit.Location;
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -16,11 +16,12 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import net.gravitydevelopment.anticheat.AntiCheat;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -40,8 +41,8 @@ public class Group {
ChatColor c = ChatColor.valueOf(color); ChatColor c = ChatColor.valueOf(color);
if (c == null) { if (c == null) {
AntiCheat.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid."); AntiCheatReloaded.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
AntiCheat.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"); 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");
} else { } else {
this.color = c; this.color = c;
} }
@@ -74,9 +75,9 @@ public class Group {
throw new Exception(); throw new Exception();
} }
} catch (Exception ex) { } catch (Exception ex) {
AntiCheat.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'"); AntiCheatReloaded.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheat.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'"); AntiCheatReloaded.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheat.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")"); AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
return null; return null;
} }
} }
@@ -0,0 +1,21 @@
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,35 +1,39 @@
package net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; 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.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 org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.AntiCheat; import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_12_R1.EnumItemSlot;
import net.minecraft.server.v1_11_R1.MinecraftServer; import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_12_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_11_R1.PlayerConnection; import net.minecraft.server.v1_12_R1.PlayerConnection;
import net.minecraft.server.v1_11_R1.PlayerInteractManager; import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_11_R1.World; import net.minecraft.server.v1_12_R1.World;
import net.minecraft.server.v1_11_R1.WorldServer; import net.minecraft.server.v1_12_R1.WorldServer;
public class NPC_1_11 { public class NPC_1_12 {
private final UUID owner; private final UUID owner;
private final String name; private final String name;
@@ -42,7 +46,7 @@ public class NPC_1_11 {
return this.entityId; return this.entityId;
} }
public NPC_1_11(Player owner) { public NPC_1_12(Player owner) {
this.owner = owner.getUniqueId(); this.owner = owner.getUniqueId();
this.name = NameGenerator.generateName(); this.name = NameGenerator.generateName();
Location eyelocation = owner.getEyeLocation(); Location eyelocation = owner.getEyeLocation();
@@ -62,6 +66,8 @@ public class NPC_1_11 {
this.location.getZ(), 0.0f, 0.0f); this.location.getZ(), 0.0f, 0.0f);
this.npc.collides = false; this.npc.collides = false;
this.npc.setInvisible(true); 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(); this.entityId = this.npc.getId();
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection; final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
@@ -89,10 +95,13 @@ public class NPC_1_11 {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true); npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 4); }.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
} }
}else { }else {
Location eyelocation = e.getPlayer().getEyeLocation(); Location eyelocation = e.getPlayer().getEyeLocation();
@@ -137,10 +146,13 @@ public class NPC_1_11 {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true); npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 6); }.runTaskLater(AntiCheatReloaded.getPlugin(), 6);
} }
} }
} }
@@ -159,15 +171,18 @@ public class NPC_1_11 {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true); npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7)); }.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(7));
} }
} }
public void damage() { public void damage() {
if (this.npc == null) { if (this.npc == null || this.getOwner() == null) {
return; return;
} }
if (new Random().nextBoolean() && this.npc.isInvisible()) { if (new Random().nextBoolean() && this.npc.isInvisible()) {
@@ -176,10 +191,13 @@ public class NPC_1_11 {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true); npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(8)); }.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(8));
} }
} }
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -12,7 +12,12 @@ public class NameGenerator {
"NoHax", "NoHax",
"Just", "Just",
"That", "That",
"New" "New",
"Ultra",
"Killer",
"Swift",
"Yolo",
"Rammel"
}); });
private static final List<String> END = Arrays.asList(new String[]{ private static final List<String> END = Arrays.asList(new String[]{
@@ -21,7 +26,10 @@ public class NameGenerator {
"JustYolo", "JustYolo",
"Gaming", "Gaming",
"Minecraft", "Minecraft",
"Games" "Games",
"Bawz",
"kast",
"" + new Random().nextInt(100)
}); });
public static String generateName() { public static String generateName() {
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Random; import java.util.Random;
@@ -16,17 +16,18 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; 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.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@@ -103,7 +104,7 @@ public class PastebinReport {
} }
private void appendLogs() { private void appendLogs() {
List<String> logs = AntiCheat.getManager().getLoggingManager().getLastLogs(); List<String> logs = AntiCheatReloaded.getManager().getLoggingManager().getLastLogs();
if (logs.size() == 0) { if (logs.size() == 0) {
append("No recent logs."); append("No recent logs.");
return; return;
@@ -115,8 +116,8 @@ public class PastebinReport {
private void appendSystemInfo() { private void appendSystemInfo() {
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
Configuration config = AntiCheat.getManager().getConfiguration(); Configuration config = AntiCheatReloaded.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheat.getVersion()); append("AntiCheat Version: " + AntiCheatReloaded.getVersion());
append("Server Version: " + Bukkit.getVersion()); append("Server Version: " + Bukkit.getVersion());
append("Server Implementation: " + Bukkit.getName()); append("Server Implementation: " + Bukkit.getName());
append("Server ID: " + Bukkit.getServerId()); append("Server ID: " + Bukkit.getServerId());
@@ -129,7 +130,7 @@ public class PastebinReport {
append("Online Mode: " + Bukkit.getOnlineMode()); append("Online Mode: " + Bukkit.getOnlineMode());
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers()); append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length); append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheat.getPlugin().getLoadTime()) / 1000) / 60 + " minutes"); append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheatReloaded.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
append("Enterprise: " + config.getConfig().enterprise.getValue()); append("Enterprise: " + config.getConfig().enterprise.getValue());
if (config.getConfig().enterprise.getValue()) { if (config.getConfig().enterprise.getValue()) {
append("- Server name: " + config.getEnterprise().serverName.getValue()); append("- Server name: " + config.getEnterprise().serverName.getValue());
@@ -142,8 +143,8 @@ public class PastebinReport {
private void appendMagicDiff() { private void appendMagicDiff() {
// This is hacky, and I like it // This is hacky, and I like it
Magic magic = AntiCheat.getManager().getConfiguration().getMagic(); Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheat.getPlugin().getDataFolder(), "magic.yml")); FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "magic.yml"));
boolean changed = false; boolean changed = false;
for (Field field : Magic.class.getFields()) { for (Field field : Magic.class.getFields()) {
Object defaultValue = file.get(field.getName()); Object defaultValue = file.get(field.getName());
@@ -168,11 +169,11 @@ public class PastebinReport {
} }
private void appendEventHandlers() { private void appendEventHandlers() {
report.append(AntiCheat.getManager().getEventChainReport()); report.append(AntiCheatReloaded.getManager().getEventChainReport());
} }
private void writeReport() throws IOException { private void writeReport() throws IOException {
File f = new File(AntiCheat.getPlugin().getDataFolder() + "/report.txt"); File f = new File(AntiCheatReloaded.getPlugin().getDataFolder() + "/report.txt");
FileWriter r = new FileWriter(f); FileWriter r = new FileWriter(f);
BufferedWriter writer = new BufferedWriter(r); BufferedWriter writer = new BufferedWriter(r);
writer.write(report.toString()); writer.write(report.toString());
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -16,7 +16,7 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Material; import org.bukkit.Material;
@@ -16,18 +16,19 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.util.rule.Rule;
import org.bukkit.Bukkit; 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.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -40,7 +41,7 @@ public class User {
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 = AntiCheat.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];
@@ -150,7 +151,7 @@ public class User {
// Check levels // Check levels
for (Group l : getLevels()) { for (Group l : getLevels()) {
if (l.getLevel() == level) { if (l.getLevel() == level) {
AntiCheat.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;
} }
@@ -16,9 +16,8 @@
* 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 net.gravitydevelopment.anticheat.util; package com.rammelkast.anticheatreloaded.util;
import net.gravitydevelopment.anticheat.AntiCheat;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@@ -29,6 +28,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -58,7 +59,7 @@ public final class Utilities {
} }
} }
for (String msg : message) { for (String msg : message) {
AntiCheat.getManager().log(msg); AntiCheatReloaded.getManager().log(msg);
} }
} }
@@ -0,0 +1,83 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class VersionUtil {
private static final List<String> SUPPORTED_VERSIONS = Arrays.asList(new String[] {
"v1_8",
"v1_9",
"v1_10",
"v1_11",
"v1_12"
});
public static String getVersion() {
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
}
public static boolean isSupported() {
for (String versionId : SUPPORTED_VERSIONS) {
if (getVersion().startsWith(versionId)) {
return true;
}
}
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) {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) {
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() {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) {
return 495;
} else {
return 1995;
}
}
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) {
return false;
}
return player.getInventory().getBoots().containsEnchantment(NMS_1_9_PLUS.FROST_WALKER);
} else {
return false;
}
}
}
@@ -16,15 +16,16 @@
* 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 net.gravitydevelopment.anticheat.util.enterprise; package com.rammelkast.anticheatreloaded.util.enterprise;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Utilities;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -136,7 +137,7 @@ public class Database {
connection.setAutoCommit(false); connection.setAutoCommit(false);
if (logInterval != 0) { if (logInterval != 0) {
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() { eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
flushEvents(); flushEvents();
@@ -145,7 +146,7 @@ public class Database {
} }
if(syncLevels && syncInterval != 0) { if(syncLevels && syncInterval != 0) {
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() { syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
syncUsers(); syncUsers();
@@ -153,7 +154,7 @@ public class Database {
}, syncInterval * 20, syncInterval * 20); }, syncInterval * 20, syncInterval * 20);
} }
AntiCheat.getPlugin().verboseLog("Connected to the database."); AntiCheatReloaded.getPlugin().verboseLog("Connected to the database.");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -202,7 +203,7 @@ public class Database {
public void cleanEvents() { public void cleanEvents() {
if (logLife != 0) { if (logLife != 0) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@@ -212,7 +213,7 @@ public class Database {
statement.executeUpdate(); statement.executeUpdate();
connection.commit(); connection.commit();
AntiCheat.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database"); AntiCheatReloaded.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -222,8 +223,8 @@ public class Database {
} }
private void syncUsers() { private void syncUsers() {
for (User user : AntiCheat.getManager().getUserManager().getUsers()) { for (User user : AntiCheatReloaded.getManager().getUserManager().getUsers()) {
AntiCheat.getManager().getConfiguration().getLevels().updateLevelToUser(user); AntiCheatReloaded.getManager().getConfiguration().getLevels().updateLevelToUser(user);
} }
} }
} }
@@ -16,14 +16,15 @@
* 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 net.gravitydevelopment.anticheat.util.rule; package com.rammelkast.anticheatreloaded.util.rule;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager; import javax.script.ScriptEngineManager;
import javax.script.ScriptException; import javax.script.ScriptException;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.SortedMap; import java.util.SortedMap;
/** /**
@@ -42,7 +43,7 @@ import java.util.SortedMap;
* Check_SPIDER > 0 ? Player.KICK : null<br /> * Check_SPIDER > 0 ? Player.KICK : null<br />
* <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i> * <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i>
* <p/> * <p/>
* To see syntax for variables and functions that you may use, see {@link net.gravitydevelopment.anticheat.util.rule.Rule} * To see syntax for variables and functions that you may use, see {@link com.rammelkast.anticheatreloaded.util.rule.Rule}
*/ */
public class ConditionalRule extends Rule { public class ConditionalRule extends Rule {
@@ -16,15 +16,16 @@
* 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 net.gravitydevelopment.anticheat.util.rule; package com.rammelkast.anticheatreloaded.util.rule;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Group;
import net.gravitydevelopment.anticheat.util.Utilities;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -44,7 +45,7 @@ import java.util.TreeMap;
* <ul> * <ul>
* <li>Check * <li>Check
* <ul> * <ul>
* <li>Contains all valid checks as listed in {@link net.gravitydevelopment.anticheat.check.CheckType}</li> * <li>Contains all valid checks as listed in {@link com.rammelkast.anticheatreloaded.check.CheckType}</li>
* <li>Will return the number of times this user has failed the given check</li> * <li>Will return the number of times this user has failed the given check</li>
* <li><b>Example:</b> Check_SPRINT</li> * <li><b>Example:</b> Check_SPRINT</li>
* </ul> * </ul>
@@ -76,7 +77,7 @@ import java.util.TreeMap;
* <p/> * <p/>
* The Rule class itself is not an functional rule setup, * The Rule class itself is not an functional rule setup,
* it is inherited and made functional by different implementations of the rule parser.<br /> * it is inherited and made functional by different implementations of the rule parser.<br />
* The only current Rule implementation is the {@link net.gravitydevelopment.anticheat.util.rule.ConditionalRule} * The only current Rule implementation is the {@link com.rammelkast.anticheatreloaded.util.rule.ConditionalRule}
*/ */
public class Rule { public class Rule {
@@ -145,7 +146,7 @@ public class Rule {
/** /**
* Get the type of rule this is * Get the type of rule this is
* *
* @return a {@link net.gravitydevelopment.anticheat.util.rule.Rule.Type} * @return a {@link com.rammelkast.anticheatreloaded.util.rule.Rule.Type}
*/ */
public Type getType() { public Type getType() {
return type; return type;
@@ -174,7 +175,7 @@ public class Rule {
if (variable.equals("player_level") && Utilities.isInt(value)) { if (variable.equals("player_level") && Utilities.isInt(value)) {
user.setLevel(Integer.parseInt(value)); user.setLevel(Integer.parseInt(value));
} else if (variable.equals("player_group") && Utilities.isInt(value)) { } else if (variable.equals("player_group") && Utilities.isInt(value)) {
for (Group group : AntiCheat.getManager().getConfiguration().getGroups().getGroups()) { for (Group group : AntiCheatReloaded.getManager().getConfiguration().getGroups().getGroups()) {
if (group.getName().equalsIgnoreCase(value)) { if (group.getName().equalsIgnoreCase(value)) {
user.setLevel(group.getLevel()); user.setLevel(group.getLevel());
} }
@@ -195,7 +196,7 @@ public class Rule {
text = text.split("\\.")[1]; text = text.split("\\.")[1];
List<String> action = new ArrayList<String>(); List<String> action = new ArrayList<String>();
action.add(text); action.add(text);
AntiCheat.getManager().getUserManager().execute(user, action, type); AntiCheatReloaded.getManager().getUserManager().execute(user, action, type);
} }
} }
@@ -1,215 +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 net.gravitydevelopment.anticheat;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
import net.gravitydevelopment.anticheat.command.CommandHandler;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.event.BlockListener;
import net.gravitydevelopment.anticheat.event.EntityListener;
import net.gravitydevelopment.anticheat.event.InventoryListener;
import net.gravitydevelopment.anticheat.event.PlayerListener;
import net.gravitydevelopment.anticheat.event.VehicleListener;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.VersionUtil;
public class AntiCheat extends JavaPlugin {
private static AntiCheatManager manager;
private static AntiCheat plugin;
private static List<Listener> eventList = new ArrayList<Listener>();
private static Configuration config;
private static boolean verbose;
private static boolean developer;
private static final int PROJECT_ID = 100229;
private static ProtocolManager protocolManager;
private static boolean protocolLib = false;
private static Long loadTime;
@Override
public void onEnable() {
plugin = this;
loadTime = System.currentTimeMillis();
manager = new AntiCheatManager(this, getLogger());
eventList.add(new PlayerListener());
eventList.add(new BlockListener());
eventList.add(new EntityListener());
eventList.add(new VehicleListener());
eventList.add(new InventoryListener());
// Order is important in some cases, don't screw with these unless needed, especially config
setupConfig();
setupEvents();
setupCommands();
setupProtocol();
// Enterprise must come before levels
setupEnterprise();
restoreLevels();
// Check if NoCheatPlus is installed
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
public void run() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
getLogger().severe("You are also running NoCheatPlus!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
}else if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
getLogger().severe("You are also running AAC!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AAC to silence this warning.");
}
}
}, 40L);
// End tests
verboseLog("Finished loading.");
getLogger().info("Running version " + VersionUtil.getVersion() + "...");
// Enable packetlisteners
KillAuraCheck.listenPackets();
BlinkCheck.startTimer();
BlinkCheck.listenPackets();
}
@Override
public void onDisable() {
verboseLog("Saving user levels...");
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
AntiCheatManager.close();
getServer().getScheduler().cancelTasks(this);
cleanup();
}
private void setupProtocol() {
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
protocolLib = true;
protocolManager = ProtocolLibrary.getProtocolManager();
verboseLog("Hooked into ProtocolLib");
}
}
private void setupEvents() {
for (Listener listener : eventList) {
getServer().getPluginManager().registerEvents(listener, this);
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
}
}
private void setupCommands() {
getCommand("anticheat").setExecutor(new CommandHandler());
verboseLog("Registered commands.");
}
private void setupConfig() {
config = manager.getConfiguration();
verboseLog("Setup the config.");
}
private void setupEnterprise() {
if (config.getConfig().enterprise.getValue()) {
if (config.getEnterprise().loggingEnabled.getValue()) {
config.getEnterprise().database.cleanEvents();
}
}
}
private void restoreLevels() {
for (Player player : getServer().getOnlinePlayers()) {
UUID uuid = player.getUniqueId();
User user = new User(uuid);
user.setIsWaitingOnLevelSync(true);
config.getLevels().loadLevelToUser(user);
manager.getUserManager().addUser(user);
verboseLog("Data for " + uuid + " loaded");
}
}
public static AntiCheat getPlugin() {
return plugin;
}
public static AntiCheatManager getManager() {
return manager;
}
public static String getVersion() {
return manager.getPlugin().getDescription().getVersion();
}
private void cleanup() {
eventList = null;
manager = null;
config = null;
}
public static boolean developerMode() {
return developer;
}
public static void setDeveloperMode(boolean b) {
developer = b;
}
public static boolean isUsingProtocolLib() {
return protocolLib;
}
public static void debugLog(final String string) {
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
public void run() {
if (developer) {
manager.debugLog("[DEBUG] " + string);
}
}
});
}
public void verboseLog(final String string) {
if (verbose) {
getLogger().info(string);
}
}
public void setVerbose(boolean b) {
verbose = b;
}
public Long getLoadTime() {
return loadTime;
}
public static ProtocolManager getProtocolManager() {
return protocolManager;
}
}
@@ -1,138 +0,0 @@
package net.gravitydevelopment.anticheat.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil;
/**
* This is broken as f*ck
*/
public class GlideCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastToFall = new HashMap<UUID, Double>();
public static Map<UUID, Integer> glideBuffer = new HashMap<UUID, Integer>();
/*
* SOME OLD CODE
*
* UUID uuid = player.getUniqueId();
if(!lastYDelta.containsKey(uuid))
lastYDelta.put(uuid, 0.0);
if(!YAxisCheck.lastYcoord.containsKey(uuid))
YAxisCheck.lastYcoord.put(uuid, player.getLocation().getY());
double currentY = player.getLocation().getY();
double math = currentY - YAxisCheck.lastYcoord.get(uuid);
if((math < 0 && math > AntiCheat.getManager().getBackend().getMagic().GLIDE_MAX()) && !AntiCheat.getManager().getBackend().isMovingExempt(player))
{
if(math <= lastYDelta.get(uuid) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
&& Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.cantStandAtSingle(player.getLocation().getBlock()) && !!Utilities.cantStandAtSingle(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
{
if(!glideBuffer.containsKey(uuid))
glideBuffer.put(uuid, 0);
int currentBuffer = glideBuffer.get(uuid);
glideBuffer.put(uuid, currentBuffer + 1);
if(currentBuffer >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT())
{
double fallDist = distanceToFall(player.getLocation());
player.teleport(player.getLocation().add(0, -fallDist, 0));
player.setFallDistance((float) fallDist);
if(!AntiCheat.getManager().getBackend().silentMode())
{
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
}
lastYDelta.put(uuid, math);
return new CheckResult(CheckResult.Result.FAILED, uuid + " attempted to fall too slowly!");
}
}
}else {
glideBuffer.remove(uuid);
}
lastYDelta.put(uuid, math);*/
public static CheckResult runCheck(Player player, Distance distance) {
/* UUID uuid = player.getUniqueId();
if (AntiCheat.getManager().getBackend().isMovingExempt(player) || VersionUtil.isFlying(player)) {
return PASS;
}
if(!YAxisCheck.lastYcoord.containsKey(uuid)) {
YAxisCheck.lastYcoord.put(uuid, player.getLocation().getY());
}
if(!YAxisCheck.lastYtime.containsKey(uuid)) {
YAxisCheck.lastYtime.put(uuid, System.currentTimeMillis());
}
double currentY = player.getLocation().getY();
double diff = currentY - YAxisCheck.lastYcoord.get(uuid);
double glideMax = AntiCheat.getManager().getBackend().getMagic().GLIDE_MAX();
long timeDiff = System.currentTimeMillis() - YAxisCheck.lastYtime.get(uuid);
if (diff <= glideMax || diff >= 0) {
return PASS;
}
if (!(!(player.getEyeLocation().getBlock().getType() == Material.LADDER)
|| !Utilities.isInWater(player) || !Utilities.isInWeb(player)
|| Utilities.cantStandAt(player.getLocation().getBlock()) || !Utilities.cantStandAtSingle(player.getLocation().getBlock()) || !Utilities.cantStandAtSingle(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))) {
return PASS;
}
if (timeDiff <= 150/) {
return PASS;
}
if(!lastToFall.containsKey(uuid)) {
lastToFall.put(uuid, distanceToFall(player.getLocation()));
} else {
double lastFall = lastToFall.get(uuid);
if (distanceToFall(player.getLocation()) + diff >= lastFall - 0.10125) {
if (!glideBuffer.containsKey(uuid)) {
glideBuffer.put(uuid, 1);
} else {
int buffer = glideBuffer.get(uuid);
if (buffer >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
glideBuffer.remove(uuid);
if(!AntiCheat.getManager().getBackend().silentMode())
{
double fallDist = distanceToFall(player.getLocation());
player.teleport(player.getLocation().add(0, -fallDist, 0));
player.setFallDistance((float) fallDist);
}
return new CheckResult(CheckResult.Result.FAILED, uuid + " attempted to glide!");
} else {
glideBuffer.put(uuid, buffer + 1);
}
}
}
}
System.out.println(diff + ":" + timeDiff + ":" + distanceToFall(player.getLocation()));
*/
return PASS;
}
private static double distanceToFall(Location location) {
location = location.clone();
double firstY = location.getY();
while (location.clone().add(0, -0.1, 0).getBlock().getType() == Material.AIR)
location.add(0, -0.1, 0);
return firstY - location.getY();
}
}
@@ -1,51 +0,0 @@
package net.gravitydevelopment.anticheat.util;
import java.util.EnumSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class VersionUtil {
public static String getVersion() {
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
}
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);
private 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);
public static boolean isFlying(Player p) {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return p.isFlying() || p.isGliding();
} else {
return p.isFlying();
}
}
public static EnumSet<Material> getMoveUpBlocks() {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return MOVE_UP_BLOCKS_1_9;
} else {
return MOVE_UP_BLOCKS_1_8;
}
}
public static boolean isNewYSpeed() {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return true;
} else {
return false;
}
}
}
-2
View File
@@ -40,7 +40,6 @@ FASTPLACE_TIMEMIN: 50
FASTPLACE_ZEROLIMIT: 3 FASTPLACE_ZEROLIMIT: 3
FLIGHT_BLOCK_LIMIT: 15.0 FLIGHT_BLOCK_LIMIT: 15.0
FLIGHT_LIMIT: 150 FLIGHT_LIMIT: 150
HEAL_TIME_MIN: 2000
INSTANT_BREAK_TIME: 2 INSTANT_BREAK_TIME: 2
INVENTORY_CHECK: 10 INVENTORY_CHECK: 10
INVENTORY_TIMEMIN: 50 INVENTORY_TIMEMIN: 50
@@ -84,7 +83,6 @@ Y_MAXVIOTIME: 5500
Y_SPEED_MAX: 0.5125 Y_SPEED_MAX: 0.5125
Y_TIME: 800 Y_TIME: 800
GLIDE_LIMIT: 10 GLIDE_LIMIT: 10
GLIDE_MAX: -3.89425
KILLAURA_BOTHITS: 4 KILLAURA_BOTHITS: 4
BLINK_PACKET: 74 BLINK_PACKET: 74
VELOCITY_AMT: 5 VELOCITY_AMT: 5
+2 -3
View File
@@ -1,10 +1,9 @@
name: AntiCheatReloaded 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: net.gravitydevelopment.anticheat.AntiCheat main: com.rammelkast.anticheatreloaded.AntiCheatReloaded
softdepend: [ProtocolLib] depend: [ProtocolLib]
startup: postworld startup: postworld
url: http://gravitydevelopment.net
version: ${project.build.version} version: ${project.build.version}
commands: commands:
anticheat: anticheat: