Compare commits

...
9 Commits
82 changed files with 1183 additions and 947 deletions

No files matched your search

+7 -8
View File
@@ -3,9 +3,8 @@ AntiCheatReloaded
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.
###Want to help me out?
First of all, i've put a lot of time and work in this project, so donations (especially in (m)BTC) are appreciated!
My BTC address is 1JfyX6hvGUazHTtKVLaNcYaUxnyjR5HtMY
### BTC donations: 1DwUKboRQKrgR9o1oZC4VutkCUwdZStHtk
### LTC donations: LTXzGnVLXmiH5XJch1bKrcZtzQjaF9rd8V
Bug Reporting
------------
@@ -15,15 +14,15 @@ Issues should be filed by hitting the [issues](https://github.com/Rammelkast/Ant
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/Paper/Taco) and it's version
* When using protocollib, your protocollib version
* If you use protocolhacks (ViaVersion etc.)
* 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 and the ProtoclLib into your Plugins folder.
Simply drag and drop the plugin file and the ProtocolLib jar into your Plugins folder.
###Hacks blocked
Hacks blocked
-------
* Blink
* Flight
+100 -100
View File
@@ -1,100 +1,100 @@
<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>
<groupId>net.gravitydevelopment.anticheat</groupId>
<artifactId>AntiCheat</artifactId>
<version>1.6.0-ALPHA</version>
<name>AntiCheatReloaded</name>
<url>https://rammelkast.com</url>
<properties>
<project.build.version>${project.version}</project.build.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository>
</repositories>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>net.gravitydevelopment.*</include>
</includes>
</artifactSet>
</configuration>
</plugin>
</plugins>
<finalName>AntiCheatReloaded</finalName>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>2.2</version>
</extension>
</extensions>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<project.build.version>${project.version}-b${env.BUILD_NUMBER}</project.build.version>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId>
<version>1.6.3-ALPHA</version>
<name>AntiCheatReloaded</name>
<url>https://rammelkast.com</url>
<properties>
<project.build.version>${project.version}</project.build.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository>
</repositories>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>com.rammelkast.*</include>
</includes>
</artifactSet>
</configuration>
</plugin>
</plugins>
<finalName>AntiCheatReloaded</finalName>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>2.2</version>
</extension>
</extensions>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<project.build.version>${project.version}-b${env.BUILD_NUMBER}</project.build.version>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-API</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -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/>.
*/
package net.gravitydevelopment.anticheat.api;
package com.rammelkast.anticheatreloaded.api;
import java.util.List;
import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.manage.CheckManager;
import net.gravitydevelopment.anticheat.manage.UserManager;
import net.gravitydevelopment.anticheat.util.Group;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.manage.UserManager;
import com.rammelkast.anticheatreloaded.util.Group;
/**
* Developer's interface for all things AntiCheat.
*/
public class AntiCheatAPI {
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
private static UserManager umr = AntiCheat.getManager().getUserManager();
private static CheckManager chk = AntiCheatReloaded.getManager().getCheckManager();
private static UserManager umr = AntiCheatReloaded.getManager().getUserManager();
// 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
* @return The player's group
@@ -159,7 +159,7 @@ public class AntiCheatAPI {
* Get all configured Groups
*
* @return List of all groups
* @see net.gravitydevelopment.anticheat.util.Group
* @see com.rammelkast.anticheatreloaded.util.Group
*/
public static List<Group> getGroups() {
return getManager().getConfiguration().getGroups().getGroups();
@@ -173,7 +173,7 @@ public class AntiCheatAPI {
* @return the AntiCheat Manager
*/
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/>.
*/
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.HandlerList;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
/**
* 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() {
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() {
return type;
@@ -16,7 +16,7 @@
* 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.HashMap;
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -37,23 +36,23 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck;
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.providers.Lang;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class Backend {
private List<UUID> isAscending = new ArrayList<UUID>();
@@ -517,14 +516,14 @@ public class Backend {
fastPlaceViolation.put(uuid, 0);
}
} 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);
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()) {
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 + ")");
} 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);
}
} else if (lastBlockPlaced.containsKey(uuid)) {
@@ -16,7 +16,7 @@
* 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 {
@@ -16,14 +16,15 @@
* 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.entity.Player;
import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.combat;
package com.rammelkast.anticheatreloaded.check.combat;
import org.bukkit.Material;
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.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener;
import net.gravitydevelopment.anticheat.util.Utilities;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class CriticalsCheck {
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.combat;
package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap;
import java.util.Map;
@@ -12,20 +12,19 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener;
import net.gravitydevelopment.anticheat.util.NPC_1_11;
import net.gravitydevelopment.anticheat.util.VersionUtil;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.NPC_1_12;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast
*/
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>();
public static void cleanPlayer(Player p) {
@@ -39,7 +38,7 @@ public class KillAuraCheck {
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
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
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
@@ -57,7 +56,8 @@ public class KillAuraCheck {
}else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
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());
}
}
@@ -72,7 +72,7 @@ public class KillAuraCheck {
if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p);
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.spawn();
}
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.combat;
package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap;
import java.util.Map;
@@ -9,10 +9,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener;
public class VelocityCheck {
@@ -23,7 +23,7 @@ public class VelocityCheck {
}
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;
final Location then = p.getLocation();
new BukkitRunnable() {
@@ -36,8 +36,8 @@ public class VelocityCheck {
VL_COUNT.put(p.getUniqueId(), 1);
else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) > AntiCheat.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);
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=" + AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_AMT() + ", dist=" + then.distance(p.getLocation()) + ")").getMessage(), p, CheckType.VELOCITY);
VL_COUNT.remove(p.getUniqueId());
}
}
@@ -45,7 +45,7 @@ public class VelocityCheck {
VL_COUNT.remove(p.getUniqueId());
}
}
}.runTaskLater(AntiCheat.getPlugin(), 4);
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
}
}
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement;
package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap;
import java.util.Map;
@@ -12,11 +12,10 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener;
/**
* @author Rammelkast
@@ -31,22 +30,22 @@ public class BlinkCheck {
public void run() {
MOVE_COUNT.clear();
}
}.runTaskTimer(AntiCheat.getPlugin(), 0, 20);
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
}
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
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
Location cur = e.getPlayer().getLocation();
if (!MOVE_COUNT.containsKey(p.getUniqueId()))
if (!MOVE_COUNT.containsKey(p.getUniqueId())) {
MOVE_COUNT.put(p.getUniqueId(), 1);
else {
} else {
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 (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.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);
if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p) && !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p) && !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
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=" + AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.BLINK);
MOVE_COUNT.remove(p.getUniqueId());
e.setCancelled(true);
e.getPlayer().teleport(cur);
@@ -1,9 +1,9 @@
package net.gravitydevelopment.anticheat.check.movement;
package com.rammelkast.anticheatreloaded.check.movement;
import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
/**
* TODO
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement;
package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap;
import java.util.Map;
@@ -8,15 +8,15 @@ 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;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
*
* @author Marco TODO rewrite this check
* @author Rammelkast
* TODO rewrite this check
*/
public class FlightCheck {
@@ -26,9 +26,9 @@ public class FlightCheck {
public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>();
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)) {
// 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.
return PASS;
}
@@ -51,11 +51,11 @@ public class FlightCheck {
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)) {
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max="
+ AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
+ AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
}
} else {
blocksOverFlight.put(uuid, 0D);
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement;
package com.rammelkast.anticheatreloaded.check.movement;
import java.math.BigDecimal;
import java.util.HashMap;
@@ -11,12 +11,12 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.Backend;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil;
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 {
@@ -44,11 +44,13 @@ public class GlideCheck {
if (!violations.containsKey(player.getUniqueId())) {
violations.put(player.getUniqueId(), 1);
} else {
if (violations.get(player.getUniqueId()) + 1 >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
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 {
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.check.movement;
package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap;
import java.util.Map;
@@ -8,9 +8,9 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.VersionUtil;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class SpeedCheck {
@@ -18,51 +18,51 @@ public class SpeedCheck {
public static Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>();
public static boolean isSpeedExempt(Player player) {
return AntiCheat.getManager().getBackend().isMovingExempt(player)
|| AntiCheat.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
return AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|| AntiCheatReloaded.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
}
public static CheckResult checkXZSpeed(Player player, double x, double z) {
if (!isSpeedExempt(player) && player.getVehicle() == null) {
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.isSprinting()) {
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)) {
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 {
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)) {
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)) {
if (player.isSprinting()) {
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 {
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()) {
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();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if (x > max || z > max) {
int num = AntiCheat.getManager().getBackend().increment(player, speedViolation,
AntiCheat.getManager().getBackend().getMagic().SPEED_MAX());
if (num >= AntiCheat.getManager().getBackend().getMagic().SPEED_MAX()) {
int num = AntiCheatReloaded.getManager().getBackend().increment(player, speedViolation,
AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX());
if (num >= AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX()) {
return new CheckResult(CheckResult.Result.FAILED,
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 + ")");
} else {
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.HashMap;
@@ -11,9 +11,10 @@ import org.bukkit.block.Block;
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.Utilities;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* This check seems to be broken/outdated
@@ -27,25 +28,22 @@ public class WaterWalkCheck {
public static Map<UUID, Integer> waterSpeedViolation = new HashMap<UUID, Integer>();
public static Map<UUID, Integer> waterAscensionViolation = new HashMap<UUID, Integer>();
/**
* TODO check & fix for 1.11? (see #25)
*/
public static CheckResult runCheck(Player player, double x, double y, double z) {
Block block = player.getLocation().getBlock();
UUID uuid = player.getUniqueId();
if (player.getVehicle() == null && !player.isFlying()) {
if (player.getVehicle() == null && !player.isFlying() && !VersionUtil.isFrostWalk(player)) {
if (block.isLiquid()) {
if (isInWater.contains(uuid)) {
if (isInWaterCache.contains(uuid)) {
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
boolean b;
if (!Utilities.sprintFly(player)) {
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER()
|| z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER()
|| z > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
} else {
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|| z > AntiCheat.getManager().getBackend().getMagic()
b = x > AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|| z > AntiCheatReloaded.getManager().getBackend().getMagic()
.XZ_SPEED_MAX_WATER_SPRINT();
}
if (!b && !Utilities.isFullyInWater(player.getLocation())
@@ -56,7 +54,7 @@ public class WaterWalkCheck {
if (b) {
if (waterSpeedViolation.containsKey(uuid)) {
int v = waterSpeedViolation.get(uuid);
if (v >= AntiCheat.getManager().getBackend().getMagic()
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic()
.WATER_SPEED_VIOLATION_MAX()) {
waterSpeedViolation.put(uuid, 0);
return new CheckResult(CheckResult.Result.FAILED,
@@ -80,11 +78,11 @@ public class WaterWalkCheck {
return PASS;
}
} 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))) {
if (waterAscensionViolation.containsKey(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);
return new CheckResult(CheckResult.Result.FAILED,
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.HashMap;
@@ -12,11 +12,11 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
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;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class YAxisCheck {
@@ -32,7 +32,7 @@ public class YAxisCheck {
}
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)) {
return PASS;
}
@@ -52,13 +52,13 @@ public class YAxisCheck {
lastYtime.put(uuid, System.currentTimeMillis());
} else {
if (y1 > lastYcoord.get(uuid)
&& yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheat.getManager()
&& yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) {
Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
if (!AntiCheat.getManager().getBackend().silentMode()) {
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
if (g.getBlock().getType() == Material.AIR) {
player.teleport(g);
@@ -66,33 +66,33 @@ public class YAxisCheck {
}
return new CheckResult(CheckResult.Result.FAILED,
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 {
if (yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheat.getManager()
if (yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) {
yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L);
}
}
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);
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();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
if (!AntiCheat.getManager().getBackend().silentMode()) {
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
if (g.getBlock().getType() == Material.AIR) {
player.teleport(g);
}
}
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 {
if ((y1 - lastYcoord.get(uuid)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + 1
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheat.getManager().getBackend()
if ((y1 - lastYcoord.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF() + 1
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheatReloaded.getManager().getBackend()
.getMagic().Y_TIME()) {
lastYtime.put(uuid, System.currentTimeMillis());
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/>.
*/
package net.gravitydevelopment.anticheat.command;
package com.rammelkast.anticheatreloaded.command;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -24,17 +24,17 @@ import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.manage.CheckManager;
import net.gravitydevelopment.anticheat.manage.UserManager;
import net.gravitydevelopment.anticheat.util.Permission;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.manage.UserManager;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandBase {
public static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
public static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
public static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
public static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
public static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
public static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
public static final ChatColor RED = ChatColor.RED;
public static final ChatColor YELLOW = ChatColor.YELLOW;
public static final ChatColor GREEN = ChatColor.GREEN;
@@ -16,7 +16,7 @@
* 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.List;
@@ -25,14 +25,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import net.gravitydevelopment.anticheat.command.executors.CommandCheck;
import net.gravitydevelopment.anticheat.command.executors.CommandDebug;
import net.gravitydevelopment.anticheat.command.executors.CommandDeveloper;
import net.gravitydevelopment.anticheat.command.executors.CommandHelp;
import net.gravitydevelopment.anticheat.command.executors.CommandLog;
import net.gravitydevelopment.anticheat.command.executors.CommandReload;
import net.gravitydevelopment.anticheat.command.executors.CommandReport;
import net.gravitydevelopment.anticheat.command.executors.CommandReset;
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
import com.rammelkast.anticheatreloaded.command.executors.CommandDebug;
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
public class CommandHandler implements CommandExecutor {
@@ -16,13 +16,14 @@
* 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 com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
import java.util.List;
public class CommandCheck extends CommandBase {
@@ -16,15 +16,16 @@
* 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.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.PastebinReport;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandDebug extends CommandBase {
private static final String NAME = "AntiCheat Debug Reporting";
@@ -16,13 +16,14 @@
* 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 com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandDeveloper extends CommandBase {
private static final String NAME = "AntiCheat Developer Mode";
@@ -39,7 +40,7 @@ public class CommandDeveloper extends CommandBase {
@Override
protected void execute(CommandSender cs, String[] args) {
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
cs.sendMessage(GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
AntiCheatReloaded.setDeveloperMode(!AntiCheatReloaded.developerMode());
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/>.
*/
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 com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandHelp extends CommandBase {
private static final String NAME = "AntiCheatReloaded Help";
@@ -16,13 +16,14 @@
* 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 com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandLog extends CommandBase {
private static final String NAME = "AntiCheat Logging";
@@ -16,12 +16,13 @@
* 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 com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandReload extends CommandBase {
private static final String NAME = "AntiCheat Reload";
@@ -16,18 +16,19 @@
* 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.ChatColor;
import org.bukkit.command.CommandSender;
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.List;
import java.util.UUID;
@@ -82,7 +83,7 @@ public class CommandReport extends CommandBase {
// Test users
for (Player player : Bukkit.getOnlinePlayers()) {
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);
return;
}
@@ -175,13 +176,13 @@ public class CommandReport extends CommandBase {
}
}
if (AntiCheat.developerMode()) {
if (AntiCheatReloaded.developerMode()) {
int permission = 0;
int check = 0;
for (Permission perm : Permission.values()) {
if (perm.get(user.getPlayer())) permission++;
}
CheckManager manager = AntiCheat.getManager().getCheckManager();
CheckManager manager = AntiCheatReloaded.getManager().getCheckManager();
for (CheckType type : CheckType.values()) {
if (manager.willCheck(user.getPlayer(), type)) check++;
}
@@ -16,17 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
public class CommandReset extends CommandBase {
private static final String NAME = "AntiCheat Resetting";
@@ -53,7 +53,7 @@ public class CommandReset extends CommandBase {
if (user != null) {
user.resetLevel();
user.clearMessages();
AntiCheat.getManager().getBackend().resetChatLevel(user);
AntiCheatReloaded.getManager().getBackend().resetChatLevel(user);
cs.sendMessage(args[0] + GREEN + " has been reset.");
} else {
cs.sendMessage(RED + "Player: " +args[0] + " not found.");
@@ -16,17 +16,18 @@
* 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 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.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -47,7 +48,7 @@ public class Configuration {
private ArrayList<ConfigurationFile> flatfiles;
private ArrayList<ConfigurationTable> dbfiles;
public Configuration(AntiCheat plugin, AntiCheatManager manager) {
public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
removeOldFiles();
this.manager = manager;
config = new Config(plugin, this);
@@ -145,20 +146,20 @@ public class Configuration {
private void removeOldFiles() {
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) {
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");
}
File eventsFile = new File(AntiCheat.getPlugin().getDataFolder(), "events.yml");
File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
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");
}
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) {
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/>.
*/
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.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class ConfigurationFile {
@@ -35,21 +37,21 @@ public class ConfigurationFile {
private FileConfiguration defaultConfigFile;
private Configuration config;
private AntiCheat plugin;
private AntiCheatReloaded plugin;
private boolean saveDefault;
protected boolean needsReload;
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName) {
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
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));
}
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
this.plugin = plugin;
this.config = config;
@@ -58,7 +60,13 @@ public class ConfigurationFile {
this.saveDefault = 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();
}
@@ -16,12 +16,13 @@
* 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 com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -58,7 +59,7 @@ public class ConfigurationTable {
public void reload() {
// For after sql inserts have been made
Bukkit.getScheduler().runTask(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
load();
@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.config.files;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
package com.rammelkast.anticheatreloaded.config.files;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class Config extends ConfigurationFile {
public static final String FILENAME = "config.yml";
@@ -51,7 +51,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<List<String>> disabledChecks;
public Config(AntiCheat plugin, Configuration config) {
public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -16,12 +16,12 @@
* 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 net.gravitydevelopment.anticheat.util.enterprise.Database;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
public class Enterprise extends ConfigurationFile {
@@ -43,7 +43,7 @@ public class Enterprise extends ConfigurationFile {
public Database database;
public Enterprise(AntiCheat plugin, Configuration config) {
public Enterprise(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -16,12 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.config.holders.mysql;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -29,6 +24,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Groups;
import com.rammelkast.anticheatreloaded.util.Group;
public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
private static final String TABLE = "groups";
@@ -16,15 +16,18 @@
* 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.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.PreparedStatement;
@@ -49,7 +52,13 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
@Override
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>();
listValues = new HashMap<String, List<String>>();
@@ -141,7 +150,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
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.";
}
@@ -16,15 +16,16 @@
* 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 com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
import com.rammelkast.anticheatreloaded.util.User;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -80,11 +81,11 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override
public void saveLevelFromUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
if (!user.isWaitingOnLevelSync()) {
AntiCheat.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
try {
PreparedStatement statement = getConnection().prepareStatement(sqlSave);
statement.setString(1, user.getUUID().toString());
@@ -100,14 +101,14 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
e.printStackTrace();
}
}
AntiCheat.getManager().getUserManager().remove(user);
AntiCheatReloaded.getManager().getUserManager().remove(user);
}
});
}
@Override
public void loadLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -119,7 +120,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
boolean has = false;
while (set.next()) {
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.setLevelSyncTimestamp(set.getTimestamp("last_update"));
}
@@ -161,7 +162,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override
public void updateLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -173,7 +174,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
ResultSet set = statement.executeQuery();
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.setLevelSyncTimestamp(set.getTimestamp("last_update"));
}
@@ -16,15 +16,18 @@
* 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.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.ResultSet;
@@ -46,7 +49,13 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
@Override
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>();
doubles = new HashMap<String, Double>();
@@ -93,7 +102,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
} else if (set.getObject("value_double") != null) {
doubles.put(key, set.getDouble("value_double"));
} 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++) {
String name = methods[i-1].getName();
if (name.equalsIgnoreCase(key)) {
@@ -140,7 +149,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
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;
}
}
@@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.config.holders.mysql;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public class MySQLRulesHolder extends ConfigurationTable implements Rules {
private static final String TABLE = "rules";
@@ -65,7 +65,7 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
if (rule != null) {
this.rules.add(rule);
} 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) {
@@ -16,16 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.*;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Groups;
import com.rammelkast.anticheatreloaded.util.Group;
public class YamlGroupsHolder extends ConfigurationFile implements Groups {
public static final String FILENAME = "groups.yml";
@@ -34,7 +34,7 @@ public class YamlGroupsHolder extends ConfigurationFile implements Groups {
private int highestLevel;
public YamlGroupsHolder(AntiCheat plugin, Configuration config) {
public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -16,21 +16,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class YamlLangHolder extends ConfigurationFile implements InvocationHandler {
public static final String FILENAME = "lang.yml";
public YamlLangHolder(AntiCheat plugin, Configuration config) {
public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -76,7 +76,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
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.";
}
}
@@ -16,22 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.List;
import java.util.UUID;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
import com.rammelkast.anticheatreloaded.util.User;
public class YamlLevelsHolder extends ConfigurationFile implements Levels {
public static final String FILENAME = "data/levels.yml";
public YamlLevelsHolder(AntiCheat plugin, Configuration config) {
public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME, false);
}
@@ -47,7 +47,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
private void saveLevelFromUser(User user, boolean remove) {
saveLevel(user.getUUID(), user.getLevel());
if (remove) AntiCheat.getManager().getUserManager().remove(user);
if (remove) AntiCheatReloaded.getManager().getUserManager().remove(user);
}
@Override
@@ -16,20 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
public static final String FILENAME = "magic.yml";
public YamlMagicHolder(AntiCheat plugin, Configuration config) {
public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -41,7 +41,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
} else if (method.getReturnType().getSimpleName().equals("double")) {
return new ConfigValue<Double>(key).getValue();
} 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;
}
}
@@ -16,24 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.ArrayList;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public class YamlRulesHolder extends ConfigurationFile implements Rules {
public static final String FILENAME = "rules.yml";
private List<Rule> rules;
public YamlRulesHolder(AntiCheat plugin, Configuration config) {
public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -61,7 +61,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
if (rule != null) {
this.rules.add(rule);
} 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/>.
*/
package net.gravitydevelopment.anticheat.config.providers;
import net.gravitydevelopment.anticheat.util.Group;
package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List;
import com.rammelkast.anticheatreloaded.util.Group;
public interface Groups {
/**
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.config.providers;
package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List;
@@ -16,12 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.config.providers;
import net.gravitydevelopment.anticheat.util.User;
package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List;
import com.rammelkast.anticheatreloaded.util.User;
public interface Levels {
/**
@@ -16,7 +16,7 @@
* 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.
@@ -17,12 +17,12 @@
*/
package net.gravitydevelopment.anticheat.config.providers;
import net.gravitydevelopment.anticheat.util.rule.Rule;
package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
public interface Rules {
/**
@@ -16,7 +16,7 @@
* 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.bukkit.Bukkit;
@@ -33,6 +33,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
@@ -188,7 +189,9 @@ public class CommentedConfiguration extends YamlConfiguration {
CommentedConfiguration config = new CommentedConfiguration();
try {
config.load(stream);
InputStreamReader reader = new InputStreamReader(stream);
config.load(reader);
reader.close();
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
@@ -16,13 +16,8 @@
* 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.entity.Player;
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.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 {
@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)
@@ -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)
@@ -16,7 +16,7 @@
* 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.entity.Creeper;
@@ -28,17 +28,18 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
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.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 {
@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
@@ -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
@@ -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)
@@ -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/>.
*/
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.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.HashMap;
import java.util.Map;
@@ -35,18 +36,18 @@ import java.util.UUID;
public class EventListener implements Listener {
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 CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
private static final Backend BACKEND = AntiCheat.getManager().getBackend();
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin();
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
public static void log(String message, Player player, CheckType type) {
User user = getUserManager().getUser(player.getUniqueId());
if (user != null) { // npc
logCheat(type, user);
if (user.increaseLevel(type) && message != null) {
AntiCheat.getManager().log(message);
AntiCheatReloaded.getManager().log(message);
}
removeDecrease(user);
}
@@ -115,7 +116,7 @@ public class EventListener implements Listener {
}
public static AntiCheatManager getManager() {
return AntiCheat.getManager();
return AntiCheatReloaded.getManager();
}
public static Backend getBackend() {
@@ -126,7 +127,7 @@ public class EventListener implements Listener {
return USER_MANAGER;
}
public static AntiCheat getPlugin() {
public static AntiCheatReloaded getPlugin() {
return PLUGIN;
}
@@ -16,12 +16,8 @@
* 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.event.EventHandler;
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.InventoryType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
public class InventoryListener extends EventListener {
@EventHandler
@@ -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
@@ -16,7 +16,7 @@
* 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.GameMode;
@@ -51,21 +51,21 @@ import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.inventory.PlayerInventory;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
import net.gravitydevelopment.anticheat.check.movement.ElytraFly;
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck;
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.Permission;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraFly;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class PlayerListener extends EventListener {
@@ -82,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
@@ -91,7 +91,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer());
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -100,7 +100,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer());
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -121,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
@@ -130,14 +130,14 @@ public class PlayerListener extends EventListener {
getBackend().logTeleport(event.getPlayer());
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
getBackend().logTeleport(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -146,7 +146,7 @@ public class PlayerListener extends EventListener {
getBackend().logToggleSneak(event.getPlayer());
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -160,7 +160,7 @@ public class PlayerListener extends EventListener {
getBackend().logVelocity(player);
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler(ignoreCancelled = true)
@@ -179,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
public void onPlayerKick(PlayerKickEvent event) {
getBackend().garbageClean(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -197,7 +197,7 @@ public class PlayerListener extends EventListener {
getConfig().getLevels().saveLevelFromUser(user);
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -216,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
@@ -238,7 +238,7 @@ public class PlayerListener extends EventListener {
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)
@@ -252,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)
@@ -260,7 +260,7 @@ public class PlayerListener extends EventListener {
if (event.getBed().getType() != Material.BED) return;
getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler(ignoreCancelled = true)
@@ -268,12 +268,12 @@ public class PlayerListener extends EventListener {
if (event.getBed().getType() != Material.BED) return;
getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
public void onPlayerAnimation(PlayerAnimationEvent event) {
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler
@@ -305,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)
@@ -440,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)
@@ -16,15 +16,16 @@
* 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.event.EventHandler;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class VehicleListener extends EventListener {
@EventHandler(ignoreCancelled = true)
@@ -33,7 +34,7 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getEntered());
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler(ignoreCancelled = true)
@@ -42,7 +43,7 @@ public class VehicleListener extends EventListener {
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());
}
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/>.
*/
package net.gravitydevelopment.anticheat.manage;
package com.rammelkast.anticheatreloaded.manage;
import java.util.Map;
import java.util.Map.Entry;
@@ -25,16 +25,16 @@ import java.util.logging.Logger;
import org.bukkit.plugin.RegisteredListener;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.Backend;
import net.gravitydevelopment.anticheat.config.Configuration;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.config.Configuration;
/**
* The internal hub for all managers.
*/
public class AntiCheatManager {
private static AntiCheat plugin = null;
private static AntiCheatReloaded plugin = null;
private static Configuration configuration;
private static UserManager userManager = 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, Long> eventcache = new ConcurrentHashMap<String, Long>();
public AntiCheatManager(AntiCheat instance, Logger logger) {
public AntiCheatManager(AntiCheatReloaded instance, Logger logger) {
plugin = instance;
configuration = new Configuration(plugin, this);
loggingManager = new LoggingManager(plugin, logger, configuration);
@@ -104,7 +104,7 @@ public class AntiCheatManager {
return gen;
}
public AntiCheat getPlugin() {
public AntiCheatReloaded getPlugin() {
return plugin;
}
@@ -16,14 +16,15 @@
* 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.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.HashMap;
import java.util.List;
@@ -174,7 +175,7 @@ public class CheckManager {
&& !isExempt(player, type)
&& !type.checkPermission(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
if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying())
return false;
@@ -16,16 +16,17 @@
* 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.ChatColor;
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.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -41,7 +42,7 @@ public class LoggingManager {
private static List<String> logs = new CopyOnWriteArrayList<String>();
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.config = config;
try {
@@ -69,12 +70,12 @@ public class LoggingManager {
}
public void debugLog(String message) {
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.GRAY + message);
Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.GRAY + message);
logToLogs(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) {
@@ -1,17 +1,17 @@
package net.gravitydevelopment.anticheat.manage;
package com.rammelkast.anticheatreloaded.manage;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.*;
import net.gravitydevelopment.anticheat.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class PacketManager {
private ProtocolManager protocolManager;
private AntiCheat plugin;
private AntiCheatReloaded plugin;
private AntiCheatManager manager;
public PacketManager(ProtocolManager protocolManager, AntiCheat plugin, AntiCheatManager manager) {
public PacketManager(ProtocolManager protocolManager, AntiCheatReloaded plugin, AntiCheatManager manager) {
this.protocolManager = protocolManager;
this.plugin = plugin;
this.manager = manager;
@@ -16,21 +16,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.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;
package com.rammelkast.anticheatreloaded.manage;
import java.util.ArrayList;
import java.util.List;
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 {
private List<User> users = new ArrayList<User>();
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) {
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
if (user.getPlayer() == null) {
return;
}
final String name = user.getName();
for (String event : actions) {
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")) {
user.getPlayer().kickPlayer(RED + kickReason);
AntiCheatReloaded.getPlugin().onPlayerKicked();
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
if (!msg.equals("")) {
manager.log(msg);
@@ -241,7 +247,7 @@ public class UserManager {
}
}
} 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);
String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
if (!msg.equals("")) {
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.metrics;
package com.rammelkast.anticheatreloaded.metrics;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@@ -16,7 +16,7 @@
* 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;
@@ -16,7 +16,7 @@
* 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;
@@ -16,7 +16,7 @@
* 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.SimpleDateFormat;
@@ -16,11 +16,12 @@
* 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 com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -40,8 +41,8 @@ public class Group {
ChatColor c = ChatColor.valueOf(color);
if (c == null) {
AntiCheat.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("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
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 {
this.color = c;
}
@@ -74,9 +75,9 @@ public class Group {
throw new Exception();
}
} catch (Exception ex) {
AntiCheat.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'");
AntiCheat.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
AntiCheatReloaded.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheatReloaded.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
return null;
}
}
@@ -1,8 +1,9 @@
package net.gravitydevelopment.anticheat.util;
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 {
@@ -15,4 +16,6 @@ public class NMS_1_9_PLUS {
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.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.MinecraftServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_11_R1.PlayerConnection;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import net.minecraft.server.v1_11_R1.World;
import net.minecraft.server.v1_11_R1.WorldServer;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumItemSlot;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_12_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_12_R1.PlayerConnection;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_12_R1.World;
import net.minecraft.server.v1_12_R1.WorldServer;
public class NPC_1_11 {
public class NPC_1_12 {
private final UUID owner;
private final String name;
@@ -42,7 +46,7 @@ public class NPC_1_11 {
return this.entityId;
}
public NPC_1_11(Player owner) {
public NPC_1_12(Player owner) {
this.owner = owner.getUniqueId();
this.name = NameGenerator.generateName();
Location eyelocation = owner.getEyeLocation();
@@ -62,6 +66,8 @@ public class NPC_1_11 {
this.location.getZ(), 0.0f, 0.0f);
this.npc.collides = false;
this.npc.setInvisible(true);
this.npc.setEquipment(EnumItemSlot.CHEST, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_CHESTPLATE)) : CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_CHESTPLATE)));
this.npc.setEquipment(EnumItemSlot.FEET, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_BOOTS)) : CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_BOOTS)));
this.entityId = this.npc.getId();
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
@@ -89,10 +95,13 @@ public class NPC_1_11 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 4);
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
}
}else {
Location eyelocation = e.getPlayer().getEyeLocation();
@@ -137,10 +146,13 @@ public class NPC_1_11 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6);
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6);
}
}
}
@@ -159,15 +171,18 @@ public class NPC_1_11 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7));
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(7));
}
}
public void damage() {
if (this.npc == null) {
if (this.npc == null || this.getOwner() == null) {
return;
}
if (new Random().nextBoolean() && this.npc.isInvisible()) {
@@ -176,10 +191,13 @@ public class NPC_1_11 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(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.List;
@@ -12,7 +12,12 @@ public class NameGenerator {
"NoHax",
"Just",
"That",
"New"
"New",
"Ultra",
"Killer",
"Swift",
"Yolo",
"Rammel"
});
private static final List<String> END = Arrays.asList(new String[]{
@@ -21,7 +26,10 @@ public class NameGenerator {
"JustYolo",
"Gaming",
"Minecraft",
"Games"
"Games",
"Bawz",
"kast",
"" + new Random().nextInt(100)
});
public static String generateName() {
@@ -1,4 +1,4 @@
package net.gravitydevelopment.anticheat.util;
package com.rammelkast.anticheatreloaded.util;
import java.util.Random;
@@ -16,17 +16,18 @@
* 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.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
@@ -103,7 +104,7 @@ public class PastebinReport {
}
private void appendLogs() {
List<String> logs = AntiCheat.getManager().getLoggingManager().getLastLogs();
List<String> logs = AntiCheatReloaded.getManager().getLoggingManager().getLastLogs();
if (logs.size() == 0) {
append("No recent logs.");
return;
@@ -115,8 +116,8 @@ public class PastebinReport {
private void appendSystemInfo() {
Runtime runtime = Runtime.getRuntime();
Configuration config = AntiCheat.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheat.getVersion());
Configuration config = AntiCheatReloaded.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheatReloaded.getVersion());
append("Server Version: " + Bukkit.getVersion());
append("Server Implementation: " + Bukkit.getName());
append("Server ID: " + Bukkit.getServerId());
@@ -129,7 +130,7 @@ public class PastebinReport {
append("Online Mode: " + Bukkit.getOnlineMode());
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
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());
if (config.getConfig().enterprise.getValue()) {
append("- Server name: " + config.getEnterprise().serverName.getValue());
@@ -142,8 +143,8 @@ public class PastebinReport {
private void appendMagicDiff() {
// This is hacky, and I like it
Magic magic = AntiCheat.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheat.getPlugin().getDataFolder(), "magic.yml"));
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "magic.yml"));
boolean changed = false;
for (Field field : Magic.class.getFields()) {
Object defaultValue = file.get(field.getName());
@@ -168,11 +169,11 @@ public class PastebinReport {
}
private void appendEventHandlers() {
report.append(AntiCheat.getManager().getEventChainReport());
report.append(AntiCheatReloaded.getManager().getEventChainReport());
}
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);
BufferedWriter writer = new BufferedWriter(r);
writer.write(report.toString());
@@ -16,7 +16,7 @@
* 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;
@@ -16,7 +16,7 @@
* 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;
@@ -16,18 +16,19 @@
* 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.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
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.util.ArrayList;
import java.util.List;
@@ -40,7 +41,7 @@ public class User {
private int level = 0;
private Location goodLocation;
private List<ItemStack> inventorySnapshot = null;
private Configuration config = AntiCheat.getManager().getConfiguration();
private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
private int toX, toY, toZ;
private String[] messages = new String[2];
private Long[] messageTimes = new Long[2];
@@ -150,7 +151,7 @@ public class User {
// Check levels
for (Group l : getLevels()) {
if (l.getLevel() == level) {
AntiCheat.getManager().getUserManager().alert(this, l, type);
AntiCheatReloaded.getManager().getUserManager().alert(this, l, type);
if (l.getLevel() == config.getGroups().getHighestLevel()) {
level = l.getLevel() - 10;
}
@@ -16,9 +16,8 @@
* 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.Location;
import org.bukkit.Material;
@@ -29,6 +28,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.NumberConversions;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -58,7 +59,7 @@ public final class Utilities {
}
}
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/>.
*/
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.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.DriverManager;
import java.sql.PreparedStatement;
@@ -136,7 +137,7 @@ public class Database {
connection.setAutoCommit(false);
if (logInterval != 0) {
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
flushEvents();
@@ -145,7 +146,7 @@ public class Database {
}
if(syncLevels && syncInterval != 0) {
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
syncUsers();
@@ -153,7 +154,7 @@ public class Database {
}, syncInterval * 20, syncInterval * 20);
}
AntiCheat.getPlugin().verboseLog("Connected to the database.");
AntiCheatReloaded.getPlugin().verboseLog("Connected to the database.");
} catch (SQLException e) {
e.printStackTrace();
}
@@ -202,7 +203,7 @@ public class Database {
public void cleanEvents() {
if (logLife != 0) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -212,7 +213,7 @@ public class Database {
statement.executeUpdate();
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) {
e.printStackTrace();
}
@@ -222,8 +223,8 @@ public class Database {
}
private void syncUsers() {
for (User user : AntiCheat.getManager().getUserManager().getUsers()) {
AntiCheat.getManager().getConfiguration().getLevels().updateLevelToUser(user);
for (User user : AntiCheatReloaded.getManager().getUserManager().getUsers()) {
AntiCheatReloaded.getManager().getConfiguration().getLevels().updateLevelToUser(user);
}
}
}
@@ -16,14 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.util.rule;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
package com.rammelkast.anticheatreloaded.util.rule;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.SortedMap;
/**
@@ -42,7 +43,7 @@ import java.util.SortedMap;
* 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>
* <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 {
@@ -16,15 +16,16 @@
* 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 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.util.ArrayList;
import java.util.List;
@@ -44,7 +45,7 @@ import java.util.TreeMap;
* <ul>
* <li>Check
* <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><b>Example:</b> Check_SPRINT</li>
* </ul>
@@ -76,7 +77,7 @@ import java.util.TreeMap;
* <p/>
* The Rule class itself is not an functional rule setup,
* 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 {
@@ -145,7 +146,7 @@ public class Rule {
/**
* 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() {
return type;
@@ -174,7 +175,7 @@ public class Rule {
if (variable.equals("player_level") && Utilities.isInt(value)) {
user.setLevel(Integer.parseInt(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)) {
user.setLevel(group.getLevel());
}
@@ -195,7 +196,7 @@ public class Rule {
text = text.split("\\.")[1];
List<String> action = new ArrayList<String>();
action.add(text);
AntiCheat.getManager().getUserManager().execute(user, action, type);
AntiCheatReloaded.getManager().getUserManager().execute(user, action, type);
}
}
@@ -1,222 +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.metrics.Metrics;
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 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();
// Metrics
try {
new Metrics(this);
} 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() {
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,53 +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);
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() || p.hasPotionEffect(NMS_1_9_PLUS.LEVITATION);
} 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 NMS_1_9_PLUS.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;
}
}
public static long getHealTime() {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return 495;
} else {
return 1995;
}
}
}
+2 -3
View File
@@ -1,10 +1,9 @@
name: AntiCheatReloaded
author: Rammelkast
description: AntiCheatReloaded helps easily identify and block malicious users on your server.
main: net.gravitydevelopment.anticheat.AntiCheat
softdepend: [ProtocolLib]
main: com.rammelkast.anticheatreloaded.AntiCheatReloaded
depend: [ProtocolLib]
startup: postworld
url: http://gravitydevelopment.net
version: ${project.build.version}
commands:
anticheat: